Feature/issue 24 delivery #27
Vendored
+44
-1
@@ -128,7 +128,50 @@ jenkins_build: ${env.BUILD_URL}
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// 6.4.6 (samahk13): Ansible staging deploy + smoke tests - added next.
|
// 6.4.6: deploy the digest just published to staging with Ansible,
|
||||||
|
// then rerun unchanged and require changed=0 (idempotence).
|
||||||
|
stage('Deploy staging') {
|
||||||
|
steps {
|
||||||
|
script {
|
||||||
|
// Expected behaviour comes from the source, not from config.
|
||||||
|
def version = sh(script: "sed -n 's/^VERSION = \"\\(.*\\)\"/\\1/p' pricing/app.py", returnStdout: true).trim()
|
||||||
|
def unit = sh(script: "sed -n 's/^UNIT_PRICE = //p' pricing/app.py", returnStdout: true).trim()
|
||||||
|
env.APP_VERSION = version
|
||||||
|
writeFile file: "release-${version}-staging.yml", text: """target_env: staging
|
||||||
|
release_image: ${env.IMAGE_DIGEST}
|
||||||
|
expected_version: ${version}
|
||||||
|
expected_commit: ${env.APP_COMMIT}
|
||||||
|
expected_total: ${3 * (unit as Integer)}
|
||||||
|
public_url: https://staging.ssw590-08.me
|
||||||
|
proxy_network: gitea-net
|
||||||
|
"""
|
||||||
|
}
|
||||||
|
archiveArtifacts artifacts: "release-${env.APP_VERSION}-staging.yml", fingerprint: true
|
||||||
|
withCredentials([sshUserPrivateKey(credentialsId: 'deploy-ssh', keyFileVariable: 'DEPLOY_KEY')]) {
|
||||||
|
sh '''
|
||||||
|
export PATH=/opt/ansible-venv/bin:$PATH
|
||||||
|
ansible-playbook -i ansible/inventory.ini ansible/deploy.yml --syntax-check
|
||||||
|
ansible-playbook -i ansible/inventory.ini ansible/deploy.yml \
|
||||||
|
--private-key "$DEPLOY_KEY" -e @release-$APP_VERSION-staging.yml
|
||||||
|
'''
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
stage('Staging idempotence') {
|
||||||
|
steps {
|
||||||
|
withCredentials([sshUserPrivateKey(credentialsId: 'deploy-ssh', keyFileVariable: 'DEPLOY_KEY')]) {
|
||||||
|
sh '''
|
||||||
|
export PATH=/opt/ansible-venv/bin:$PATH
|
||||||
|
ansible-playbook -i ansible/inventory.ini ansible/deploy.yml \
|
||||||
|
--private-key "$DEPLOY_KEY" -e @release-$APP_VERSION-staging.yml | tee rerun.log
|
||||||
|
grep -E 'startup +: .*changed=0 +unreachable=0 +failed=0' rerun.log \
|
||||||
|
|| { echo "Second run changed something: not idempotent"; exit 1; }
|
||||||
|
'''
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
// 6.4.7 (kholmes): approval + production deploy.
|
// 6.4.7 (kholmes): approval + production deploy.
|
||||||
stage('Approve and deploy production') {
|
stage('Approve and deploy production') {
|
||||||
|
|||||||
Reference in New Issue
Block a user