|
| 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_SCRIPT |
| 23 | + description: Git clone commands |
| 24 | + type: string |
| 25 | + - name: GIT_IDENTITY |
| 26 | + description: Git username |
| 27 | + type: string |
| 28 | + - name: GIT_URL |
| 29 | + description: URL to determine whether we're using gitlab or github |
| 30 | + type: string |
| 31 | + - name: GIT_DEPLOY_TOKEN |
| 32 | + description: Name of jvm-build-git-repo-secrets secret containing git password/token to use. |
| 33 | + type: string |
| 34 | + - name: GIT_SSL_VERIFICATION |
| 35 | + description: Whether to disable ssl verification |
| 36 | + type: string |
| 37 | + default: "false" |
| 38 | + - name: GIT_REUSE_REPOSITORY |
| 39 | + description: Whether to reuse existing git repository or create new one |
| 40 | + type: string |
| 41 | + - name: SCM_URL |
| 42 | + description: Reference to the git repository |
| 43 | + type: string |
| 44 | + - name: SCM_HASH |
| 45 | + description: Git hash |
| 46 | + type: string |
| 47 | + - name: RECIPE_IMAGE |
| 48 | + description: The image from the build recipe to use |
| 49 | + - name: BUILD_SCRIPT |
| 50 | + description: The build script to embed with the Containerfile |
| 51 | + - name: PREPROCESSOR_ARGS |
| 52 | + description: The arguments for the build preprocessor |
| 53 | + - name: ORAS_OPTIONS |
| 54 | + type: string |
| 55 | + description: Optional environment variable string for build-trusted-artifacts |
| 56 | + default: "" |
| 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/redhat-appstudio/hacbs-jvm-build-request-processor:dev" |
| 61 | + results: |
| 62 | + - name: PRE_BUILD_IMAGE_DIGEST |
| 63 | + description: Digest of the image just built |
| 64 | + - name: GIT_ARCHIVE |
| 65 | + description: Git archive information |
| 66 | + workspaces: |
| 67 | + - description: The git repo will be cloned onto the volume backing this Workspace. |
| 68 | + name: source |
| 69 | + mountPath: /var/workdir |
| 70 | + - name: tls |
| 71 | + steps: |
| 72 | + # Should we use our own git clone task? Or embed (somehow) Konflux's version? |
| 73 | + - name: git-clone |
| 74 | + image: $(params.RECIPE_IMAGE) |
| 75 | + computeResources: |
| 76 | + limits: |
| 77 | + cpu: 300m |
| 78 | + memory: 512Mi |
| 79 | + requests: |
| 80 | + cpu: 10m |
| 81 | + memory: 512Mi |
| 82 | + securityContext: |
| 83 | + runAsUser: 0 |
| 84 | + env: |
| 85 | + - name: GIT_TOKEN |
| 86 | + valueFrom: |
| 87 | + secretKeyRef: |
| 88 | + optional: true |
| 89 | + name: jvm-build-git-secrets |
| 90 | + key: .git-credentials |
| 91 | + script: | |
| 92 | + $(params.GIT_SCRIPT) |
| 93 | + - name: preprocessor |
| 94 | + image: $(params.JVM_BUILD_SERVICE_REQPROCESSOR_IMAGE) |
| 95 | + securityContext: |
| 96 | + runAsUser: 0 |
| 97 | + computeResources: |
| 98 | + limits: |
| 99 | + cpu: 300m |
| 100 | + memory: 512Mi |
| 101 | + requests: |
| 102 | + cpu: 10m |
| 103 | + memory: 512Mi |
| 104 | + script: | |
| 105 | + $(params.BUILD_SCRIPT) |
| 106 | + /opt/jboss/container/java/run/run-java.sh $(params.PREPROCESSOR_ARGS) |
| 107 | + - name: create-pre-build-source |
| 108 | + image: $(params.JVM_BUILD_SERVICE_REQPROCESSOR_IMAGE) |
| 109 | + securityContext: |
| 110 | + runAsUser: 0 |
| 111 | + computeResources: |
| 112 | + limits: |
| 113 | + cpu: 300m |
| 114 | + memory: 512Mi |
| 115 | + requests: |
| 116 | + cpu: 10m |
| 117 | + memory: 512Mi |
| 118 | + env: |
| 119 | + - name: GIT_DEPLOY_TOKEN |
| 120 | + valueFrom: |
| 121 | + secretKeyRef: |
| 122 | + optional: true |
| 123 | + name: $(params.GIT_DEPLOY_TOKEN) |
| 124 | + key: gitdeploytoken |
| 125 | + args: |
| 126 | + - deploy-pre-build-source |
| 127 | + - --source-path=$(workspaces.source.path)/source |
| 128 | + - --task-run-name=$(context.taskRun.name) |
| 129 | + - --scm-uri=$(params.SCM_URL) |
| 130 | + - --scm-commit=$(params.SCM_HASH) |
| 131 | + - --image-id=$(params.NAME) |
| 132 | + - --git-identity=$(params.GIT_IDENTITY) |
| 133 | + - --git-url=$(params.GIT_URL) |
| 134 | + - --git-disable-ssl-verification=$(params.GIT_SSL_VERIFICATION) |
| 135 | + - --git-reuse-repository=$(params.GIT_REUSE_REPOSITORY) |
| 136 | + - name: create-pre-build-image |
| 137 | + image: quay.io/redhat-appstudio/build-trusted-artifacts:latest@sha256:d6f57d97d19008437680190908fe5444cda380f9c77d0e9efde7153720412e05 |
| 138 | + script: | |
| 139 | + echo "Creating pre-build-image archive" |
| 140 | + export ORAS_OPTIONS="$ORAS_OPTIONS --image-spec=v1.0 --artifact-type application/vnd.oci.image.config.v1+json" |
| 141 | + create-archive --store $(params.IMAGE_URL) $(results.PRE_BUILD_IMAGE_DIGEST.path)=$(workspaces.source.path)/source |
| 142 | + env: |
| 143 | + - name: ORAS_OPTIONS |
| 144 | + value: $(params.ORAS_OPTIONS) |
| 145 | + - name: IMAGE_URL |
| 146 | + value: $(params.IMAGE_URL) |
| 147 | + |
0 commit comments