Build Member 2 fixture review-to-release pipeline
This commit is contained in:
@@ -0,0 +1,77 @@
|
||||
pipeline {
|
||||
agent { label 'assignment8-trusted' }
|
||||
options { disableConcurrentBuilds(); skipDefaultCheckout(); timeout(time: 45, unit: 'MINUTES'); timestamps() }
|
||||
parameters {
|
||||
string(name: 'SOURCE_SHA', defaultValue: '', description: 'Full SHA of this reviewed pipeline branch and Actions run')
|
||||
string(name: 'ACTIONS_RUN_ID', defaultValue: '', description: 'Exact successful Gitea Actions run')
|
||||
string(name: 'ACTIONS_ATTEMPT', defaultValue: '1', description: 'Exact attempt')
|
||||
choice(name: 'MODE', choices: ['fixture'], description: 'Live mode requires Member 1 integration and review')
|
||||
}
|
||||
stages {
|
||||
stage('Checkout exact source') {
|
||||
steps {
|
||||
script {
|
||||
if (!(params.SOURCE_SHA ==~ /[0-9a-f]{40}/) || !(params.ACTIONS_RUN_ID ==~ /[1-9][0-9]*/) || !(params.ACTIONS_ATTEMPT ==~ /[1-9][0-9]*/)) { error('Invalid run identity') }
|
||||
}
|
||||
deleteDir()
|
||||
checkout scm
|
||||
sh '''set -eu
|
||||
test "$(git rev-parse HEAD)" = "$SOURCE_SHA"
|
||||
mkdir -p out
|
||||
'''
|
||||
}
|
||||
}
|
||||
stage('Retrieve exact Actions bundle') {
|
||||
steps {
|
||||
withCredentials([string(credentialsId: 'final-project-gitea-read', variable: 'GITEA_TOKEN')]) {
|
||||
sh '''set +x
|
||||
set -eu
|
||||
python3 ci/final_project.py fetch --sha "$SOURCE_SHA" --run-id "$ACTIONS_RUN_ID" --attempt "$ACTIONS_ATTEMPT" --mode "$MODE" --output out/review-bundle.zip > out/actions-run.json
|
||||
'''
|
||||
}
|
||||
}
|
||||
}
|
||||
stage('Validate identity and payload hashes') {
|
||||
steps { sh '''set -eu
|
||||
python3 ci/final_project.py verify --bundle out/review-bundle.zip --sha "$SOURCE_SHA" --run-id "$ACTIONS_RUN_ID" --attempt "$ACTIONS_ATTEMPT" --mode "$MODE" --output out/verified
|
||||
sh ci/toolchain.sh start
|
||||
''' }
|
||||
}
|
||||
stage('Reserve durable release version') {
|
||||
steps {
|
||||
script {
|
||||
env.RELEASE_VERSION = sh(script: 'sh ci/toolchain.sh exec python3 ci/final_project.py reserve --sha "$SOURCE_SHA" --run-id "$ACTIONS_RUN_ID" --attempt "$ACTIONS_ATTEMPT" --mode "$MODE" --state /state --baseline 1.0', returnStdout: true).trim()
|
||||
}
|
||||
}
|
||||
}
|
||||
stage('Compile LaTeX report') {
|
||||
steps { sh '''set -eu
|
||||
RUN_NUMBER=$(python3 -c 'import json;print(json.load(open("out/actions-run.json"))["run_number"])')
|
||||
sh ci/toolchain.sh exec python3 documentation/ci/build_manual.py --sha "$SOURCE_SHA" --run-number "$RUN_NUMBER" --run-id "$ACTIONS_RUN_ID" --attempt "$ACTIONS_ATTEMPT" --review-bundle /work/out/review-bundle.zip --release-version "$RELEASE_VERSION" --mode "$MODE" --jenkins-build "$BUILD_NUMBER"
|
||||
''' }
|
||||
}
|
||||
stage('Unit, syntax and reviewed-file smoke tests') {
|
||||
steps { sh '''set -eu
|
||||
sh ci/toolchain.sh exec python3 -m unittest discover -s tests -v
|
||||
sh ci/toolchain.sh exec python3 -m unittest discover -s ci/tests -v
|
||||
sh ci/toolchain.sh exec python3 ci/final_project.py test --review-dir out/verified --output out/test-result.json
|
||||
''' }
|
||||
}
|
||||
stage('Package immutable release') {
|
||||
steps { sh '''set -eu
|
||||
sh ci/toolchain.sh exec python3 ci/final_project.py publish --sha "$SOURCE_SHA" --run-id "$ACTIONS_RUN_ID" --attempt "$ACTIONS_ATTEMPT" --mode "$MODE" --bundle out/review-bundle.zip --pdf documentation/build/main.pdf --state /state --output out/release --jenkins-build "$BUILD_NUMBER"
|
||||
sh ci/toolchain.sh collect
|
||||
''' }
|
||||
}
|
||||
stage('Publish downloadable ZIP') {
|
||||
steps { archiveArtifacts artifacts: 'out/collected/release/*', fingerprint: true }
|
||||
}
|
||||
}
|
||||
post {
|
||||
always {
|
||||
sh 'sh ci/toolchain.sh collect || true'
|
||||
sh 'sh ci/toolchain.sh stop || true'
|
||||
archiveArtifacts artifacts: 'out/actions-run.json,out/collected/test-result.json,out/collected/verified/verified.json', allowEmptyArchive: true
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user