Uploaded image for project: 'Jenkins'
  1. Jenkins
  2. JENKINS-40906

Resolve an SCM from an SCMSource and a list of candidate target branch names

XMLWordPrintable

      Use-case:

      The Apache Maven Jenkinsfile wants to run integration tests when testing a build of Maven core.

      As new features are added, there is often a need to add associated integration tests.

      It would be great if the Jenkinsfile could easily determine if there is a matching branch in the maven-integration-testing repository and check that out... but if there is no matching branch then the master branch should be used instead.

      Something like

      def tests=resolveScm(source:git(url:'https://git-wip-us.apache.org/repos/asf/maven-integration-testing.git'), targets:[env.BRANCH_NAME,'master']))
      node('ubuntu') {
          stage 'Checkout'{
              ...
              checkout scm
          }
         ...
      }
      
      stage 'Integration Test'
      parallel linuxJava7:{
              node('ubuntu') {
                  checkout tests
                  ...
              }
          },linuxJava8: {
              node('ubuntu') {
                  checkout tests
                  ...
              }
          },winJava7: {
              node('windows-2012') {
                  checkout tests
                  ...
              }
          },winJava8: {
              node('windows-2012') {
                  checkout tests
                  ...
              }
          }
      ...
      

      There are a couple of important features:

      1. We want to use the SCMSource to create the SCM so that it has a pinned revision and the same version of the tests are used on each of the parallel integration test runs
      2. We want to allow a list of branches to be tried in preference order
      3. We want to avoid requiring conditional behaviour to use this feature in the pipeline so that it can also be used from pipeline-model-definition based pipelines

            stephenconnolly Stephen Connolly
            stephenconnolly Stephen Connolly
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved: