Jenkinsfile
branchfeature-block-in-context
changeset 80 c213d491e876
parent 74 57edfcce2a40
child 105 983a637074e6
--- a/Jenkinsfile	Tue Nov 22 21:19:13 2016 +0000
+++ b/Jenkinsfile	Mon Nov 14 23:00:13 2016 +0000
@@ -3,6 +3,15 @@
  */
 
 def pipeline;
+
+def branch() {
+    if (env.BRANCH_NAME == null) {
+        return scm.getBranch();
+    } else {
+        return env.BRANCH_NAME;
+    }
+}
+
 stage ( "Load Pipeline") {
     node {
         /*
@@ -11,7 +20,16 @@
          * workspace instead
          */
         ws ("workspace/${env.JOB_NAME}@loadpipeline") {
-            checkout scm
+            sshagent([ scm.getCredentialsId() ]) {
+                sh  """
+                    if [ -f pipeline.groovy ]; then
+                        hg pull ${scm.getSource()}
+                    else
+                        hg clone ${scm.getSource()} .
+                    fi
+                    hg up ${branch()}
+                    """
+            }
             pipeline = load "pipeline.groovy"
         }
     }