2022-04-15 14:41:39 +02:00
|
|
|
pipeline {
|
|
|
|
agent {
|
|
|
|
label 'CD'
|
|
|
|
}
|
2022-04-15 15:23:26 +02:00
|
|
|
triggers {
|
|
|
|
cron "*/10 * * * *"
|
|
|
|
}
|
|
|
|
//once in every two hours slot between 9 AM and 5 PM every weekday (perhaps at 10:38 AM, 12:38 PM, 2:38 PM, 4:38 PM)
|
|
|
|
// cron('H H(9-16)/2 * * 1-5')
|
2022-04-15 14:41:39 +02:00
|
|
|
|
|
|
|
environment {
|
|
|
|
AGENT_ROOT_FOLDER = "${agent_root_folder}"
|
|
|
|
AGENT_DEPLOY_FILE = "${agent_deploy_file}"
|
|
|
|
}
|
|
|
|
stages {
|
|
|
|
stage('initialize environment') {
|
|
|
|
steps {
|
|
|
|
sh '''
|
|
|
|
date=`date`
|
2022-04-15 14:59:34 +02:00
|
|
|
echo "#Build ${PIPELINE_BUILD_NUMBER},,"
|
2022-04-15 14:41:39 +02:00
|
|
|
'''
|
|
|
|
}
|
|
|
|
}
|
2022-04-15 15:06:25 +02:00
|
|
|
stage('Deploy from system') {
|
2022-04-15 14:41:39 +02:00
|
|
|
when{
|
|
|
|
allOf{
|
|
|
|
triggeredBy 'TimeTrigger'
|
|
|
|
environment name: 'IS_CRON', value: 'True'
|
|
|
|
}
|
|
|
|
}
|
|
|
|
steps {
|
|
|
|
echo 'Deploy from system properly triggered'
|
|
|
|
}
|
|
|
|
}
|
2022-04-15 15:06:25 +02:00
|
|
|
stage('Add new pending deploy ') {
|
2022-04-15 14:41:39 +02:00
|
|
|
when{
|
|
|
|
environment name: 'IS_CRON', value: 'True'
|
|
|
|
}
|
|
|
|
steps {
|
|
|
|
echo 'New deploy of ${job} appended to the deploy file'
|
|
|
|
}
|
|
|
|
}
|
2022-04-15 15:06:25 +02:00
|
|
|
stage('Deploy from job ') {
|
|
|
|
when{
|
|
|
|
environment name: 'IS_CRON', value: 'False'
|
|
|
|
}
|
|
|
|
steps {
|
|
|
|
echo 'New deploy of ${job} appended to the deploy file'
|
|
|
|
}
|
|
|
|
}
|
2022-04-15 14:41:39 +02:00
|
|
|
|
|
|
|
}
|
|
|
|
post {
|
|
|
|
always {
|
|
|
|
script {
|
|
|
|
sh '''
|
|
|
|
echo ' jobs currently appended:'
|
|
|
|
'''
|
2022-04-15 15:06:25 +02:00
|
|
|
//cat ./${ACTION_DEPLOY_FILE}.csv
|
2022-04-15 14:41:39 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
success {
|
|
|
|
echo 'The deploy pipeline worked!'
|
|
|
|
|
2022-04-15 15:25:26 +02:00
|
|
|
emailext //attachmentsPattern: "**/${ACTION_DEPLOY_FILE}.csv",
|
2022-04-15 14:41:39 +02:00
|
|
|
to: 'roberto.cirillo@isti.cnr.it',
|
|
|
|
subject: "Deploy report (build #${PIPELINE_BUILD_NUMBER})",
|
|
|
|
body: "${currentBuild.fullDisplayName}. Build time: ${currentBuild.durationString}. See ${env.BUILD_URL}. "
|
|
|
|
}
|
|
|
|
failure {
|
|
|
|
echo 'The deploy pipeline has failed'
|
|
|
|
emailext attachLog: true,
|
|
|
|
to: 'roberto.cirillo@isti.cnr.it',
|
|
|
|
subject: "[Jenkins deploy D4S] deploy ${currentBuild.fullDisplayName} failed",
|
|
|
|
body: "Something is wrong with ${env.BUILD_URL}"
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|