playground-jenkins/Jenkinsfile
2020-07-12 22:11:33 +02:00

70 lines
2.1 KiB
Groovy

@Library('jenkins-shlib')_
pipeline {
agent any
environment {
PROD_TAG = '11_abcdef9'
deployment_name = 'some_random_deployment'
}
stages {
stage('Approve'){
steps {
script {
def userInput
try {
timeout(time: 300, unit: 'SECONDS') {
// https://stackoverflow.com/questions/52093926/jenkins-pipeline-send-email-at-user-input
// https://www.jenkins.io/doc/pipeline/steps/workflow-basic-steps/#mail-mail
// Oder: http://{{jenkins_uri}}/blue/organizations/jenkins/${env.JOB_NAME - ohne /Branch}/detail/${env.BRANCH_NAME}/${env.BUILD_ID}/pipeline/${env.BUILD_ID}
emailext
to: 'devel@zwackl.de',
subject: "[${env.JOB_NAME}] is waiting for your decision",
body: "${env.BUILD_URL}/input/"
userInput = input(
//id: 'approve_deploy_at_prod',
message: "Do you want to deploy version ${PROD_TAG}@${env.deployment_name} in PROD?",
ok: 'Yepp, go on!'/*,
parameters: [
[
$class: 'BooleanParameterDefinition',
defaultValue: true,
description: '',
name: 'Please confirm you agree with this'
]
]*/
)
}
} catch(org.jenkinsci.plugins.workflow.steps.FlowInterruptedException e) {
error "${e.toString()}: this job was either aborted or timed out."
}
/*if (userInput == true) {
// do something
echo "this was successful"
} else {
// do something else
echo "this was not successful"
currentBuild.result = 'FAILURE'
}*/
}
}
}
stage('deploy@PROD'){
steps{
script{
echo "deploy@PROD..."
}
}
}
}
post {
always {
script {
env.RESULT = "${currentBuild.currentResult}"
echo "FINAL RESULT: ${env.RESULT}"
}
}
}
}