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

Use SCM extension [$class: 'ScmName'] in Pipeline step

    Details

    • Similar Issues:

      Description

      Given the following code

      lock('checkout') {
          stage('checkout') {
              checkout([$class: 'GitSCM',
                      branches: [[name: branch]],
                      doGenerateSubmoduleConfigurations: false,
                      extensions: [[$class: 'CleanCheckout'], [$class: 'ScmName', name: 'super']],
                      submoduleCfg: [],
                      userRemoteConfigs: [[url: "${gitBaseUrl}/${superRepo}"]]])
      
              def repos = readFile('.gitslave')
              def reposLines = repos.readLines()
              for (line in reposLines) {
                  def repoInfo = line.split(' ')
                  def repoUrl = repoInfo[0]
                  def repoPath = repoInfo[1]
                  def curatedRepoUrl = repoUrl.substring(4, repoUrl.length()-1)
                  def curatedRepoPath = repoPath.substring(1, repoPath.length()-1)
      
                  checkout([$class: 'GitSCM',
                          branches: [[name: branch]],
                          doGenerateSubmoduleConfigurations: false,
                          extensions: [[$class: 'RelativeTargetDirectory', relativeTargetDir: curatedRepoPath], [$class: 'CleanCheckout'], [$class: 'ScmName', name: curatedRepoPath]],
                          submoduleCfg: [],
                          userRemoteConfigs: [[url: "${gitBaseUrl}/${curatedRepoUrl}"]]])
              }
          }
      }
      
      

      We use $class: 'ScmName', name: curatedRepoPath].

      That is reflected in the SCM list, but not in Pipeline Step. See attached screenshots.

      Would be great if that value was used in the SCM pipeline step.

        Attachments

        1. scm.png
          scm.png
          47 kB
        2. scm2.png
          scm2.png
          22 kB

          Issue Links

            Activity

            roidelapluie Julien Pivotto created issue -
            roidelapluie Julien Pivotto made changes -
            Field Original Value New Value
            Description The `sh` step adds a "Shell Script" step in the Pipeline. However, there could be multiple such steps including steps from various plugins (e.g., Docker), which makes it hard to distinguish the steps. We should perhaps add an optional parameter to sh to specify a name or alias which would then appear in the pipeline steps.

            e.g., the following can be the step for npm which would show as "Shell script: npm" in the pipeline view.
            {code:java}
            sh cmd:"npm install", name: "npm"
            {code}

            Given the following code
            {code:groovy}
            lock('checkout') {
                stage('checkout') {
                    checkout([$class: 'GitSCM',
                            branches: [[name: branch]],
                            doGenerateSubmoduleConfigurations: false,
                            extensions: [[$class: 'CleanCheckout'], [$class: 'ScmName', name: 'super']],
                            submoduleCfg: [],
                            userRemoteConfigs: [[url: "${gitBaseUrl}/${superRepo}"]]])

                    def repos = readFile('.gitslave')
                    def reposLines = repos.readLines()
                    for (line in reposLines) {
                        def repoInfo = line.split(' ')
                        def repoUrl = repoInfo[0]
                        def repoPath = repoInfo[1]
                        def curatedRepoUrl = repoUrl.substring(4, repoUrl.length()-1)
                        def curatedRepoPath = repoPath.substring(1, repoPath.length()-1)

                        checkout([$class: 'GitSCM',
                                branches: [[name: branch]],
                                doGenerateSubmoduleConfigurations: false,
                                extensions: [[$class: 'RelativeTargetDirectory', relativeTargetDir: curatedRepoPath], [$class: 'CleanCheckout'], [$class: 'ScmName', name: curatedRepoPath]],
                                submoduleCfg: [],
                                userRemoteConfigs: [[url: "${gitBaseUrl}/${curatedRepoUrl}"]]])
                    }
                }
            }

            {code}
            We use $class: 'ScmName', name: curatedRepoPath]
            roidelapluie Julien Pivotto made changes -
            Description Given the following code
            {code:groovy}
            lock('checkout') {
                stage('checkout') {
                    checkout([$class: 'GitSCM',
                            branches: [[name: branch]],
                            doGenerateSubmoduleConfigurations: false,
                            extensions: [[$class: 'CleanCheckout'], [$class: 'ScmName', name: 'super']],
                            submoduleCfg: [],
                            userRemoteConfigs: [[url: "${gitBaseUrl}/${superRepo}"]]])

                    def repos = readFile('.gitslave')
                    def reposLines = repos.readLines()
                    for (line in reposLines) {
                        def repoInfo = line.split(' ')
                        def repoUrl = repoInfo[0]
                        def repoPath = repoInfo[1]
                        def curatedRepoUrl = repoUrl.substring(4, repoUrl.length()-1)
                        def curatedRepoPath = repoPath.substring(1, repoPath.length()-1)

                        checkout([$class: 'GitSCM',
                                branches: [[name: branch]],
                                doGenerateSubmoduleConfigurations: false,
                                extensions: [[$class: 'RelativeTargetDirectory', relativeTargetDir: curatedRepoPath], [$class: 'CleanCheckout'], [$class: 'ScmName', name: curatedRepoPath]],
                                submoduleCfg: [],
                                userRemoteConfigs: [[url: "${gitBaseUrl}/${curatedRepoUrl}"]]])
                    }
                }
            }

            {code}
            We use $class: 'ScmName', name: curatedRepoPath]
            Given the following code
            {code:groovy}
            lock('checkout') {
                stage('checkout') {
                    checkout([$class: 'GitSCM',
                            branches: [[name: branch]],
                            doGenerateSubmoduleConfigurations: false,
                            extensions: [[$class: 'CleanCheckout'], [$class: 'ScmName', name: 'super']],
                            submoduleCfg: [],
                            userRemoteConfigs: [[url: "${gitBaseUrl}/${superRepo}"]]])

                    def repos = readFile('.gitslave')
                    def reposLines = repos.readLines()
                    for (line in reposLines) {
                        def repoInfo = line.split(' ')
                        def repoUrl = repoInfo[0]
                        def repoPath = repoInfo[1]
                        def curatedRepoUrl = repoUrl.substring(4, repoUrl.length()-1)
                        def curatedRepoPath = repoPath.substring(1, repoPath.length()-1)

                        checkout([$class: 'GitSCM',
                                branches: [[name: branch]],
                                doGenerateSubmoduleConfigurations: false,
                                extensions: [[$class: 'RelativeTargetDirectory', relativeTargetDir: curatedRepoPath], [$class: 'CleanCheckout'], [$class: 'ScmName', name: curatedRepoPath]],
                                submoduleCfg: [],
                                userRemoteConfigs: [[url: "${gitBaseUrl}/${curatedRepoUrl}"]]])
                    }
                }
            }

            {code}
            We use {{$class: 'ScmName', name: curatedRepoPath]}}.

            That is reflected in the SCM list, but not in Pipeline Step. See attached screenshots.

            Would be great if that value was used in the SCM pipeline step.
            roidelapluie Julien Pivotto made changes -
            Attachment scm.png [ 34823 ]
            roidelapluie Julien Pivotto made changes -
            Attachment scm.png [ 34823 ]
            roidelapluie Julien Pivotto made changes -
            Attachment scm.png [ 34824 ]
            roidelapluie Julien Pivotto made changes -
            Attachment scm2.png [ 34825 ]
            jamesdumay James Dumay made changes -
            Component/s blueocean-plugin [ 21481 ]
            jamesdumay James Dumay made changes -
            Link This issue duplicates JENKINS-37324 [ JENKINS-37324 ]
            jamesdumay James Dumay made changes -
            Status Open [ 1 ] Resolved [ 5 ]
            Resolution Duplicate [ 3 ]

              People

              • Assignee:
                Unassigned
                Reporter:
                roidelapluie Julien Pivotto
              • Votes:
                0 Vote for this issue
                Watchers:
                1 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved: