-
Notifications
You must be signed in to change notification settings - Fork 578
/
jib-gradle.yaml
67 lines (66 loc) · 2.18 KB
/
jib-gradle.yaml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
apiVersion: tekton.dev/v1alpha1
kind: Task
metadata:
name: jib-gradle
spec:
inputs:
params:
- name: DIRECTORY
description: The directory containing the app, relative to the source repository root
default: .
- name: CACHE
description: The name of the volume for caching Gradle artifacts, local Maven repository, and base image layers
default: empty-dir-volume
- name: INSECUREREGISTRY
description: Whether to allow insecure registry
default: "false"
resources:
- name: source
type: git
outputs:
resources:
- name: image
type: image
steps:
- name: build-and-push
image: gcr.io/cloud-builders/gradle
script: |
#!/bin/sh
set -o errexit
# Adds Gradle init script that applies the Jib Gradle plugin.
echo "initscript {
repositories { maven { url 'https://plugins.gradle.org/m2' } }
dependencies { classpath 'gradle.plugin.com.google.cloud.tools:jib-gradle-plugin:+' }
}
rootProject {
afterEvaluate {
if (!project.plugins.hasPlugin('com.google.cloud.tools.jib')) {
project.apply plugin: com.google.cloud.tools.jib.gradle.JibPlugin
}
}
}" > /tekton/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 \
-Djib.allowInsecureRegistries=$(inputs.params.INSECUREREGISTRY) \
-Djib.to.image=$(outputs.resources.image.url)
workingDir: /workspace/source/$(inputs.params.DIRECTORY)
volumeMounts:
- name: $(inputs.params.CACHE)
mountPath: /tekton/home/.gradle/caches
subPath: gradle-caches
- name: $(inputs.params.CACHE)
mountPath: /tekton/home/.gradle/wrapper
subPath: gradle-wrapper
- name: $(inputs.params.CACHE)
mountPath: /tekton/home/.m2
subPath: m2-cache
- name: $(inputs.params.CACHE)
mountPath: /tekton/home/.cache
subPath: jib-cache
volumes:
- name: empty-dir-volume
emptyDir: {}