generated from gCubeCI/Pipeline-Docker-Template
81 lines
2.4 KiB
Groovy
81 lines
2.4 KiB
Groovy
pipeline {
|
|
agent {
|
|
label 'CD'
|
|
}
|
|
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')
|
|
|
|
environment {
|
|
AGENT_ROOT_FOLDER = "${agent_root_folder}"
|
|
AGENT_DEPLOY_FILE = "${agent_deploy_file}"
|
|
}
|
|
stages {
|
|
stage('initialize environment') {
|
|
steps {
|
|
sh '''
|
|
date=`date`
|
|
echo "#Build ${PIPELINE_BUILD_NUMBER},,"
|
|
'''
|
|
}
|
|
}
|
|
stage('Deploy from system') {
|
|
when{
|
|
allOf{
|
|
triggeredBy 'TimeTrigger'
|
|
environment name: 'IS_CRON', value: 'True'
|
|
}
|
|
}
|
|
steps {
|
|
echo 'Deploy from system properly triggered'
|
|
}
|
|
}
|
|
stage('Add new pending deploy ') {
|
|
when{
|
|
environment name: 'IS_CRON', value: 'True'
|
|
}
|
|
steps {
|
|
echo 'New deploy of ${job} appended to the deploy file'
|
|
}
|
|
}
|
|
stage('Deploy from job ') {
|
|
when{
|
|
environment name: 'IS_CRON', value: 'False'
|
|
}
|
|
steps {
|
|
echo 'New deploy of ${job} appended to the deploy file'
|
|
}
|
|
}
|
|
|
|
}
|
|
post {
|
|
always {
|
|
script {
|
|
sh '''
|
|
echo ' jobs currently appended:'
|
|
'''
|
|
//cat ./${ACTION_DEPLOY_FILE}.csv
|
|
}
|
|
}
|
|
success {
|
|
echo 'The deploy pipeline worked!'
|
|
|
|
emailext attachLog: true,//attachmentsPattern: "**/${ACTION_DEPLOY_FILE}.csv",
|
|
to: 'roberto.cirillo@isti.cnr.it',
|
|
subject: "Deploy report",
|
|
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}"
|
|
}
|
|
|
|
}
|
|
}
|
|
|