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

Cannot access SCM object in Pipeline Script Job

XMLWordPrintable

      Whenever accessing scm property from the Scripted Pipeline the below error is being thrown:

       

      ERROR: ‘checkout scm’ is only available when using “Multibranch Pipeline” or “Pipeline script from SCM

      Example code:

       

      node {
        def tempSCM = scm
      }
      

      Please note that the checkout command was not used. Also, when assigning anything to that property no error is thrown:

      scm =
              [$class           : 'GitSCM', branches: [[name: "*/$testsBranchName"]],
               //...
               credentialsId    : 'GitUser'
              ] //<- no error here
      

      Attached system info

       

       

        1. system-info
          8 kB
          Mikołaj Mański

            markewaite Mark Waite
            mmanski Mikołaj Mański
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved: