Added 12h timeout to all pipelines
Change-Id: I085fcbda322d0877d5ffebd002fc109577788c29
diff --git a/test-salt-models-pipeline.groovy b/test-salt-models-pipeline.groovy
index ca8353e..08c37d7 100644
--- a/test-salt-models-pipeline.groovy
+++ b/test-salt-models-pipeline.groovy
@@ -107,108 +107,109 @@
]
}
-
-node("python") {
- try{
- stage("checkout") {
- if (gerritRef) {
- // job is triggered by Gerrit
- // test if change aren't already merged
- def gerritChange = gerrit.getGerritChange(GERRIT_NAME, GERRIT_HOST, GERRIT_CHANGE_NUMBER, CREDENTIALS_ID, true)
- // test if gerrit change is already Verified
- if(gerrit.patchsetHasApproval(gerritChange.currentPatchSet,"Verified", "+")){
- common.successMsg("Gerrit change ${GERRIT_CHANGE_NUMBER} patchset ${GERRIT_PATCHSET_NUMBER} already has Verified, skipping tests") // do nothing
- // test WIP contains in commit message
- }else if (gerritChange.commitMessage.contains("WIP")) {
- common.successMsg("Commit message contains WIP, skipping tests") // do nothing
- } else {
- def merged = gerritChange.status == "MERGED"
- if(!merged){
- checkouted = gerrit.gerritPatchsetCheckout ([
- credentialsId : CREDENTIALS_ID
- ])
- } else{
- common.successMsg("Change ${GERRIT_CHANGE_NUMBER} is already merged, no need to test them")
- }
- }
- // defaultGitUrl is passed to the triggered job
- defaultGitUrl = "${GERRIT_SCHEME}://${GERRIT_NAME}@${GERRIT_HOST}:${GERRIT_PORT}/${GERRIT_PROJECT}"
- defaultGitRef = GERRIT_REFSPEC
- } else if(defaultGitRef && defaultGitUrl) {
- checkouted = gerrit.gerritPatchsetCheckout(defaultGitUrl, defaultGitRef, "HEAD", CREDENTIALS_ID)
- } else {
- throw new Exception("Cannot checkout gerrit patchset, GERRIT_REFSPEC and DEFAULT_GIT_REF is null")
- }
- }
-
- stage("Check YAML") {
- sh("git diff-tree --no-commit-id --diff-filter=d --name-only -r HEAD | grep .yml | xargs -I {} python -c \"import yaml; yaml.load(open('{}', 'r'))\" \\;")
- }
-
- stage("test-nodes") {
- if(checkouted) {
- def modifiedClusters = null
-
+timeout(time: 12, unit: 'HOURS') {
+ node("python") {
+ try{
+ stage("checkout") {
if (gerritRef) {
- checkChange = sh(script: "git diff-tree --no-commit-id --name-only -r HEAD | grep -v classes/cluster", returnStatus: true)
- if (checkChange == 1) {
- modifiedClusters = sh(script: "git diff-tree --no-commit-id --name-only -r HEAD | grep classes/cluster/ | awk -F/ '{print \$3}' | uniq", returnStdout: true).tokenize()
+ // job is triggered by Gerrit
+ // test if change aren't already merged
+ def gerritChange = gerrit.getGerritChange(GERRIT_NAME, GERRIT_HOST, GERRIT_CHANGE_NUMBER, CREDENTIALS_ID, true)
+ // test if gerrit change is already Verified
+ if(gerrit.patchsetHasApproval(gerritChange.currentPatchSet,"Verified", "+")){
+ common.successMsg("Gerrit change ${GERRIT_CHANGE_NUMBER} patchset ${GERRIT_PATCHSET_NUMBER} already has Verified, skipping tests") // do nothing
+ // test WIP contains in commit message
+ }else if (gerritChange.commitMessage.contains("WIP")) {
+ common.successMsg("Commit message contains WIP, skipping tests") // do nothing
+ } else {
+ def merged = gerritChange.status == "MERGED"
+ if(!merged){
+ checkouted = gerrit.gerritPatchsetCheckout ([
+ credentialsId : CREDENTIALS_ID
+ ])
+ } else{
+ common.successMsg("Change ${GERRIT_CHANGE_NUMBER} is already merged, no need to test them")
+ }
}
- }
-
- def infraYMLs = sh(script: "find ./classes/ -regex '.*cluster/[-_a-zA-Z0-9]*/[infra/]*init\\.yml' -exec grep -il 'cluster_name' {} \\;", returnStdout: true).tokenize()
- def clusterDirectories = sh(script: "ls -d ./classes/cluster/*/ | awk -F/ '{print \$4}'", returnStdout: true).tokenize()
-
- // create a list of cluster names present in cluster folder
- def infraList = []
- for (elt in infraYMLs) {
- infraList << elt.tokenize('/')[3]
- }
-
- // verify we have all valid clusters loaded
- def commonList = infraList.intersect(clusterDirectories)
- def differenceList = infraList.plus(clusterDirectories)
- differenceList.removeAll(commonList)
-
- if(!differenceList.isEmpty()){
- common.warningMsg("The following clusters are not valid : ${differenceList} - That means we cannot found cluster_name in init.yml or infra/init.yml")
- }
- if (modifiedClusters) {
- infraYMLs.removeAll { !modifiedClusters.contains(it.tokenize('/')[3]) }
- common.infoMsg("Testing only modified clusters: ${infraYMLs}")
- }
-
- for (int i = 0; i < infraYMLs.size(); i++) {
- def infraYMLConfig = readYaml(file: infraYMLs[i])
- if(!infraYMLConfig["parameters"].containsKey("_param")){
- common.warningMsg("ERROR: Cannot find soft params (_param) in file " + infraYMLs[i] + " for obtain a cluster info. Skipping test.")
- continue
- }
- def infraParams = infraYMLConfig["parameters"]["_param"];
- if(!infraParams.containsKey("infra_config_hostname") || !infraParams.containsKey("cluster_name") || !infraParams.containsKey("cluster_domain")){
- common.warningMsg("ERROR: Cannot find _param:infra_config_hostname or _param:cluster_name or _param:cluster_domain in file " + infraYMLs[i] + " for obtain a cluster info. Skipping test.")
- continue
- }
- def clusterName = infraParams["cluster_name"]
- def clusterDomain = infraParams["cluster_domain"]
- def configHostname = infraParams["infra_config_hostname"]
- def testTarget = String.format("%s.%s", configHostname, clusterDomain)
-
- futureNodes << [defaultGitUrl, defaultGitRef, clusterName, testTarget, formulasSource]
- }
-
- setupRunner()
-
- if (failedNodes) {
- currentBuild.result = "FAILURE"
+ // defaultGitUrl is passed to the triggered job
+ defaultGitUrl = "${GERRIT_SCHEME}://${GERRIT_NAME}@${GERRIT_HOST}:${GERRIT_PORT}/${GERRIT_PROJECT}"
+ defaultGitRef = GERRIT_REFSPEC
+ } else if(defaultGitRef && defaultGitUrl) {
+ checkouted = gerrit.gerritPatchsetCheckout(defaultGitUrl, defaultGitRef, "HEAD", CREDENTIALS_ID)
+ } else {
+ throw new Exception("Cannot checkout gerrit patchset, GERRIT_REFSPEC and DEFAULT_GIT_REF is null")
}
}
+
+ stage("Check YAML") {
+ sh("git diff-tree --no-commit-id --diff-filter=d --name-only -r HEAD | grep .yml | xargs -I {} python -c \"import yaml; yaml.load(open('{}', 'r'))\" \\;")
+ }
+
+ stage("test-nodes") {
+ if(checkouted) {
+ def modifiedClusters = null
+
+ if (gerritRef) {
+ checkChange = sh(script: "git diff-tree --no-commit-id --name-only -r HEAD | grep -v classes/cluster", returnStatus: true)
+ if (checkChange == 1) {
+ modifiedClusters = sh(script: "git diff-tree --no-commit-id --name-only -r HEAD | grep classes/cluster/ | awk -F/ '{print \$3}' | uniq", returnStdout: true).tokenize()
+ }
+ }
+
+ def infraYMLs = sh(script: "find ./classes/ -regex '.*cluster/[-_a-zA-Z0-9]*/[infra/]*init\\.yml' -exec grep -il 'cluster_name' {} \\;", returnStdout: true).tokenize()
+ def clusterDirectories = sh(script: "ls -d ./classes/cluster/*/ | awk -F/ '{print \$4}'", returnStdout: true).tokenize()
+
+ // create a list of cluster names present in cluster folder
+ def infraList = []
+ for (elt in infraYMLs) {
+ infraList << elt.tokenize('/')[3]
+ }
+
+ // verify we have all valid clusters loaded
+ def commonList = infraList.intersect(clusterDirectories)
+ def differenceList = infraList.plus(clusterDirectories)
+ differenceList.removeAll(commonList)
+
+ if(!differenceList.isEmpty()){
+ common.warningMsg("The following clusters are not valid : ${differenceList} - That means we cannot found cluster_name in init.yml or infra/init.yml")
+ }
+ if (modifiedClusters) {
+ infraYMLs.removeAll { !modifiedClusters.contains(it.tokenize('/')[3]) }
+ common.infoMsg("Testing only modified clusters: ${infraYMLs}")
+ }
+
+ for (int i = 0; i < infraYMLs.size(); i++) {
+ def infraYMLConfig = readYaml(file: infraYMLs[i])
+ if(!infraYMLConfig["parameters"].containsKey("_param")){
+ common.warningMsg("ERROR: Cannot find soft params (_param) in file " + infraYMLs[i] + " for obtain a cluster info. Skipping test.")
+ continue
+ }
+ def infraParams = infraYMLConfig["parameters"]["_param"];
+ if(!infraParams.containsKey("infra_config_hostname") || !infraParams.containsKey("cluster_name") || !infraParams.containsKey("cluster_domain")){
+ common.warningMsg("ERROR: Cannot find _param:infra_config_hostname or _param:cluster_name or _param:cluster_domain in file " + infraYMLs[i] + " for obtain a cluster info. Skipping test.")
+ continue
+ }
+ def clusterName = infraParams["cluster_name"]
+ def clusterDomain = infraParams["cluster_domain"]
+ def configHostname = infraParams["infra_config_hostname"]
+ def testTarget = String.format("%s.%s", configHostname, clusterDomain)
+
+ futureNodes << [defaultGitUrl, defaultGitRef, clusterName, testTarget, formulasSource]
+ }
+
+ setupRunner()
+
+ if (failedNodes) {
+ currentBuild.result = "FAILURE"
+ }
+ }
+ }
+ } catch (Throwable e) {
+ currentBuild.result = "FAILURE"
+ currentBuild.description = currentBuild.description ? e.message + " " + currentBuild.description : e.message
+ throw e
+ } finally {
+ common.sendNotification(currentBuild.result,"",["slack"])
}
- } catch (Throwable e) {
- currentBuild.result = "FAILURE"
- currentBuild.description = currentBuild.description ? e.message + " " + currentBuild.description : e.message
- throw e
- } finally {
- common.sendNotification(currentBuild.result,"",["slack"])
}
}