diff --git a/Jenkinsfile b/Jenkinsfile index 7fa471c..b09fce0 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -36,12 +36,10 @@ pipeline { triggers { // every fifteen minutes (perhaps at :07, :22, :37, :52) // cron('H/15 * * * *') -// once a day on the 1st and 15th of every month -// cron ('H H 1,15 * *') // 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}" DEPLOY_ROOT_FOLDER ="${agent_root_folder}/ansible-repos/ansible-playbooks/d4science-ghn-cluster/CD" @@ -51,10 +49,10 @@ pipeline { TRIGGER_VERSION= "${params.TRIGGER_VERSION}" TRIGGER_HOST="${params.TRIGGER_HOST}" TRIGGER_CD="${params.TRIGGER_CD}" - // maybe here define another param used to identify the target host. In this way the developer can change it from the job } + stages { - stage('initialize environment') { + stage('Initialize environment') { steps { sh ''' date=`date`; @@ -91,7 +89,7 @@ pipeline { cleanup(DEPLOY_FILE,BACKUP_FILE); } } - stage('Nothing to do by System ') { + stage('Nothing to do ') { when{ allOf{ triggeredBy 'TimerTrigger' @@ -102,7 +100,7 @@ pipeline { echo 'Do Nothing: cron build disabled' } } - stage('Add new pending deploy ') { + stage('New pending deploy ') { when{ environment name: 'IS_CRON', value: 'True' anyOf{ @@ -158,7 +156,7 @@ pipeline { always { script { sh ''' - echo ' jobs currently appended:' + echo 'Sending report' ''' //cat ./${ACTION_DEPLOY_FILE}.csv } @@ -168,14 +166,14 @@ pipeline { emailext attachLog: true,//attachmentsPattern: "**/${ACTION_DEPLOY_FILE}.csv", to: 'roberto.cirillo@isti.cnr.it', - subject: "Deploy report", + subject: "[Jenkins-gCubeDeployer] 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", + subject: "[Jenkins-gCubeDeployer] deploy ${currentBuild.fullDisplayName} failed", body: "Something is wrong with ${env.BUILD_URL}" } @@ -205,27 +203,7 @@ def estractComponentsFromCSV(def deployList) { return components } -//Alternative way to append a text in a small file (not used) -def appendToFile(String fileName, String line) { - def current = "" - if (fileExists(fileName)) { - current = readFile fileName - } - writeFile file: fileName, text: current + "\n" + line -} - -/** - * Appends the footer to the deploy file. - */ -def appendFooter( def File) { - def now = new Date() - sh(""" - echo "#---" >> $File - echo "#generated by the gCubeDeploy pipeline >> $File - echo "#last update $now*" >> $File - """) -} - +//launch ansible deploy def deploy(String service, String version, String host){ def now = new Date(); println("Going to deploy the service "+service+" with version: "+version+" on target: "+host); @@ -245,7 +223,7 @@ def checkup(String service, String version, String host){ esac """) } - +//clean and update the local deploy file def cleanup(def DEPLOY_FILE, def BACKUP_FILE){ sh ''' echo "cleanup $DEPLOY_FILE";