-
Notifications
You must be signed in to change notification settings - Fork 160
Expand file tree
/
Copy pathJenkinsfile
More file actions
58 lines (54 loc) · 1.79 KB
/
Copy pathJenkinsfile
File metadata and controls
58 lines (54 loc) · 1.79 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
pipeline {
agent any
options {
disableConcurrentBuilds()
timestamps()
}
parameters {
choice(name: 'ACTION', choices: ['verify', 'deploy', 'rollback'], description: 'Pipeline action')
choice(name: 'TARGET_ENVIRONMENT', choices: ['staging', 'production'], description: 'Deployment target')
}
stages {
stage('Quality gate') {
steps {
sh '''#!/usr/bin/env bash
set -euo pipefail
rustup component add rustfmt clippy
cargo fmt --all --check
cargo build --locked
cargo test --locked
cargo clippy --all-features --locked -- -D warnings
cargo test --test cli_smoke --locked
'''
}
}
stage('Deploy or rollback') {
when { expression { params.ACTION != 'verify' } }
steps {
script {
if (params.TARGET_ENVIRONMENT == 'production') {
input message: 'Approve production ' + params.ACTION + '?', ok: 'Approve'
}
}
withCredentials([
string(credentialsId: 'starforge-deploy-command', variable: 'STARFORGE_DEPLOY_COMMAND'),
string(credentialsId: 'starforge-rollback-command', variable: 'STARFORGE_ROLLBACK_COMMAND'),
string(credentialsId: 'starforge-healthcheck-url', variable: 'STARFORGE_HEALTHCHECK_URL')
]) {
sh '''#!/usr/bin/env bash
set -euo pipefail
export STARFORGE_DEPLOY_ENVIRONMENT="$TARGET_ENVIRONMENT"
if [ "$TARGET_ENVIRONMENT" = production ]; then
export STARFORGE_DEPLOY_APPROVED=true STARFORGE_ROLLBACK_APPROVED=true
fi
if [ "$ACTION" = deploy ]; then
bash scripts/ci-deploy.sh
else
bash scripts/ci-rollback.sh
fi
'''
}
}
}
}
}