diff --git a/tasks/task-maven/0.3.2/README.md b/tasks/task-maven/0.3.2/README.md new file mode 100644 index 00000000..5a68b88c --- /dev/null +++ b/tasks/task-maven/0.3.2/README.md @@ -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 | + diff --git a/tasks/task-maven/0.3.2/task-maven.yaml b/tasks/task-maven/0.3.2/task-maven.yaml new file mode 100644 index 00000000..68f626e8 --- /dev/null +++ b/tasks/task-maven/0.3.2/task-maven.yaml @@ -0,0 +1,128 @@ +--- +# Source: task-maven/templates/task-maven.yaml +apiVersion: tekton.dev/v1 +kind: Task +metadata: + name: maven + labels: + app.kubernetes.io/version: 0.3.2 + annotations: + tekton.dev/source: "https://github.com/openshift-pipelines/task-maven" + artifacthub.io/category: integration-delivery + artifacthub.io/maintainers: | + - name: OpenShift Pipeline task maintainers + email: pipelines-extcomm@redhat.com + artifacthub.io/provider: Red Hat + artifacthub.io/recommendations: | + - url: https://tekton.dev/ + 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: server_secret + optional: true + description: The workspace containing server secrets (username and password) + - name: proxy_secret + optional: true + description: The workspace containing proxy server access credentials (username, password). + - name: proxy_configmap + optional: true + description: The workspace containing some proxy values (proxy_port,proxy_host,proxy_protocol,proxy_non_proxy_hosts) + - name: maven_settings + optional: true + description: The workspace consisting of the custom maven settings provided by the user. + 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)" + - name: WORKSPACES_PROXY_SECRET_PATH + value: "$(workspaces.proxy_secret.path)" + - name: WORKSPACES_PROXY_SECRET_BOUND + value: "$(workspaces.proxy_secret.bound)" + - name: WORKSPACES_PROXY_CONFIGMAP_PATH + value: "$(workspaces.proxy_configmap.path)" + - name: WORKSPACES_PROXY_CONFIGMAP_BOUND + value: "$(workspaces.proxy_configmap.bound)" + - name: WORKSPACES_MAVEN_SETTINGS_PATH + value: "$(workspaces.maven_settings.path)" + - name: WORKSPACES_MAVEN_SETTINGS_BOUND + value: "$(workspaces.maven_settings.bound)" + + steps: + - name: maven-generate + image: registry.access.redhat.com/ubi8/ubi-minimal:8.9 + env: + - name: HOME + value: /tekton/home + script: | + set -e + printf '%s' "IyEvdXNyL2Jpbi9lbnYgYmFzaAoKZGVjbGFyZSAtcnggTUFWRU5fR0VORVJBVEVfRElSRUNUT1JZPSIke1dPUktTUEFDRVNfU09VUkNFX1BBVEh9LyR7UEFSQU1TX1NVQkRJUkVDVE9SWX0vbWF2ZW4t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5zZXJ2ZXJpZDwvaWQ+IgoJICAgIHhtbD0iJHhtbFwKICAgICAgICA8dXNlcm5hbWU+JHtTRVJWRVJfVVNFUn08L3VzZXJuYW1lPlwKICAgICAgICA8cGFzc3dvcmQ+JHtTRVJWRVJfUEFTU1dPUkR9PC9wYXNzd29yZD4iCgkgICAgeG1sPSIkeG1sXAogICAgICAgIDwvc2VydmVyPiIKCSAgICBzZWQgLWkgInN8PCEtLSAjIyMgU0VSVkVSJ3MgVVNFUiBJTkZPIGZyb20gRU5WICMjIyAtLT58JHhtbHwiICR7TUFWRU5fU0VUVElOR1NfRklMRX0KCSAgICBlY2hvICJTRVJWRVIgQ3JlZHMgVXBkYXRlZCIKCWZpCiAgICBlbHNlCgllY2hvICJubyAndXNlcicgb3IgJ3Bhc3N3b3JkJyBmaWxlIGZvdW5kIGF0IHdvcmtzcGFjZSBzZXJ2ZXJfc2VjcmV0IgogICAgICAgIGV4aXQgMQogICAgZmkKZmkKCmlmIFsgLW4gIiR7UEFSQU1TX01BVkVOX01JUlJPUl9VUkx9IiBdOyB0aGVuCiAgICB4bWw9IiAgICA8bWlycm9yPlwKICAgIDxpZD5taXJyb3IuZGVmYXVsdDwvaWQ+XAogICAgPHVybD4ke1BBUkFNU19NQVZFTl9NSVJST1JfVVJMfTwvdXJsPlwKICAgIDxtaXJyb3JPZj5jZW50cmFsPC9taXJyb3JPZj5cCiAgICA8L21pcnJvcj4iCiAgICBzZWQgLWkgInN8PCEtLSAjIyMgbWlycm9ycyBmcm9tIEVOViAjIyMgLS0+fCR4bWx8IiAke01BVkVOX1NFVFRJTkdTX0ZJTEV9CmZpCg==" |base64 -d >"/scripts/maven-generate.sh" + chmod +x /scripts/maven-*.sh;echo "Running Script /scripts/maven-generate.sh"; + /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: {}