Refactored test pipelines for possibility of external call gerrit checkout
Change-Id: I3682290aa7d4fa8dd857bc92fe12def66ee51f0a
diff --git a/test-salt-formulas-pipeline.groovy b/test-salt-formulas-pipeline.groovy
index 2a3b2ac..24e5bb3 100644
--- a/test-salt-formulas-pipeline.groovy
+++ b/test-salt-formulas-pipeline.groovy
@@ -1,16 +1,51 @@
+/**
+ * Test salt formulas pipeline
+ * DEFAULT_GIT_REF
+ * DEFAULT_GIT_URL
+ * CREDENTIALS_ID
+ */
def common = new com.mirantis.mk.Common()
def gerrit = new com.mirantis.mk.Gerrit()
+
+def gerritRef
+try {
+ gerritRef = GERRIT_REFSPEC
+} catch (MissingPropertyException e) {
+ gerritRef = null
+}
+
+def defaultGitRef, defaultGitUrl
+try {
+ defaultGitRef = DEFAULT_GIT_REF
+ defaultGitUrl = DEFAULT_GIT_URL
+} catch (MissingPropertyException e) {
+ defaultGitRef = null
+ defaultGitUrl = null
+}
+
+def checkouted = false;
+
node("python") {
try{
stage("checkout") {
- gerrit.gerritPatchsetCheckout ([
+ if (gerritRef) {
+ // job is triggered by Gerrit
+ checkouted = gerrit.gerritPatchsetCheckout ([
credentialsId : CREDENTIALS_ID
- ])
+ ])
+ } else if(defaultGitRef && defaultGitUrl) {
+ checkouted = gerrit.gerritPatchsetCheckout(defaultGitUrl, defaultGitRef, "master", CREDENTIALS_ID)
+ }
+ if(!checkouted){
+ common.errorMsg("Cannot checkout gerrit patchset, GERRIT_REFSPEC and DEFAULT_GIT_REF is null")
+ }
}
stage("test") {
- wrap([$class: 'AnsiColorBuildWrapper']) {
- sh("make clean")
- sh("[ $SALT_VERSION != 'latest' ] || export SALT_VERSION=''; make test")
+ if(checkouted){
+ wrap([$class: 'AnsiColorBuildWrapper']) {
+ sh("make clean")
+ sh("[ $SALT_VERSION != 'latest' ] || export SALT_VERSION=''; make test")
+ }
}
}
} catch (Throwable e) {