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

Allow to specify node for load from SCM (Jenkinsfile)

      Currently SCM checkout is done on master. This requires the master to have SCM tool installed. Add ability to specify node for Pipeline SCM checkout (Jenkinsfile).

          [JENKINS-34140] Allow to specify node for load from SCM (Jenkinsfile)

          Code changed in jenkins
          User: Jesse Glick
          Path:
          src/main/java/org/jenkinsci/plugins/workflow/cps/CpsScmFlowDefinition.java
          http://jenkins-ci.org/commit/workflow-cps-plugin/e162da74637040ccd0b9623290b8597da1a8e513
          Log:
          Removing TODO comment filed as JENKINS-34140.

          SCM/JIRA link daemon added a comment - Code changed in jenkins User: Jesse Glick Path: src/main/java/org/jenkinsci/plugins/workflow/cps/CpsScmFlowDefinition.java http://jenkins-ci.org/commit/workflow-cps-plugin/e162da74637040ccd0b9623290b8597da1a8e513 Log: Removing TODO comment filed as JENKINS-34140 .

          Jesse Glick added a comment -

          The code change seems easy, but the security implications are worrisome. Anyway JENKINS-33273 would render this sort of obsolete to the extent that compliant SCM integrations would not require any checkout for Jenkinsfile. For SCMs which do not have any way of retrieving file contents remotely, or which do not have a Java client, the problem may remain.

          Jesse Glick added a comment - The code change seems easy, but the security implications are worrisome. Anyway JENKINS-33273 would render this sort of obsolete to the extent that compliant SCM integrations would not require any checkout for Jenkinsfile . For SCMs which do not have any way of retrieving file contents remotely, or which do not have a Java client, the problem may remain.

          Eli White added a comment -

          Eli White added a comment - This seems similar to https://issues.jenkins-ci.org/browse/JENKINS-35710

          Jesse Glick added a comment -

          JENKINS-35710 that is. Not really.

          Jesse Glick added a comment - JENKINS-35710 that is. Not really.

          Jesse Glick added a comment -

          Lesser importance after JENKINS-33273.

          Jesse Glick added a comment - Lesser importance after  JENKINS-33273 .

          Hi Owen,

          I'm checking out code on a specific node like this:

           

          pipeline {
             environment {
                mvnHome = tool 'maven-3.0.5'
                mvn_version = 'maven-3.0.5'
             }
          
             agent none
          
             options {
                buildDiscarder(logRotator(numToKeepStr: '30', artifactNumToKeepStr: '30'))
                retry(2)
                skipDefaultCheckout()
             }
          
             stages {
                stage('build') {
                agent {
                   node {
                      label 'xxxx'
                      customWorkspace 'xxxxxxxxxxx-ws'
                   }
                }
          
                steps {
                   checkout([$class: 'SubversionSCM', additionalCredentials: [], 
                      excludedCommitMessages: '', excludedRegions: '', excludedRevprop: '',
                      excludedUsers: '', 
                      filterChangelog: false, ignoreDirPropChanges: false, 
                      includedRegions: '', 
                      locations: [], workspaceUpdater: [$class: 'UpdateWithCleanUpdater']])
          
                   // Name the build after the product version. Also include the build 
                   // machine as a debugging aid.
                   echo "Running BUILD_ID ${env.BUILD_ID} on NODE_NAME ${env.NODE_NAME}"
          
          

          The key here is skipDefaultCheckout().

          Does this meet what you're trying to do?

          Kind Regards,

          Johnny

          John Muczynski added a comment - Hi Owen, I'm checking out code on a specific node like this:   pipeline { environment {   mvnHome = tool 'maven-3.0.5' mvn_version = 'maven-3.0.5' } agent none options { buildDiscarder(logRotator(numToKeepStr: '30' , artifactNumToKeepStr: '30' )) retry(2) skipDefaultCheckout() } stages { stage( 'build' ) { agent { node { label 'xxxx' customWorkspace 'xxxxxxxxxxx-ws' } } steps { checkout([$class: 'SubversionSCM' , additionalCredentials: [], excludedCommitMessages: '', excludedRegions: ' ', excludedRevprop: ' ', excludedUsers: '', filterChangelog: false , ignoreDirPropChanges: false , includedRegions: '', locations: [], workspaceUpdater: [$class: 'UpdateWithCleanUpdater' ]]) // Name the build after the product version. Also include the build // machine as a debugging aid. echo "Running BUILD_ID ${env.BUILD_ID} on NODE_NAME ${env.NODE_NAME}" The key here is skipDefaultCheckout(). Does this meet what you're trying to do? Kind Regards, Johnny

          Andrew Bayer added a comment -

          No, that just skips the automatic checkout on the agent. This ticket is about where the Jenkinsfile gets read in the first place - which is just on master.

          Andrew Bayer added a comment - No, that just skips the automatic checkout on the agent. This ticket is about where the Jenkinsfile gets read in the first place - which is just on master.

            Unassigned Unassigned
            owood Owen Wood
            Votes:
            2 Vote for this issue
            Watchers:
            9 Start watching this issue

              Created:
              Updated: