generated from gCubeCI/Pipeline-Docker-Template
changing stage names and add some comments
This commit is contained in:
parent
2d430bd8cd
commit
a19122069e
|
@ -36,12 +36,10 @@ pipeline {
|
||||||
triggers {
|
triggers {
|
||||||
// every fifteen minutes (perhaps at :07, :22, :37, :52)
|
// every fifteen minutes (perhaps at :07, :22, :37, :52)
|
||||||
// cron('H/15 * * * *')
|
// 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)
|
// 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')
|
cron('H H(9-16)/2 * * 1-5')
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
environment {
|
environment {
|
||||||
AGENT_ROOT_FOLDER = "${agent_root_folder}"
|
AGENT_ROOT_FOLDER = "${agent_root_folder}"
|
||||||
DEPLOY_ROOT_FOLDER ="${agent_root_folder}/ansible-repos/ansible-playbooks/d4science-ghn-cluster/CD"
|
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_VERSION= "${params.TRIGGER_VERSION}"
|
||||||
TRIGGER_HOST="${params.TRIGGER_HOST}"
|
TRIGGER_HOST="${params.TRIGGER_HOST}"
|
||||||
TRIGGER_CD="${params.TRIGGER_CD}"
|
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 {
|
stages {
|
||||||
stage('initialize environment') {
|
stage('Initialize environment') {
|
||||||
steps {
|
steps {
|
||||||
sh '''
|
sh '''
|
||||||
date=`date`;
|
date=`date`;
|
||||||
|
@ -91,7 +89,7 @@ pipeline {
|
||||||
cleanup(DEPLOY_FILE,BACKUP_FILE);
|
cleanup(DEPLOY_FILE,BACKUP_FILE);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
stage('Nothing to do by System ') {
|
stage('Nothing to do ') {
|
||||||
when{
|
when{
|
||||||
allOf{
|
allOf{
|
||||||
triggeredBy 'TimerTrigger'
|
triggeredBy 'TimerTrigger'
|
||||||
|
@ -102,7 +100,7 @@ pipeline {
|
||||||
echo 'Do Nothing: cron build disabled'
|
echo 'Do Nothing: cron build disabled'
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
stage('Add new pending deploy ') {
|
stage('New pending deploy ') {
|
||||||
when{
|
when{
|
||||||
environment name: 'IS_CRON', value: 'True'
|
environment name: 'IS_CRON', value: 'True'
|
||||||
anyOf{
|
anyOf{
|
||||||
|
@ -158,7 +156,7 @@ pipeline {
|
||||||
always {
|
always {
|
||||||
script {
|
script {
|
||||||
sh '''
|
sh '''
|
||||||
echo ' jobs currently appended:'
|
echo 'Sending report'
|
||||||
'''
|
'''
|
||||||
//cat ./${ACTION_DEPLOY_FILE}.csv
|
//cat ./${ACTION_DEPLOY_FILE}.csv
|
||||||
}
|
}
|
||||||
|
@ -168,14 +166,14 @@ pipeline {
|
||||||
|
|
||||||
emailext attachLog: true,//attachmentsPattern: "**/${ACTION_DEPLOY_FILE}.csv",
|
emailext attachLog: true,//attachmentsPattern: "**/${ACTION_DEPLOY_FILE}.csv",
|
||||||
to: 'roberto.cirillo@isti.cnr.it',
|
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}. "
|
body: "${currentBuild.fullDisplayName}. Build time: ${currentBuild.durationString}. See ${env.BUILD_URL}. "
|
||||||
}
|
}
|
||||||
failure {
|
failure {
|
||||||
echo 'The deploy pipeline has failed'
|
echo 'The deploy pipeline has failed'
|
||||||
emailext attachLog: true,
|
emailext attachLog: true,
|
||||||
to: 'roberto.cirillo@isti.cnr.it',
|
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}"
|
body: "Something is wrong with ${env.BUILD_URL}"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -205,27 +203,7 @@ def estractComponentsFromCSV(def deployList) {
|
||||||
return components
|
return components
|
||||||
}
|
}
|
||||||
|
|
||||||
//Alternative way to append a text in a small file (not used)
|
//launch ansible deploy
|
||||||
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
|
|
||||||
""")
|
|
||||||
}
|
|
||||||
|
|
||||||
def deploy(String service, String version, String host){
|
def deploy(String service, String version, String host){
|
||||||
def now = new Date();
|
def now = new Date();
|
||||||
println("Going to deploy the service "+service+" with version: "+version+" on target: "+host);
|
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
|
esac
|
||||||
""")
|
""")
|
||||||
}
|
}
|
||||||
|
//clean and update the local deploy file
|
||||||
def cleanup(def DEPLOY_FILE, def BACKUP_FILE){
|
def cleanup(def DEPLOY_FILE, def BACKUP_FILE){
|
||||||
sh '''
|
sh '''
|
||||||
echo "cleanup $DEPLOY_FILE";
|
echo "cleanup $DEPLOY_FILE";
|
||||||
|
|
Loading…
Reference in New Issue