42 lines
1.7 KiB
Plaintext
42 lines
1.7 KiB
Plaintext
pipeline {
|
|||
|
|
agent { label 'assignment8-trusted' }
|
||
|
|
options { disableConcurrentBuilds(); timeout(time: 20, unit: 'MINUTES'); timestamps() }
|
||
|
|
stages {
|
||
|
|
stage('Prepare staging-only failure') {
|
||
|
|
steps {
|
||
|
|
deleteDir()
|
||
|
|
git url: 'https://myfileagent.tech/myfileagent/myfileagent-pipeline.git', branch: 'assignment8/staging-failure-exercise'
|
||
|
|
sh '''set -eu
|
||
|
|
test "$(git rev-parse HEAD)" = c0cdd9159b430b8a27543a293cdd23aa05c8ee34
|
||
|
|
mkdir -p reports
|
||
|
|
cat > reports/staging.yml <<'EOF'
|
||
|
|
target_env: staging
|
||
|
|
release_image: myfileagent.tech/myfileagent/pricing@sha256:2ab86894ada4c12bd066ae1d29be40a296b1a037f379c494dead5cad4d8b88f9
|
||
|
|
expected_version: v2
|
||
|
|
expected_commit: ee128d18bddd1763b916b40f05829f2e769f0654
|
||
|
|
configuration_commit: c0cdd9159b430b8a27543a293cdd23aa05c8ee34
|
||
|
|
expected_total: 36
|
||
|
|
public_url: https://staging.myfileagent.tech
|
||
|
|
proxy_network: myfileagent-gitea_gitea-private
|
||
|
|
EOF
|
||
|
|
date -u +%FT%TZ > reports/failure-start.txt
|
||
|
|
'''
|
||
|
|
}
|
||
|
|
}
|
||
|
|
stage('Deploy deliberate mismatch') {
|
||
|
|
steps {
|
||
|
|
withCredentials([sshUserPrivateKey(credentialsId: 'assignment8-deploy-ssh', keyFileVariable: 'DEPLOY_KEY')]) {
|
||
|
|
sh '''#!/bin/sh
|
||
|
|
set +x
|
||
|
|
set -eu
|
||
|
|
export ANSIBLE_SSH_ARGS="-o StrictHostKeyChecking=yes -o UserKnownHostsFile=$WORKSPACE/secure-delivery/ansible/known_hosts"
|
||
|
|
ansible-playbook -i secure-delivery/ansible/inventory.ini secure-delivery/ansible/deploy.yml --private-key "$DEPLOY_KEY" -e @reports/staging.yml > reports/failure-ansible.txt 2>&1
|
||
|
|
'''
|
||
|
|
}
|
||
|
|
}
|
||
|
|
}
|
||
|
|
stage('Must not run after failure') { steps { error('Unexpected success: the staging failure did not block the pipeline') } }
|
||
|
|
}
|
||
|
|
post { always { archiveArtifacts artifacts: 'reports/*', allowEmptyArchive: true } }
|
||
|
|
}
|