generated from gCubeCI/Pipeline-Docker-Template
add env variables for new input params
This commit is contained in:
parent
ddfa536c69
commit
5b34d2b1a8
|
@ -12,7 +12,7 @@ def agent_root_folder = '/var/lib/jenkins'
|
||||||
|
|
||||||
// load the build report's content if present
|
// load the build report's content if present
|
||||||
def text
|
def text
|
||||||
String reportURL = "https://code-repo.d4science.org/gCubeCI/gCubeReleases/raw/branch/master/closed/${gCube_release_version}/build_commits.${report_number}.csv"
|
String reportURL = "https://code-repo.d4science.org/gCubeCI/gCubeReleases/raw/branch/master/open/${gCube_release_version}/build_commits.${report_number}.csv"
|
||||||
if (reportURL){
|
if (reportURL){
|
||||||
println "Pulling the report from Git at ${reportURL}"
|
println "Pulling the report from Git at ${reportURL}"
|
||||||
text = reportURL.toURL().getText()
|
text = reportURL.toURL().getText()
|
||||||
|
@ -21,7 +21,7 @@ if (reportURL){
|
||||||
assert 0 < components.size(): "No component found in build_commits.${report_number}.csv"
|
assert 0 < components.size(): "No component found in build_commits.${report_number}.csv"
|
||||||
for (component in components) {
|
for (component in components) {
|
||||||
// here we need to filter on keywords matching component's section
|
// here we need to filter on keywords matching component's section
|
||||||
println "$component"
|
println " $component"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -64,6 +64,9 @@ 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}"
|
||||||
|
GCUBE_RELEASE_NUMBER = "${params.gCube_release_version}"
|
||||||
|
REPORT_NUMBER = "${params.report_number}"
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
parameters {
|
parameters {
|
||||||
|
@ -106,18 +109,26 @@ pipeline {
|
||||||
}
|
}
|
||||||
stage('Deploy from system') {
|
stage('Deploy from system') {
|
||||||
when{
|
when{
|
||||||
allOf{
|
anyOf{
|
||||||
triggeredBy 'TimerTrigger'
|
allOf{
|
||||||
// maybe we can add a new condition in order to consider the manual execution of this pipeline
|
triggeredBy 'TimerTrigger'
|
||||||
environment name: 'IS_SCHEDULED', value: 'True'
|
// maybe we can add a new condition in order to consider the manual execution of this pipeline
|
||||||
}
|
environment name: 'IS_SCHEDULED', value: 'True'
|
||||||
|
}
|
||||||
|
// in this case the pipeline is triggered by the gCubeBuilder pipeline
|
||||||
|
equals(actual: $TRIGGER_JOB, expected: 'gCubeBuilder')
|
||||||
|
}
|
||||||
}
|
}
|
||||||
steps {
|
steps {
|
||||||
echo 'Cron build enabled. Deploy from system ongoing'
|
echo 'Cron build enabled. Deploy from system ongoing'
|
||||||
script {
|
script {
|
||||||
def deployFolder="CD-${env.BUILD_NUMBER}";
|
echo "pipeline triggered by $TRIGGER_JOB"
|
||||||
deployPendingJobs(deployFolder);
|
if("$TRIGGER_JOB" == "gCubeBuilder"){
|
||||||
|
// do something
|
||||||
|
}else{
|
||||||
|
def deployFolder="CD-${env.BUILD_NUMBER}";
|
||||||
|
deployPendingJobs(deployFolder);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -253,7 +264,6 @@ def checkup(String service, String version, String host){
|
||||||
""")
|
""")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
//parse all csv files found in the local folder and deploy the components defined inside
|
//parse all csv files found in the local folder and deploy the components defined inside
|
||||||
def deployPendingJobs( def deployFolder){
|
def deployPendingJobs( def deployFolder){
|
||||||
println ("searching files in folder ${deployFolder}");
|
println ("searching files in folder ${deployFolder}");
|
||||||
|
@ -286,3 +296,43 @@ def deployPendingJobs( def deployFolder){
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
//parse all csv files found in the local folder and deploy the components defined inside
|
||||||
|
def parsePendingJobs( def deployFolder){
|
||||||
|
println ("searching files in folder ${deployFolder}");
|
||||||
|
def files = findFiles(glob: "${deployFolder}/*.csv")
|
||||||
|
if (files == null){
|
||||||
|
println ("Nothing to do");
|
||||||
|
}else{
|
||||||
|
def serviceList = []
|
||||||
|
for (def file : files){
|
||||||
|
def records = readCSV file: "${file.path}"
|
||||||
|
for (def record : records) {
|
||||||
|
println("Processing record: "+record)
|
||||||
|
serviceList += "$record.get(0),$record.get(1),$record.get(2)";
|
||||||
|
deployJobs(serviceList.unique())
|
||||||
|
}
|
||||||
|
sh "rm ${file.path}"
|
||||||
|
}
|
||||||
|
sh "rm -Rf ${deployFolder}"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
//Deploy jobs from an input list with the following elements: serviceName,serviceVersion,targetHost.
|
||||||
|
def deployJobs(def serviceList){
|
||||||
|
for (def record : serviceList) {
|
||||||
|
println("Processing record: "+record)
|
||||||
|
service=record.split(",");
|
||||||
|
stage(service.get(0)){
|
||||||
|
println "Deploy on going of component: ${service.get(0)}"
|
||||||
|
catchError(buildResult: 'UNSTABLE', stageResult: 'UNSTABLE') {
|
||||||
|
checkup(service.get(0), service.get(1), service.get(2));
|
||||||
|
deploy(service.get(0), service.get(1), service.get(2));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue