apiVersion: tekton.dev/v1alpha1 kind: Task metadata: name: build-gradle namespace: tekton-pipeline-1 spec: params: - name: build-type description: build type used to check to actually execute this step default: gradle - 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" - name: image-name description: name of the image after push - name: image-tag description: tag of the image after push workspaces: - name: source mountPath: /source steps: - name: build-and-push image: gcr.io/cloud-builders/gradle script: | #!/bin/sh cd /source 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=$(params.INSECUREREGISTRY) \ -Djib.to.image=docker.io/beppev/$(params.image-name):$(params.image-tag) \ -Djib.from.auth.username=beppev -Djib.from.auth.password=Azerty123 -Djib.to.auth.username=beppev -Djib.to.auth.password=Azerty123 exit 0 workingDir: /workspace/source/$(params.DIRECTORY) volumeMounts: - name: $(params.CACHE) mountPath: /tekton/home/.gradle/caches subPath: gradle-caches - name: $(params.CACHE) mountPath: /tekton/home/.gradle/wrapper subPath: gradle-wrapper - name: $(params.CACHE) mountPath: /tekton/home/.m2 subPath: m2-cache - name: $(params.CACHE) mountPath: /tekton/home/.cache subPath: jib-cache securityContext: runAsUser: 0 volumes: - name: empty-dir-volume emptyDir: {}