generated from gCubeCI/Pipeline-Docker-Template
Merge branch 'master' of https://code-repo.d4science.org/gCubeCI/gCubeDeployer.git
This commit is contained in:
commit
c6cccec47d
|
@ -75,7 +75,7 @@ pipeline {
|
|||
//Category name of the components candidates to the remote deployment
|
||||
DEPLOY_CATEGORY="${env.DEPLOY_CATEGORY}"
|
||||
//Job name of the release pipeline
|
||||
RELEASE_JOB='gCubeBuilder'
|
||||
RELEASE_JOB='Pipeline-gCubeBuilder'
|
||||
//URL to the YAML file. Used alternatively to RELEASE_JOB
|
||||
RELEASE_URL= "${params.RELEASE_URL}"
|
||||
// username of ReleaseManager. Used for limiting the preproduction deployments
|
||||
|
@ -99,10 +99,7 @@ pipeline {
|
|||
description: 'Set to false to avoid current deploy')
|
||||
string(name: 'gCube_release_version',
|
||||
defaultValue: '',
|
||||
description: 'The number of the gCube release. Leave blank if executed outside gCube release.')
|
||||
string(name: 'report_number',
|
||||
defaultValue: '',
|
||||
description: 'The build report number on Git to pull the notes. Leave blank if executed outside gCube release.')
|
||||
description: 'The number of the current gCube release. Leave blank if executed outside gCube release.')
|
||||
string(name: 'RELEASE_URL',
|
||||
defaultValue: '',
|
||||
description: 'URL to the yaml file. Leave blank if executed outside gCube release.')
|
||||
|
@ -129,7 +126,7 @@ pipeline {
|
|||
}
|
||||
}
|
||||
steps {
|
||||
echo 'Cron build enabled. Deploy from system ongoing'
|
||||
echo 'Cron build enabled. \033[31;1;4mDeploy from system ongoing\033[0m'
|
||||
script {
|
||||
echo "pipeline was triggered by ${params.TRIGGER_JOB}"
|
||||
println("Going to deploy all the pending deployments")
|
||||
|
@ -141,17 +138,14 @@ pipeline {
|
|||
}
|
||||
stage('Nothing to do ') {
|
||||
when{
|
||||
anyOf{
|
||||
allOf{
|
||||
triggeredBy 'TimerTrigger'
|
||||
environment name: 'IS_SCHEDULED', value: 'False'
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
steps {
|
||||
echo 'Going to sleep'
|
||||
sh ' exit 1; '
|
||||
echo '\033[31;1;4mGoing to sleep\033[0m'
|
||||
sh ' exit 0; '
|
||||
}
|
||||
}
|
||||
stage('New pending deploy ') {
|
||||
|
@ -166,7 +160,8 @@ pipeline {
|
|||
}
|
||||
steps {
|
||||
sh '''
|
||||
echo "Cron build enabled. New deploy of ${TRIGGER_JOB} - ${TRIGGER_VERSION} will be added to the pending deploy file"
|
||||
echo '\033[31;1;4mNew pending deploy added to the queue/033[0m'
|
||||
echo "Cron build enabled. Adding ${TRIGGER_JOB} - ${TRIGGER_VERSION} to the queue"
|
||||
touch $DEPLOY_FILE;
|
||||
if grep -q \"\${TRIGGER_JOB}\" \${DEPLOY_FILE}; then
|
||||
echo "component ${TRIGGER_JOB} already added. Nothing to add."
|
||||
|
@ -197,9 +192,10 @@ pipeline {
|
|||
}
|
||||
steps {
|
||||
script{
|
||||
echo "Cron build disabled. New deploy of ${params.TRIGGER_JOB} - ${params.TRIGGER_VERSION} ongoing"
|
||||
ansiColor("xterm") {
|
||||
catchError(buildResult: 'SUCCESS', stageResult: 'FAILURE') {
|
||||
echo '\033[31;1;4mNew upstream deploy ongoing\033[0m'
|
||||
echo "Cron build disabled. Component: ${params.TRIGGER_JOB} - ${params.TRIGGER_VERSION}"
|
||||
ansiColor('xterm') {
|
||||
catchError(buildResult: 'UNSTABLE', stageResult: 'FAILURE') {
|
||||
checkup("${params.TRIGGER_JOB}", "${params.TRIGGER_VERSION}", "${params.TRIGGER_HOST}");
|
||||
deploy("${params.TRIGGER_JOB}", "${params.TRIGGER_VERSION}", "${params.TRIGGER_HOST}");
|
||||
}
|
||||
|
@ -238,14 +234,12 @@ pipeline {
|
|||
expression { params.TRIGGER_JOB != "${RELEASE_JOB}" }
|
||||
}
|
||||
steps {
|
||||
echo '\033[31;1;4mNew deploy ongoing manually triggered\033[0m'
|
||||
echo "Cron build disabled. Pipeline executed Manually. New deploy of ${params.TRIGGER_JOB} - ${params.TRIGGER_VERSION} ongoing"
|
||||
ansiColor("xterm") {
|
||||
catchError(buildResult: 'FAILURE', stageResult: 'FAILURE') {
|
||||
deploy("${params.TRIGGER_JOB}", "${params.TRIGGER_VERSION}", "${params.TRIGGER_HOST}");
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
post {
|
||||
|
@ -278,7 +272,7 @@ pipeline {
|
|||
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);
|
||||
def statusCode = sh( script: "cd $ANSIBLE_ROOT_FOLDER;git pull;./deployService.sh $service $version $host;", returnStdout: true);
|
||||
def statusCode = sh( script: "cd $ANSIBLE_ROOT_FOLDER;./deployService.sh $service $version $host;", returnStdout: true);
|
||||
sh("""
|
||||
echo " last exit code \$?";
|
||||
""")
|
||||
|
|
|
@ -17,6 +17,11 @@ Jenkins Pipeline script to manage one or more gCube components deployment
|
|||
* Manually from Jenkins GUI
|
||||
|
||||
## Expected environment variables
|
||||
The variables below must be specified as environment variables on the agent where the deployments will be executed:
|
||||
* IS_SCHEDULED (True | False): if true all the deployment requests will be performed periodically as specified by cron
|
||||
* ENVIRONMENT: ( DEV | PREPROD | PROD) Indicates the target environment where will be deployed all the artifacts
|
||||
* DEPLOY_CATEGORY: (Related to release build) one or more Component group on yaml file where search the components to deploy
|
||||
* CD: (Continuous Deployment: True | False) if True the remote deploy will be performed
|
||||
|
||||
## References
|
||||
* [Jenkins Pipeline](https://jenkins.io/doc/book/pipeline/)
|
||||
|
|
Binary file not shown.
Before Width: | Height: | Size: 58 KiB |
Loading…
Reference in New Issue