|
| 1 | +// Build once a day |
| 2 | +CRON_SETTINGS = '''H H * * *''' |
| 3 | +NODE_LABEL = 'dockerBuild&&linux&&x64' |
| 4 | + |
| 5 | +pipeline { |
| 6 | + agent none |
| 7 | + parameters { |
| 8 | + string(name: 'UPSTREAM_JOB_NAME', defaultValue: '', description: 'Pipeline job with sbom filesCompared nightly build job name') |
| 9 | + string(name: 'UPSTREAM_JOB_NUMBER', defaultValue: '', description: 'Pipeline job number') |
| 10 | + |
| 11 | + } |
| 12 | + stages { |
| 13 | + stage('Post-Build') { |
| 14 | + parallel { |
| 15 | + stage('sbomSign') { |
| 16 | + agent { |
| 17 | + label NODE_LABEL |
| 18 | + } |
| 19 | + steps { |
| 20 | + sbomSign() |
| 21 | + } |
| 22 | + } |
| 23 | + } |
| 24 | + } |
| 25 | + } |
| 26 | +} |
| 27 | + |
| 28 | +def sbomSign() { |
| 29 | + cleanWs() |
| 30 | + docker.image('adoptopenjdk/centos7_build_image').inside { |
| 31 | + checkout scm |
| 32 | + checkout([$class: 'GitSCM', branches: [[name: 'post']], doGenerateSubmoduleConfigurations: false, extensions: [[$class: 'RelativeTargetDirectory', relativeTargetDir: "sbomSign"]], submoduleCfg: [], userRemoteConfigs: [[url: "https://github.com/sophia-guo/openjdk-build.git"]]]) |
| 33 | + copyArtifacts excludes: '**/OpenJDK*-sbom*metadata.json', |
| 34 | + filter: '**/OpenJDK*-sbom*.json', |
| 35 | + fingerprintArtifacts: true, |
| 36 | + flatten: true, |
| 37 | + projectName: "${params.UPSTREAM_JOB_NAME}", |
| 38 | + target: 'sbom/', |
| 39 | + selector: specific("${params.UPSTREAM_JOB_NUMBER}") |
| 40 | + script { |
| 41 | + dir("sbomSign/cyclonedx-lib") { |
| 42 | + sh label: 'build-sign-sbom', script: ''' |
| 43 | + JAVA_HOME=/usr/lib/jvm/jdk-17 ant clean |
| 44 | + JAVA_HOME=/usr/lib/jvm/jdk-17 ant build-sign-sbom |
| 45 | + openssl genpkey -algorithm RSA -pass pass:test -outform PEM -out testPrivateFile -pkeyopt rsa_keygen_bits:2048 |
| 46 | + openssl rsa -in testPrivateFile -passin pass:test -pubout -out publicPemFile |
| 47 | + ''' |
| 48 | + } |
| 49 | + def sbomFiles = findFiles(glob: "**/OpenJDK*-sbom*.json") |
| 50 | + for (def sbomFile: sbomFiles) { |
| 51 | + def sbomFileName = sbomFile.path |
| 52 | + def classPath = "sbomSign/cyclonedx-lib/build/jar/*" |
| 53 | + sh label: 'sign-sbom', script: """ |
| 54 | + /usr/lib/jvm/jdk-17/bin/java -cp "${classPath}" temurin.sbom.TemurinSignSBOM --signSBOM --jsonFile ${sbomFileName} --privateKeyFile ./sbomSign/cyclonedx-lib/testPrivateFile |
| 55 | + /usr/lib/jvm/jdk-17/bin/java -cp "${classPath}" temurin.sbom.TemurinSignSBOM --verifySignature --jsonFile ${sbomFileName} --publicKeyFile ./sbomSign/cyclonedx-lib/publicPemFile |
| 56 | + """ |
| 57 | + } |
| 58 | + } |
| 59 | + archiveArtifacts artifacts: "**/OpenJDK*-sbom*.json" |
| 60 | + } |
| 61 | +} |
0 commit comments