|
| 1 | +# Copyright © 2025 Cask Data, Inc. |
| 2 | +# Licensed under the Apache License, Version 2.0 (the "License"); you may not |
| 3 | +# use this file except in compliance with the License. You may obtain a copy of |
| 4 | +# the License at |
| 5 | +# http://www.apache.org/licenses/LICENSE-2.0 |
| 6 | +# Unless required by applicable law or agreed to in writing, software |
| 7 | +# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT |
| 8 | +# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the |
| 9 | +# License for the specific language governing permissions and limitations under |
| 10 | +# the License. |
| 11 | + |
| 12 | +steps: |
| 13 | + - name: 'maven:3.8-jdk-8' # Specify a Maven image |
| 14 | + id: maven-package |
| 15 | + entrypoint: 'mvn' |
| 16 | + args: |
| 17 | + - -B |
| 18 | + - -U |
| 19 | + - clean |
| 20 | + - package |
| 21 | + - -DskipTests |
| 22 | + |
| 23 | + - name: 'anchore/syft:v1.5.0' |
| 24 | + id: generate-sbom |
| 25 | + args: |
| 26 | + - 'packages' |
| 27 | + - '-o' |
| 28 | + - 'spdx-json=/workspace/attestations/project-sbom.spdx.json' |
| 29 | + - '.' |
| 30 | + waitFor: ['maven-package'] |
| 31 | + |
| 32 | + - name: 'bash' |
| 33 | + id: stage-artifacts |
| 34 | + entrypoint: 'bash' |
| 35 | + args: |
| 36 | + - '-c' |
| 37 | + - | |
| 38 | + set -e |
| 39 | + mkdir -p /workspace/staging |
| 40 | + mkdir -p /workspace/attestations |
| 41 | +
|
| 42 | + # Copy Maven artifacts from the 'target' directory |
| 43 | + echo "Copying Maven artifacts..." |
| 44 | + find target -name "*.jar" -exec cp {} /workspace/staging/ \; |
| 45 | + find target -name "*.pom" -exec cp {} /workspace/staging/ \; |
| 46 | + # Add other artifact types if necessary |
| 47 | +
|
| 48 | + # Copy SBOM |
| 49 | + echo "Copying SBOM..." |
| 50 | + if [ -f /workspace/attestations/project-sbom.spdx.json ]; then |
| 51 | + cp /workspace/attestations/project-sbom.spdx.json /workspace/staging/ |
| 52 | + else |
| 53 | + echo "ERROR: SBOM file not found!" |
| 54 | + exit 1 |
| 55 | + fi |
| 56 | +
|
| 57 | + echo "Staged files:" |
| 58 | + ls -l /workspace/staging |
| 59 | + waitFor: ['generate-sbom'] |
| 60 | + |
| 61 | + - name: 'bash' |
| 62 | + id: create-manifest |
| 63 | + entrypoint: 'bash' |
| 64 | + args: |
| 65 | + - '-c' |
| 66 | + - | |
| 67 | + set -e |
| 68 | + echo "Creating manifest.json..." |
| 69 | + cd /workspace/staging |
| 70 | + printf '{\n "artifacts": [\n' > manifest.json |
| 71 | + find . -maxdepth 1 -type f ! -name "manifest.json" | sed 's|./||' | sed 's/.*/ "&",/' >> manifest.json |
| 72 | + sed -i '$ s/,$//' manifest.json |
| 73 | + printf '\n ]\n}\n' >> manifest.json |
| 74 | + echo "Generated manifest.json:" |
| 75 | + cat manifest.json |
| 76 | + cd /workspace |
| 77 | + waitFor: ['stage-artifacts'] |
| 78 | + |
| 79 | + - name: 'gcr.io/cloud-builders/gsutil' |
| 80 | + id: upload-to-staging |
| 81 | + args: |
| 82 | + - '-m' |
| 83 | + - 'cp' |
| 84 | + - '-r' |
| 85 | + - '/workspace/staging/*' |
| 86 | + - 'gs://${_SECURE_PUBLISH_BUCKET_NAME}/cdap/${_ARTIFACT_ID}/${BUILD_ID}/' |
| 87 | + waitFor: ['create-manifest'] |
| 88 | + |
| 89 | +options: |
| 90 | + requestedVerifyOption: VERIFIED |
| 91 | + machineType: 'E2_HIGHCPU_32' |
| 92 | + |
0 commit comments