Skip to content

Commit

Permalink
task-maven: Auto-update tekton tasks resources\n\nURL: https://github…
Browse files Browse the repository at this point in the history
  • Loading branch information
github-actions authored and openshift-merge-bot[bot] committed Dec 21, 2023
1 parent 11852e3 commit b6222d7
Show file tree
Hide file tree
Showing 2 changed files with 130 additions and 0 deletions.
22 changes: 22 additions & 0 deletions tasks/task-maven/0.1.0/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
# `maven` Tekton Task

The `maven` Task can be used to run a Maven goal on a simple or multi-module maven project.

## Workspaces

### `source`

The `source` workspace is required. It contains the source of the "maven" project to build. It should contain a `pom.xml`.

## `server_secret` (optional)

The `server_secret` is optional. It should contain two *files* : `username` and `password`. It is possible to bind a `ConfigMap` or a `Secret` to this workspace ; in that case, the `ConfigMap` or `Secret` should have a `username` and a `password` key.

## Parameters

| Parameter | Type | Default | Description |
|:-------------------|:---------|:-----------|:-----------------------------------------------------------------------------------|
| `GOALS` | `string` | `package` | The `maven` goal(s) to run |
| `MAVEN_MIRROR_URL` | `string` | "" (empty) | The maven repository mirror URL to use |
| `SUBDIRECTORY` | `string` | `.` | The subdirectory of the `source` workspace on which we want to execute maven goals |

108 changes: 108 additions & 0 deletions tasks/task-maven/0.1.0/task-maven.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,108 @@
---
# Source: task-maven/templates/task-maven.yaml
apiVersion: tekton.dev/v1beta1
kind: Task
metadata:
name: maven
labels:
app.kubernetes.io/version: 0.1.0
annotations:
tekton.dev/categories: containers
tekton.dev/pipelines.minVersion: 0.41.0
tekton.dev/tags: containers
spec:
description: >-
This Task can be used to run a Maven build.
workspaces:
- name: source
optional: false
description: The workspace consisting of maven project.
- name: sever_secret
optional: true
description: The workspace containing server secrets (user and password file)

params:
- name: GOALS
description: maven goals to run
type: array
default:
- "package"
- name: MAVEN_MIRROR_URL
description: The Maven repository mirror url
type: string
default: ""
- name: SUBDIRECTORY
type: string
description: >-
The subdirectory within the repository for sources on
which we want to execute maven goals.
default: "."

stepTemplate:
env:

- name: PARAMS_MAVEN_MIRROR_URL
value: "$(params.MAVEN_MIRROR_URL)"
- name: PARAMS_SUBDIRECTORY
value: "$(params.SUBDIRECTORY)"
- name: WORKSPACES_SOURCE_PATH
value: "$(workspaces.source.path)"
- name: WORKSPACES_SOURCE_BOUND
value: "$(workspaces.source.bound)"
- name: WORKSPACES_SERVER_SECRET_PATH
value: "$(workspaces.server_secret.path)"
- name: WORKSPACES_SERVER_SECRET_BOUND
value: "$(workspaces.server_secret.bound)"

