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

Cannot access SCM object in Pipeline Script Job

    XMLWordPrintable

    Details

    • Similar Issues:

      Description

      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

       

       

        Attachments

          Activity

          Hide
          markewaite Mark Waite added a comment - - edited

          I believe this is an intentional behavior of the scm pipeline step plugin. The scm global variable may not be assigned by the user. It may be used only in a multibranch pipeline. You can read about the global variable on your Jenkins instance at http://your-jenkins.example.com/pipeline-syntax/globals#scm

          Show
          markewaite Mark Waite added a comment - - edited I believe this is an intentional behavior of the scm pipeline step plugin. The scm global variable may not be assigned by the user. It may be used only in a multibranch pipeline. You can read about the global variable on your Jenkins instance at http://your-jenkins.example.com/pipeline-syntax/globals#scm

            People

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

              Dates

              Created:
              Updated:
              Resolved: