Added 12h timeout to all pipelines
Change-Id: I085fcbda322d0877d5ffebd002fc109577788c29
diff --git a/test-salt-formulas-pipeline.groovy b/test-salt-formulas-pipeline.groovy
index 37983c0..af22dc8 100644
--- a/test-salt-formulas-pipeline.groovy
+++ b/test-salt-formulas-pipeline.groovy
@@ -63,43 +63,43 @@
[$class: 'StringParameterValue', name: 'SALT_VERSION', value: SALT_VERSION]
]
}
-
-node("python") {
- try {
- stage("checkout") {
- if (gerritRef) {
- // job is triggered by Gerrit
- 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 {
- // test if change aren't already merged
- def merged = gerritChange.status == "MERGED"
- if (!merged) {
- checkouted = gerrit.gerritPatchsetCheckout([
- credentialsId: CREDENTIALS_ID
- ])
+timeout(time: 12, unit: 'HOURS') {
+ node("python") {
+ try {
+ stage("checkout") {
+ if (gerritRef) {
+ // job is triggered by Gerrit
+ 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 {
- common.successMsg("Change ${GERRIT_CHANGE_NUMBER} is already merged, no need to test them")
+ // test if change aren't already merged
+ 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 = "${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")
}
- 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("test") {
if (checkouted) {
try {
saltVersion = SALT_VERSION
- } catch (MissingPropertyException e) {
+ } catch (MissingPropertyException e) {
saltVersion = "latest"
}
withEnv(["SALT_VERSION=${saltVersion}"]) {
@@ -108,52 +108,53 @@
}
}
stage("kitchen") {
- if (checkouted) {
- if (fileExists(".kitchen.yml")) {
- common.infoMsg(".kitchen.yml found, running kitchen tests")
- def kitchenEnvs = []
- def filteredEnvs = []
- if (fileExists(".travis.yml")) {
- common.infoMsg(".travis.yml file found.")
- def kitchenConfigYML = readYaml(file: ".travis.yml")
- if (kitchenConfigYML.containsKey("env")) {
- kitchenEnvs = kitchenConfigYML["env"]
+ if (checkouted) {
+ if (fileExists(".kitchen.yml")) {
+ common.infoMsg(".kitchen.yml found, running kitchen tests")
+ def kitchenEnvs = []
+ def filteredEnvs = []
+ if (fileExists(".travis.yml")) {
+ common.infoMsg(".travis.yml file found.")
+ def kitchenConfigYML = readYaml(file: ".travis.yml")
+ if (kitchenConfigYML.containsKey("env")) {
+ kitchenEnvs = kitchenConfigYML["env"]
+ }
+ } else {
+ common.warningMsg(".travis.yml file not found, suites must be passed via CUSTOM_KITCHEN_ENVS parameter.")
}
- } else {
- common.warningMsg(".travis.yml file not found, suites must be passed via CUSTOM_KITCHEN_ENVS parameter.")
- }
- common.infoMsg("Running kitchen testing in parallel mode")
- if (CUSTOM_KITCHEN_ENVS != null && CUSTOM_KITCHEN_ENVS != '') {
- kitchenEnvs = CUSTOM_KITCHEN_ENVS.tokenize('\n')
- common.infoMsg("CUSTOM_KITCHEN_ENVS not empty. Running with custom enviroments: ${kitchenEnvs}")
- }
- if (kitchenEnvs != null && kitchenEnvs != '') {
- def acc = 0
- common.infoMsg("Found " + kitchenEnvs.size() + " environment(s)")
- for (int i = 0; i < kitchenEnvs.size(); i++) {
- futureFormulas << kitchenEnvs[i]
+ common.infoMsg("Running kitchen testing in parallel mode")
+ if (CUSTOM_KITCHEN_ENVS != null && CUSTOM_KITCHEN_ENVS != '') {
+ kitchenEnvs = CUSTOM_KITCHEN_ENVS.tokenize('\n')
+ common.infoMsg("CUSTOM_KITCHEN_ENVS not empty. Running with custom enviroments: ${kitchenEnvs}")
}
- setupRunner(defaultGitRef, defaultGitUrl)
- } else {
- common.warningMsg(".kitchen.yml file not found, no kitchen tests triggered.")
+ if (kitchenEnvs != null && kitchenEnvs != '') {
+ def acc = 0
+ common.infoMsg("Found " + kitchenEnvs.size() + " environment(s)")
+ for (int i = 0; i < kitchenEnvs.size(); i++) {
+ futureFormulas << kitchenEnvs[i]
+ }
+ setupRunner(defaultGitRef, defaultGitUrl)
+ } else {
+ common.warningMsg(".kitchen.yml file not found, no kitchen tests triggered.")
+ }
}
}
}
- }
- if (failedFormulas) {
+ if (failedFormulas) {
+ currentBuild.result = "FAILURE"
+ common.warningMsg("The following tests failed: ${failedFormulas}")
+ }
+ } catch (Throwable e) {
+ // If there was an error or exception thrown, the build failed
currentBuild.result = "FAILURE"
- common.warningMsg("The following tests failed: ${failedFormulas}")
+ currentBuild.description = currentBuild.description ? e.message + " " + currentBuild.description : e.message
+ throw e
+ } finally {
+ if (currentBuild.result == "FAILURE" && fileExists(".kitchen/logs/kitchen.log")) {
+ common.errorMsg("----------------KITCHEN LOG:---------------")
+ println readFile(".kitchen/logs/kitchen.log")
+ }
+ common.sendNotification(currentBuild.result, "", ["slack"])
}
- } catch (Throwable e) {
- // If there was an error or exception thrown, the build failed
- currentBuild.result = "FAILURE"
- currentBuild.description = currentBuild.description ? e.message + " " + currentBuild.description : e.message
- throw e
- } finally {
- if (currentBuild.result == "FAILURE" && fileExists(".kitchen/logs/kitchen.log")) {
- common.errorMsg("----------------KITCHEN LOG:---------------")
- println readFile(".kitchen/logs/kitchen.log")
- }
- common.sendNotification(currentBuild.result, "", ["slack"])
}
}