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

Pipeline - plugin does not find SCMs on first execution

    XMLWordPrintable

    Details

    • Similar Issues:

      Description

       This issue was reported by an user at github here.

      The issue is that the plugin is failing to getSCM in a pipeline run only on the first time, here is the code used by the plugin:

      Collection<? extends SCM> scms = SCMTriggerItem.SCMTriggerItems.asSCMTriggerItem(projectAction.getProject()).getSCMs();
      

      scms is _ null _ when we run the pipeline script below, only for the first time:

       

      node() {
        def STOP_ON_ERROR = '';
        def mvnHome
        def javaHome
        def failed = false;
        try{
          stage('Preparation') { // for display purposes
            // Get the Maven tool.
            // ** NOTE: This 'M3' Maven tool must be configured
            // **       in the global configuration.
            checkout([$class: 'GitSCM', branches: [[name: '*/master']], doGenerateSubmoduleConfigurations: false, extensions: [], submoduleCfg: [], userRemoteConfigs: [[url: 'https://github.com/thomas-oo/eventAppFrontend']]])
          }
        }catch(Exception e){
          failed = true
          echo 'Build failed'
        }finally{
          if(!failed){
            stage('Last Changes'){
              echo 'In last changes'
              step([$class: 'LastChangesPublisher', format: 'LINE', matchWordsThreshold: '0.25', matching: 'NONE', matchingMaxComparisons: '1000', showFiles: true, synchronisedScroll: true, endRevision: ''])
            }
          }
          echo 'In finally block'
        }
      }

       

       

       

       

        Attachments

          Activity

          Hide
          rmpestano Rafael Pestano added a comment -

          Hi Baptiste Mathus, Daniel Beck and Oleg Nenashev,

           

          Do you have any recomendation on this? I've read the pipeline devguide but missed a concrete example, do you have any pointers on that?

           

          Thanks in advance!

          Show
          rmpestano Rafael Pestano added a comment - Hi Baptiste Mathus , Daniel Beck and Oleg Nenashev ,   Do you have any recomendation on this? I've read the pipeline devguide but missed a concrete example, do you have any pointers on that?   Thanks in advance!
          Hide
          luispiedra Luis Piedra-Márquez added a comment -

          I think it is more an issue in workflow-job plugin rather than in consumer plugins. I'm hitting the same problem with bitbucket-build-status-notifier, there is no reasonable way to retrieve the SCMs of the already performed checkouts in the first build. It's really painful specially when using branch source plugins.

          WorkflobJob getSCMs method could fallback to the SCM from checkouts in the current build if there is no last completed build. WorkflowRun class already has this information but it's not accessible to external classes.

           

           

           

           

          Show
          luispiedra Luis Piedra-Márquez added a comment - I think it is more an issue in workflow-job plugin rather than in consumer plugins. I'm hitting the same problem with bitbucket-build-status-notifier, there is no reasonable way to retrieve the SCMs of the already performed checkouts in the first build. It's really painful specially when using branch source plugins. WorkflobJob getSCMs method could fallback to the SCM from checkouts in the current build if there is no last completed build. WorkflowRun class already has this information but it's not accessible to external classes.        

            People

            Assignee:
            rmpestano Rafael Pestano
            Reporter:
            rmpestano Rafael Pestano
            Votes:
            1 Vote for this issue
            Watchers:
            2 Start watching this issue

              Dates

              Created:
              Updated: