From 84bb6d320ab8b36c29c4fd5d227b74ea666b8818 Mon Sep 17 00:00:00 2001 From: Vincent Demeester Date: Tue, 10 Mar 2020 17:04:44 +0100 Subject: [PATCH] =?UTF-8?q?jib-gradle:=20use=20workspace=20instead=20of=20?= =?UTF-8?q?GitResource=20=F0=9F=90=90?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This migrate jib-gradle to use `workspace` instead of an input `GitResource`. This also updates e2e tests to use a `Pipeline` in order to clone the repository in the workspace. Signed-off-by: Vincent Demeester --- jib-gradle/README.md | 17 +++---- jib-gradle/jib-gradle.yaml | 7 ++- jib-gradle/tests/pre-apply-task-hook.sh | 3 ++ jib-gradle/tests/resources.yaml | 23 +++++---- jib-gradle/tests/run.yaml | 64 +++++++++++++++++++------ 5 files changed, 74 insertions(+), 40 deletions(-) diff --git a/jib-gradle/README.md b/jib-gradle/README.md index f4545bfa..ce63e255 100644 --- a/jib-gradle/README.md +++ b/jib-gradle/README.md @@ -16,13 +16,13 @@ kubectl apply -f https://raw.githubusercontent.com/tektoncd/catalog/master/jib-g - **DIRECTORY**: The directory in the source repository where source should be found. (*default: .*) - **CACHE**: The name of the volume for caching Gradle artifacts, local Maven repository, and base image layers (*default: empty-dir-volume*) -## Resources - -### Inputs +## Workspaces * **source**: A `git`-type `PipelineResource` specifying the location of the source to build. +## Resources + ### Outputs * **image**: The Docker image name to apply to the newly built image. @@ -55,14 +55,11 @@ spec: params: - name: DIRECTORY value: ./examples/helloworld + workspaces: + - name: source + persistentVolumeClaim: + claimName: my-source resources: - inputs: - - name: source - resourceSpec: - type: git - params: - - name: url - value: https://github.com/my-user/my-repo outputs: - name: image resourceRef: diff --git a/jib-gradle/jib-gradle.yaml b/jib-gradle/jib-gradle.yaml index bcf8c635..66016245 100644 --- a/jib-gradle/jib-gradle.yaml +++ b/jib-gradle/jib-gradle.yaml @@ -13,10 +13,9 @@ spec: - name: INSECUREREGISTRY description: Whether to allow insecure registry default: "false" + workspaces: + - name: source resources: - inputs: - - name: source - type: git outputs: - name: image type: image @@ -46,7 +45,7 @@ spec: -Dgradle.user.home=/tekton/home/.gradle \ -Djib.allowInsecureRegistries=$(params.INSECUREREGISTRY) \ -Djib.to.image=$(resources.outputs.image.url) - workingDir: /workspace/source/$(params.DIRECTORY) + workingDir: $(workspaces.source.path)/$(params.DIRECTORY) volumeMounts: - name: $(params.CACHE) mountPath: /tekton/home/.gradle/caches diff --git a/jib-gradle/tests/pre-apply-task-hook.sh b/jib-gradle/tests/pre-apply-task-hook.sh index 4287a669..cf2406f8 100755 --- a/jib-gradle/tests/pre-apply-task-hook.sh +++ b/jib-gradle/tests/pre-apply-task-hook.sh @@ -3,3 +3,6 @@ # Add an internal registry as sidecar to the task so we can upload it directly # from our tests withouth having to go to an external registry. add_sidecar_registry ${TMPF} + +# Add git-clone +kubectl -n ${tns} apply -f ./git/git-clone.yaml diff --git a/jib-gradle/tests/resources.yaml b/jib-gradle/tests/resources.yaml index da3959b8..1c2079dc 100644 --- a/jib-gradle/tests/resources.yaml +++ b/jib-gradle/tests/resources.yaml @@ -1,18 +1,6 @@ --- apiVersion: tekton.dev/v1alpha1 kind: PipelineResource -metadata: - name: console-java-simple -spec: - type: git - params: - - name: revision - value: master - - name: url - value: https://github.com/che-samples/console-java-simple ---- -apiVersion: tekton.dev/v1alpha1 -kind: PipelineResource metadata: name: image spec: @@ -20,3 +8,14 @@ spec: params: - name: url value: localhost:5000/tekton-pipelines/console-java-simple +--- +apiVersion: v1 +kind: PersistentVolumeClaim +metadata: + name: jib-gradle-source-pvc +spec: + accessModes: + - ReadWriteOnce + resources: + requests: + storage: 500Mi diff --git a/jib-gradle/tests/run.yaml b/jib-gradle/tests/run.yaml index be2775bb..e79e5eab 100644 --- a/jib-gradle/tests/run.yaml +++ b/jib-gradle/tests/run.yaml @@ -1,20 +1,56 @@ --- apiVersion: tekton.dev/v1beta1 -kind: TaskRun +kind: Pipeline metadata: - name: jib-gradle-run + name: jib-gradle-test-pipeline spec: - taskRef: - name: jib-gradle + workspaces: + - name: shared-workspace resources: - outputs: - - name: image - resourceRef: - name: image - inputs: + - name: build-image + type: image + tasks: + - name: fetch-repository + taskRef: + name: git-clone + workspaces: + - name: output + workspace: shared-workspace + params: + - name: url + value: https://github.com/che-samples/console-java-simple + - name: subdirectory + value: "" + - name: deleteExisting + value: "true" + - name: jib-gradle + taskRef: + name: jib-gradle + runAfter: + - fetch-repository + workspaces: - name: source - resourceRef: - name: console-java-simple - params: - - name: INSECUREREGISTRY - value: "true" + workspace: shared-workspace + params: + - name: INSECUREREGISTRY + value: "true" + resources: + outputs: + - name: image + resource: build-image +--- +apiVersion: tekton.dev/v1beta1 +kind: PipelineRun +metadata: + name: jib-gradle-test-pipeline-run +spec: + pipelineRef: + name: jib-gradle-test-pipeline + workspaces: + - name: shared-workspace + persistentvolumeclaim: + claimName: jib-gradle-source-pvc + resources: + - name: build-image + resourceRef: + name: image