Created
September 27, 2018 12:46
-
-
Save ciiqr/663f1049469f75a571b9e8f769d35bb2 to your computer and use it in GitHub Desktop.
Outline of a jenkins file that includes an automated deploy step with manual approval
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
pipeline { | |
agent any | |
stages { | |
stage('Build') { | |
steps { | |
echo 'Build' | |
} | |
post { | |
always { | |
echo 'Build Cleanup' | |
} | |
success { | |
slackSend color: 'good', message: ":heavy_check_mark: <${RUN_DISPLAY_URL}|${BRANCH_NAME}> - Build success" | |
} | |
aborted { | |
slackSend color: 'warning', message: ":x: <${RUN_DISPLAY_URL}|${BRANCH_NAME}> - Build aborted" | |
} | |
failure { | |
slackSend color: 'danger', message: ":x: <${RUN_DISPLAY_URL}|${BRANCH_NAME}> - Build failure" | |
} | |
} | |
} | |
stage('Test') { | |
parallel { | |
stage('Static analysis') { | |
steps { | |
echo 'Static Analysis Test' | |
} | |
} | |
stage('Unit') { | |
steps { | |
echo 'Unit Test' | |
} | |
} | |
stage('Integration') { | |
steps { | |
echo 'Integration Test' | |
} | |
} | |
stage('Performance') { | |
steps { | |
echo 'Performance Test' | |
} | |
} | |
stage('Smoke') { | |
steps { | |
echo 'Smoke Test' | |
} | |
} | |
} | |
post { | |
always { | |
echo 'Test Cleanup' | |
} | |
success { | |
slackSend color: 'good', message: ":heavy_check_mark: <${RUN_DISPLAY_URL}|${BRANCH_NAME}> - Tests success" | |
} | |
aborted { | |
slackSend color: 'warning', message: ":x: <${RUN_DISPLAY_URL}|${BRANCH_NAME}> - Tests aborted" | |
} | |
failure { | |
slackSend color: 'danger', message: ":x: <${RUN_DISPLAY_URL}|${BRANCH_NAME}> - Tests failure" | |
} | |
} | |
} | |
stage('Deploy') { | |
parallel { | |
stage('Staging') { | |
when { branch 'rel_.*' } | |
input { | |
message "Should we deploy to staging?" | |
ok "Deploy" | |
} | |
steps { | |
// TODO: get ref link from scm: def repositoryUrl = scm.userRemoteConfigs[0].url | |
slackSend "Deploying <https://github.com/ciiqr/test/commit/some_ref|${BRANCH_NAME}> to Staging" | |
sh './scripts/deploy.sh staging' // TODO: might want to instead trigger different jobs to do the actual deploys/confirms... ¯\_(ツ)_/¯ | |
} | |
} | |
stage('Sandbox') { | |
when { branch 'master|rel_.*' } | |
input { | |
message "Should we deploy to sandbox?" | |
ok "Deploy" | |
} | |
steps { | |
slackSend "Deploying <https://github.com/ciiqr/test/commit/some_ref|${BRANCH_NAME}> to Sandbox" | |
sh './scripts/deploy.sh sandbox' | |
} | |
} | |
stage('Production') { | |
when { branch 'master' } | |
input { | |
message "Should we deploy to production?" | |
ok "Deploy" | |
} | |
steps { | |
slackSend "Deploying <https://github.com/ciiqr/test/commit/some_ref|${BRANCH_NAME}> to Production" | |
sh './scripts/deploy.sh production' | |
} | |
} | |
} | |
} | |
} | |
post { | |
cleanup { | |
cleanWs() | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment