Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make jib-gradle and jib-maven future-proof regarding Tekton $HOME deprecation #407

Merged
merged 1 commit into from
Jul 22, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions task/jib-gradle/0.1/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,8 @@ kubectl apply -f https://raw.githubusercontent.com/tektoncd/catalog/master/task/
This TaskRun runs the Task to fetch a Git repo, and build and push a container
image using Jib (Gradle)

```
apiVersion: tekton.dev/v1alpha1
```yaml
apiVersion: tekton.dev/v1beta1
kind: PipelineResource
metadata:
name: example-image
Expand All @@ -43,7 +43,7 @@ spec:
value: gcr.io/tekton-task-project/my-image
```

```
```yaml
apiVersion: tekton.dev/v1beta1
kind: TaskRun
metadata:
Expand Down
24 changes: 16 additions & 8 deletions task/jib-gradle/0.1/jib-gradle.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -47,28 +47,36 @@ spec:
project.apply plugin: com.google.cloud.tools.jib.gradle.JibPlugin
}
}
}" > /tekton/home/init-script.gradle
}" > $HOME/init-script.gradle
# Runs the Gradle Jib build.
gradle jib \
--stacktrace --console=plain \
--init-script=/tekton/home/init-script.gradle \
-Duser.home=/tekton/home \
-Dgradle.user.home=/tekton/home/.gradle \
--init-script=$HOME/init-script.gradle \
--gradle-user-home=$HOME/.gradle \
-Dgradle.user.home=$HOME/.gradle \
-Duser.home=$HOME \
-Djib.allowInsecureRegistries=$(params.INSECUREREGISTRY) \
-Djib.to.image=$(resources.outputs.image.url)
workingDir: $(workspaces.source.path)/$(params.DIRECTORY)
env:
- name: HOME
value: /workspace
volumeMounts:
# empty volume required to make the Gradle home globally writable
- name: empty-dir-volume
mountPath: /workspace/.gradle
subPath: gradle-user-home
- name: $(params.CACHE)
mountPath: /tekton/home/.gradle/caches
mountPath: /workspace/.gradle/caches
subPath: gradle-caches
- name: $(params.CACHE)
mountPath: /tekton/home/.gradle/wrapper
mountPath: /workspace/.gradle/wrapper
subPath: gradle-wrapper
- name: $(params.CACHE)
mountPath: /tekton/home/.m2
mountPath: /workspace/.m2
subPath: m2-cache
- name: $(params.CACHE)
mountPath: /tekton/home/.cache
mountPath: /workspace/.cache
subPath: jib-cache
securityContext:
runAsUser: 0
Expand Down
6 changes: 3 additions & 3 deletions task/jib-maven/0.1/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,8 @@ kubectl apply -f https://raw.githubusercontent.com/tektoncd/catalog/master/task/
This TaskRun runs the Task to fetch a Git repo, and build and push a container
image using Jib (Maven)

```
apiVersion: tekton.dev/v1alpha1
```yaml
apiVersion: tekton.dev/v1beta1
kind: PipelineResource
metadata:
name: example-image
Expand All @@ -43,7 +43,7 @@ spec:
value: gcr.io/tekton-task-project/my-image
```

```
```yaml
apiVersion: tekton.dev/v1beta1
kind: TaskRun
metadata:
Expand Down
24 changes: 14 additions & 10 deletions task/jib-maven/0.1/jib-maven.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -33,21 +33,25 @@ spec:
steps:
- name: build-and-push
image: gcr.io/cloud-builders/mvn
command:
- mvn
- -B
- compile
- com.google.cloud.tools:jib-maven-plugin:build
- -Duser.home=/tekton/home
- -Djib.allowInsecureRegistries=$(params.INSECUREREGISTRY)
- -Djib.to.image=$(resources.outputs.image.url)
# Make sh evaluate $HOME.
script: |
#!/bin/sh
mvn -B \
-Duser.home=$HOME \
-Djib.allowInsecureRegistries=$(params.INSECUREREGISTRY) \
-Djib.to.image=$(resources.outputs.image.url) \
compile \
com.google.cloud.tools:jib-maven-plugin:build
workingDir: $(workspaces.source.path)/$(params.DIRECTORY)
env:
- name: HOME
value: /workspace
volumeMounts:
- name: $(params.CACHE)
mountPath: /tekton/home/.m2
mountPath: /workspace/.m2
subPath: m2-cache
- name: $(params.CACHE)
mountPath: /tekton/home/.cache
mountPath: /workspace/.cache
subPath: jib-cache

volumes:
Expand Down