diff --git a/Jenkinsfile b/Jenkinsfile index 883cf85..e448d11 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -71,6 +71,8 @@ pipeline { TRIGGER_HOST="${params.TRIGGER_HOST}" // enable the ContinuousDeployment if TRUE TRIGGER_CD="${params.TRIGGER_CD}" + // generic parameter that can be passed to the ansible job + TRIGGER_FOO="${params.TRIGGER_FOO}" // Useful to identify the remote YAML file GCUBE_RELEASE_NUMBER = "${params.gCube_release_version}" //Category name of the components candidates to the remote deployment @@ -100,6 +102,9 @@ pipeline { booleanParam(name: 'TRIGGER_CD', defaultValue: true, description: 'Set to false to avoid current deploy') + string(name: 'TRIGGER_FOO', + defaultValue: '', + description: 'Additional parameter to pass to the ansible job. Leave blank if not used') string(name: 'gCube_release_version', defaultValue: '', description: 'The number of the current gCube release. Leave blank if executed outside gCube release.') @@ -200,7 +205,7 @@ pipeline { 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}"); + deploy("${params.TRIGGER_JOB}", "${params.TRIGGER_VERSION}", "${params.TRIGGER_HOST}", "${params.TRIGGER_FOO}"); } } } @@ -240,7 +245,7 @@ pipeline { 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" catchError(buildResult: 'FAILURE', stageResult: 'FAILURE') { - deploy("${params.TRIGGER_JOB}", "${params.TRIGGER_VERSION}", "${params.TRIGGER_HOST}"); + deploy("${params.TRIGGER_JOB}", "${params.TRIGGER_VERSION}", "${params.TRIGGER_HOST}", "${params.TRIGGER_FOO}"); } } } @@ -337,10 +342,10 @@ def deployJobs(def serviceList){ } //Run ansible deploy -def deploy(String service, String version, String host){ +def deploy(String service, String version, String host, String foo){ 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}/CD;./deployService.sh $service $version $host;", returnStdout: true); + println("Going to deploy the service "+service+" with version: "+version+" on target: "+host+" with argument: "+foo); + def statusCode = sh( script: "cd ${ANSIBLE_ROOT_FOLDER}/CD;./deployService.sh $service $version $host $foo;", returnStdout: true); sh(""" echo " last exit code \$?"; """) diff --git a/README.html b/README.html new file mode 100644 index 0000000..1889eb4 --- /dev/null +++ b/README.html @@ -0,0 +1,403 @@ + + + + + README.md - Grip + + + + + + +
+
+
+
+
+
+
+
+ + + +
+ +
+
+

+ README.md +

+
+
+ +
+
+

Pipeline-gCubeDeployer

+

Jenkins Pipeline script to manage one or more gCube components deployment

+

Requirements

+ +

Expected usage

+
    +
  • ContinuousDeployment(CD): configured as post step build on jenkinsjob
  • +
  • Scheduled by system: In this case all the pending deployments (CD) will be managed by a temporized trigger
  • +
  • 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

+ +

Examples

+
    +
  • When configured as post step build on jenkinsjob, there are some variables to pass as triggered parameters. All the values are dinamically set as shown below:
  • +
+

[[images/gCubeDeployer-JenkinsJob.png]]

+
    +
  • The pipeline can run manually. This option is conceived for debug purpose:
  • +
+

[[images/gCubeDeployer-manualRun.png]]

+
    +
  • Follows a stage view example when the pipeline was scheduled by system, but there were any action to do:
  • +
+

[[images/gCubeDeployer-stageview.png]]

+

Flow Chart

+

[[images/FlowChartgCubeDeployer.jpeg]]

+

License

+

This project is licensed under the EUPL V.1.1 License.

+ +
+
+
+ + + +
+
+
+
+
+
+
+
+ + \ No newline at end of file