add input parameters in order to launch the pipeline manually; add new stage dedicated to the manually execution

This commit is contained in:
Roberto Cirillo 2022-06-21 15:47:38 +02:00
parent 3028ffc459
commit 4f2aeb5920
1 changed files with 45 additions and 2 deletions

47
Jenkinsfile vendored
View File

@ -25,6 +25,15 @@ if (params.deployFile) {
} }
backupList = agent_root_folder+'/'+agent_deploy_backup_filename; backupList = agent_root_folder+'/'+agent_deploy_backup_filename;
//locate the targetHost file
//String targetHostURL = "https://code-repo.d4science.org/gCubeCI/gCubeDeployer/raw/branch/master/open/gcube-${gCube_release_version}.yaml"
//if (verbose)
// println "Querying ${targetHostURL}"
//load the release file
//def text = targetHostURL.toURL().getText()
pipeline { pipeline {
agent { agent {
label 'CD' label 'CD'
@ -50,7 +59,23 @@ pipeline {
TRIGGER_HOST="${params.TRIGGER_HOST}" TRIGGER_HOST="${params.TRIGGER_HOST}"
TRIGGER_CD="${params.TRIGGER_CD}" TRIGGER_CD="${params.TRIGGER_CD}"
} }
parameters {
string(name: 'TRIGGER_JOB',
defaultValue: '',
description: 'Name of the service or job to deploy')
string(name: 'TRIGGER_VERSION',
defaultValue: '',
description: 'service version to deploy')
string(name: 'TRIGGER_HOST',
defaultValue: '',
description: 'Target Host / Host group where deploy the service')
booleanParam(name: 'TRIGGER_CD',
defaultValue: true,
description: 'Set to false to avoid current deploy')
}
stages { stages {
stage('Initialize environment') { stage('Initialize environment') {
steps { steps {
@ -71,7 +96,7 @@ pipeline {
echo 'Cron build enabled. Deploy from system ongoing' echo 'Cron build enabled. Deploy from system ongoing'
script { script {
// parse the report and extract the data // parse the report and extract the data
def components = gettComponentsFromCSV(deployList) def components = getComponentsFromCSV(deployList)
if (components.size() > 0) { if (components.size() > 0) {
for (component in components) { for (component in components) {
stage(component){ stage(component){
@ -147,6 +172,24 @@ pipeline {
} }
} }
stage('Deploy manually ') {
when{
allOf{
environment name: 'IS_CRON', value: 'False';
triggeredBy 'UserIdCause'
}
}
steps {
echo "Cron build disabled. Pipeline executed Manually. New deploy of ${params.TRIGGER_JOB} - ${params.TRIGGER_VERSION} ongoing"
ansiColor("xterm") {
catchError(buildResult: 'FAILURE', stageResult: 'FAILURE') {
checkup("${params.TRIGGER_JOB}", "${params.TRIGGER_VERSION}", "${params.TRIGGER_HOST}");
deploy("${params.TRIGGER_JOB}", "${params.TRIGGER_VERSION}", "${params.TRIGGER_HOST}");
}
}
}
}
} }
post { post {
always { always {