|
| 1 | +--- |
| 2 | +apiVersion: tekton.dev/v1 |
| 3 | +kind: Task |
| 4 | +metadata: |
| 5 | + name: pre-build |
| 6 | + annotations: |
| 7 | + tekton.dev/pipelines.minVersion: 0.12.1 |
| 8 | + tekton.dev/tags: image-build, konflux |
| 9 | + labels: |
| 10 | + app.kubernetes.io/version: "0.1" |
| 11 | + build.appstudio.redhat.com/build_type: docker |
| 12 | +spec: |
| 13 | + description: |- |
| 14 | + Sets up pre-build running the preprocessor, pushing the source and creating the OCI image. |
| 15 | + params: |
| 16 | + - name: IMAGE_URL |
| 17 | + description: URL of the OCI image to use. |
| 18 | + type: string |
| 19 | + - name: NAME |
| 20 | + description: Name of the pipeline run (i.e. unique dependency build name) |
| 21 | + type: string |
| 22 | + - name: GIT_IDENTITY |
| 23 | + description: Git username. If empty, deploy-pre-build-source step will be skipped. |
| 24 | + type: string |
| 25 | + default: "" |
| 26 | + - name: GIT_URL |
| 27 | + description: String to determine whether we're using gitlab or github |
| 28 | + type: string |
| 29 | + default: "github" |
| 30 | + - name: GIT_SSL_VERIFICATION |
| 31 | + description: Whether to disable ssl verification |
| 32 | + type: string |
| 33 | + default: "false" |
| 34 | + - name: GIT_REUSE_REPOSITORY |
| 35 | + description: Whether to reuse existing git repository or create new one |
| 36 | + type: string |
| 37 | + default: "false" |
| 38 | + - name: SCM_URL |
| 39 | + description: Reference to the git repository |
| 40 | + type: string |
| 41 | + - name: SCM_HASH |
| 42 | + description: Git hash |
| 43 | + type: string |
| 44 | + - name: RECIPE_IMAGE |
| 45 | + description: The image from the build recipe to use |
| 46 | + - name: BUILD_TOOL |
| 47 | + description: The build tool to use (ant, gradle, maven, sbt). |
| 48 | + - name: BUILD_TOOL_VERSION |
| 49 | + description: The build tool version to use (e.g. 3.9.5) |
| 50 | + - name: JAVA_VERSION |
| 51 | + description: Java version to use (7, 8, 9, 11, 17, 21, 22, 23) |
| 52 | + - name: BUILD_PLUGINS |
| 53 | + description: Optional comma separated list of build plugins that should be disabled. |
| 54 | + default: "" |
| 55 | + - name: BUILD_SCRIPT |
| 56 | + description: The build script to embed with the Containerfile |
| 57 | + - name: JVM_BUILD_SERVICE_REQPROCESSOR_IMAGE |
| 58 | + description: Name of the processor image. Useful to override for development. |
| 59 | + type: string |
| 60 | + default: "quay.io/ncross/hacbs-jvm-build-request-processor:latest" |
| 61 | + # default: "quay.io/redhat-user-workloads/konflux-jbs-pnc-tenant/jvm-build-service/build-request-processor:latest" |
| 62 | + results: |
| 63 | + - name: PRE_BUILD_IMAGE_DIGEST |
| 64 | + description: Digest of the image just built |
| 65 | + - name: GIT_ARCHIVE |
| 66 | + description: Git archive information |
| 67 | + workspaces: |
| 68 | + - description: The git repo will be cloned onto the volume backing this Workspace. |
| 69 | + name: source |
| 70 | + mountPath: /var/workdir |
| 71 | + steps: |
| 72 | + - name: preprocessor |
| 73 | + image: $(params.JVM_BUILD_SERVICE_REQPROCESSOR_IMAGE) |
| 74 | + securityContext: |
| 75 | + runAsUser: 0 |
| 76 | + computeResources: |
| 77 | + limits: |
| 78 | + cpu: 300m |
| 79 | + memory: 512Mi |
| 80 | + requests: |
| 81 | + cpu: 10m |
| 82 | + memory: 512Mi |
| 83 | + script: | |
| 84 | + # Complete temporary hack for backwards compatibility with JBS until tasks are ported to build-definitions |
| 85 | + if [[ $(params.JVM_BUILD_SERVICE_REQPROCESSOR_IMAGE) == *"konflux-tooling"* ]]; then |
| 86 | + /opt/jboss/container/java/run/run-java.sh prepare --type=$(params.BUILD_TOOL) --java-version=$(params.JAVA_VERSION) --build-tool-version=$(params.BUILD_TOOL_VERSION) --recipe-image=$(params.RECIPE_IMAGE) --request-processor-image=$(params.JVM_BUILD_SERVICE_REQPROCESSOR_IMAGE) $(workspaces.source.path)/source |
| 87 | + else |
| 88 | + /opt/jboss/container/java/run/run-java.sh $(params.BUILD_TOOL)-prepare --java-version=$(params.JAVA_VERSION) --build-tool-version=$(params.BUILD_TOOL_VERSION) --recipe-image=$(params.RECIPE_IMAGE) --request-processor-image=$(params.JVM_BUILD_SERVICE_REQPROCESSOR_IMAGE) --disabled-plugins=$(params.BUILD_PLUGINS) $(workspaces.source.path)/source |
| 89 | + fi |
| 90 | + env: |
| 91 | + - name: BUILD_SCRIPT |
| 92 | + value: $(params.BUILD_SCRIPT) |
| 93 | + # TODO: Look at making this optional until we know whether we need to store source |
| 94 | + - name: create-pre-build-source |
| 95 | + image: $(params.JVM_BUILD_SERVICE_REQPROCESSOR_IMAGE) |
| 96 | + securityContext: |
| 97 | + runAsUser: 0 |
| 98 | + computeResources: |
| 99 | + limits: |
| 100 | + cpu: 300m |
| 101 | + memory: 512Mi |
| 102 | + requests: |
| 103 | + cpu: 10m |
| 104 | + memory: 512Mi |
| 105 | + env: |
| 106 | + - name: GIT_DEPLOY_TOKEN |
| 107 | + valueFrom: |
| 108 | + secretKeyRef: |
| 109 | + optional: true |
| 110 | + name: jvm-build-git-repo-secrets |
| 111 | + key: gitdeploytoken |
| 112 | + args: |
| 113 | + - deploy-pre-build-source |
| 114 | + - --source-path=$(workspaces.source.path)/source |
| 115 | + - --task-run-name=$(context.taskRun.name) |
| 116 | + - --scm-uri=$(params.SCM_URL) |
| 117 | + - --scm-commit=$(params.SCM_HASH) |
| 118 | + - --image-id=$(params.NAME) |
| 119 | + - --git-identity=$(params.GIT_IDENTITY) |
| 120 | + - --git-url=$(params.GIT_URL) |
| 121 | + - --git-disable-ssl-verification=$(params.GIT_SSL_VERIFICATION) |
| 122 | + - --git-reuse-repository=$(params.GIT_REUSE_REPOSITORY) |
| 123 | + - name: create-pre-build-image |
| 124 | + image: quay.io/redhat-appstudio/build-trusted-artifacts:latest@sha256:52f1391e6f1c472fd10bb838f64fae2ed3320c636f536014978a5ddbdfc6b3af |
| 125 | + script: | |
| 126 | + set -x |
| 127 | + echo "IMAGE is $(params.IMAGE_URL)" |
| 128 | + cat $HOME/.docker/config.json || true |
| 129 | + echo "Creating pre-build-image archive" |
| 130 | + create-archive --store $(params.IMAGE_URL) $(results.PRE_BUILD_IMAGE_DIGEST.path)=$(workspaces.source.path)/source |
| 131 | + env: |
| 132 | + - name: IMAGE_URL |
| 133 | + value: $(params.IMAGE_URL) |
0 commit comments