steps:
- name: load-scripts
image: registry.access.redhat.com/ubi8/ubi-minimal:8.9
workingDir: /scripts
script: |
set -e
printf '%s' "IyEvdXNyL2Jpbi9lbnYgYmFzaAoKZGVjbGFyZSAtcnggTUFWRU5fR0VORVJBVEVfRElSRUNUT1JZPSIke1dPUktTUEFDRVNfU09VUkNFX1BBVEh9L21hdmVuLWdlbmVyYXRlIgoKZGVjbGFyZSAtcnggTUFWRU5fU0VUVElOR1NfRklMRT0iJHtNQVZFTl9HRU5FUkFURV9ESVJFQ1RPUll9L3NldHRpbmdzLnhtbCIKCmlmIFtbIC1mICR7TUFWRU5fU0VUVElOR1NfRklMRX0gXV07IHRoZW4KICAgIGVjaG8gInVzaW5nIGV4aXN0aW5nICcke01BVkVOX1NFVFRJTkdTX0ZJTEV9JyIKICAgIGNhdCAke01BVkVOX1NFVFRJTkdTX0ZJTEV9CiAgICBleGl0IDAKZmkKCm1rZGlyICIke01BVkVOX0dFTkVSQVRFX0RJUkVDVE9SWX0iCgpjYXQgPiAiJHtNQVZFTl9TRVRUSU5HU19GSUxFfSIgPDxFT0YKPHNldHRpbmdzPgogICAgPHNlcnZlcnM+CiAgICA8IS0tIFRoZSBzZXJ2ZXJzIGFkZGVkIGhlcmUgYXJlIGdlbmVyYXRlZCBmcm9tIGVudmlyb25tZW50IHZhcmlhYmxlcy4gRG9uJ3QgY2hhbmdlLiAtLT4KICAgIDwhLS0gIyMjIFNFUlZFUidzIFVTRVIgSU5GTyBmcm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AgICA8cGFzc3dvcmQ+JHtTRVJWRVJfUEFTU1dPUkR9PC9wYXNzd29yZD4iCgkgICAgeG1sPSIkeG1sXAogICAgICAgIDwvc2VydmVyPiIKCSAgICBzZWQgLWkgInN8PCEtLSAjIyMgU0VSVkVSJ3MgVVNFUiBJTkZPIGZyb20gRU5WICMjIyAtLT58JHhtbHwiICR7TUFWRU5fU0VUVElOR1NfRklMRX0KCSAgICBlY2hvICJTRVJWRVIgQ3JlZHMgVXBkYXRlZCIKCWZpCiAgICBlbHNlCgllY2hvICJubyAndXNlcicgb3IgJ3Bhc3N3b3JkJyBmaWxlIGZvdW5kIGF0IHdvcmtzcGFjZSBzZXJ2ZXJfc2VjcmV0IgogICAgICAgIGV4aXQgMQogICAgZmkKZmkKCmlmIFsgLW4gIiR7UEFSQU1TX01BVkVOX01JUlJPUl9VUkx9IiBdOyB0aGVuCiAgICB4bWw9IiAgICA8bWlycm9yPlwKICAgIDxpZD5taXJyb3IuZGVmYXVsdDwvaWQ+XAogICAgPHVybD4ke1BBUkFNU19NQVZFTl9NSVJST1JfVVJMfTwvdXJsPlwKICAgIDxtaXJyb3JPZj5jZW50cmFsPC9taXJyb3JPZj5cCiAgICA8L21pcnJvcj4iCiAgICBzZWQgLWkgInN8PCEtLSAjIyMgbWlycm9ycyBmcm9tIEVOViAjIyMgLS0+fCR4bWx8IiAke01BVkVOX1NFVFRJTkdTX0ZJTEV9CmZpCg==" |base64 -d >maven-generate.sh
chmod +x maven-*.sh
volumeMounts:
- name: scripts-dir
mountPath: /scripts

- name: maven-generate
image: registry.access.redhat.com/ubi8/ubi-minimal:8.9
env:
- name: HOME
value: /tekton/home
command:
- /scripts/maven-generate.sh
securityContext:
runAsNonRoot: true
runAsUser: 65532
volumeMounts:
- name: scripts-dir
mountPath: /scripts
- name: maven-settings-dir
mountPath: /maven-generate

- name: maven-goals
env:
- name: HOME
value: /tekton/home
image: registry.access.redhat.com/ubi8/openjdk-11:latest
workingDir: $(workspaces.source.path)/$(params.SUBDIRECTORY)
command: ["/usr/bin/mvn"]
args:
- -s
- maven-generate/settings.xml
- "$(params.GOALS[*])"
securityContext:
runAsNonRoot: true
runAsUser: 65532
volumeMounts:
- name: maven-settings-dir
mountPath: /maven-generate

volumes:
- name: scripts-dir
emptyDir: {}
- name: maven-settings-dir
emptyDir: {}

0 comments on commit b6222d7

Please sign in to comment.