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

p4-plugin + global pipeline shared library - no ${JOB_NAME} expansion in view

      similar to JENKINS-50393 but as a global declarative shared library

      I have a pipelines-lib/vars/basicDeclarative.groovy file with contents like:

      def call(body) {
          def config = [:]
          body.resolveStrategy = Closure.DELEGATE_FIRST
          body.delegate = config
          body()
          pipeline {
              ...
              stages {
                  stage("Checkout") {
                      steps {
                          checkout perforce(
                              ...
                              workspace: manualSpec(
                                  ...
                                  name: 'jenkins-${JOB_NAME}',
                                  ...
                                  spec: clientSpec(
                                      view: config.p4view
                                      ...
                                  )
                              ...
                              )
                          ...
                          )
                     }
                 }
             }
         }
      }

      that when called with a Jenkinsfile script like:

      #!groovy
      @Library('pipelines-lib') _
      basicDeclarative {
          p4view = """\
          //depot/foo/bar/... //jenkins-${JOB_NAME}/...
          """
      }

      results in errors like:

      ... p4 client -o jenkins-pipelines-lib-test +
      ... p4 client -i +
      P4: Unable to setup workspace: com.perforce.p4java.exception.RequestException: Error in client specification.
      Mapping '//jenkins-null/...' is not under '//jenkins-pipelines-lib-test/...'.

      note the workspace name is expanded properly but the view mapping is not

       

      many edits to try and fix formatting - preformatted/monospace does not work well with curly braces

          [JENKINS-52487] p4-plugin + global pipeline shared library - no ${JOB_NAME} expansion in view

          Daniel Hsueh created issue -
          Daniel Hsueh made changes -
          Description Original: similar to JENKINS-50393 but as a global declarative shared library

          I have a pipelines-lib/vars/basicDeclarative.groovy file with contents like:

          {{def call(body) {}}
          {{    def config = [:]}}
           {{    body.resolveStrategy = Closure.DELEGATE_FIRST}}
           {{    body.delegate = config}}
           {{    body()}}
           {{    pipeline {}}
           {{        ...}}
          {{        stages {}}
           {{            stage("Checkout") {}}
           {{                steps {}}
           {{                    checkout perforce(}}
           {{                        ...}}
           {{                        workspace: manualSpec(}}
           {{                            ...}}
          {{                            name: 'jenkins-{color:#00875a}${JOB_NAME}{color}',}}
           {{                            ...}}
           {{                            spec: clientSpec(}}
           {{                                view: config.p4view}}
           {{                                ...}}
           {{                            )}}
           {{                        ...}}
           {{                        )}}
           {{                    ...}}
           {{                    )}}
          {{                }}}
          {{            }}}
          {{        }}}
          {{    }}}
          {{ {{}}}}}

          that when called with a Jenkinsfile script like:

          {{#!groovy}}
          {{ @Library('pipelines-lib') _}}
          {{basicDeclarative {}}
          {{     p4view = """\}}
          {{     //depot/foo/bar/... //jenkins-{color:#de350b}${JOB_NAME}{color}/...}}
          {{     """}}
          {{ }}}

          results in errors like:

          {{... p4 client -o jenkins-pipelines-lib-test +}}
          {{... p4 client -i +}}
          {{P4: Unable to setup workspace: com.perforce.p4java.exception.RequestException: Error in client specification.}}
          {{Mapping '//jenkins-null/...' is not under '//jenkins-pipelines-lib-test/...'.}}

          note the {color:#00875a}workspace name{color} is expanded properly but the {color:#de350b}view mapping{color} is not

           
          New: similar to JENKINS-50393 but as a global declarative shared library

          I have a pipelines-lib/vars/basicDeclarative.groovy file with contents like:

          {{def call(body) {}}
          {{     def config = [:]}}
          {{     body.resolveStrategy = Closure.DELEGATE_FIRST}}
          {{     body.delegate = config}}
          {{     body()}}
          {{     pipeline {}}
          {{         ...}}
          {{         stages {}}
          {{             stage("Checkout") {}}
          {{                 steps {}}
          {{                     checkout perforce(}}
          {{                         ...}}
          {{                         workspace: manualSpec(}}
          {{                             ...}}
          {{                             name: 'jenkins-{color:#00875a}${JOB_NAME}{color}',}}
          {{                             ...}}
          {{                             spec: clientSpec(}}
          {{                                 view: config.p4view}}
          {{                                 ...}}
          {{                             )}}
          {{                         ...}}
          {{                         )}}
          {{                     ...}}
          {{                     )}}
          {{                }}}
          {{            }}}
          {{        }}}
          {{    }}}
          {{}}}

          that when called with a Jenkinsfile script like:

          {{#!groovy}}
          {{@Library('pipelines-lib') _}}
          {{ basicDeclarative {}}
          {{     p4view = """\}}
          {{     //depot/foo/bar/... //jenkins-{color:#de350b}${JOB_NAME}{color}/...}}
          {{     """}}
          {{}}}

          results in errors like:

          {{... p4 client -o jenkins-pipelines-lib-test +}}
           {{... p4 client -i +}}
           {{P4: Unable to setup workspace: com.perforce.p4java.exception.RequestException: Error in client specification.}}
           {{Mapping '//jenkins-null/...' is not under '//jenkins-pipelines-lib-test/...'.}}

          note the {color:#00875a}workspace name{color} is expanded properly but the {color:#de350b}view mapping{color} is not

           
          Daniel Hsueh made changes -
          Description Original: similar to JENKINS-50393 but as a global declarative shared library

          I have a pipelines-lib/vars/basicDeclarative.groovy file with contents like:

          {{def call(body) {}}
          {{     def config = [:]}}
          {{     body.resolveStrategy = Closure.DELEGATE_FIRST}}
          {{     body.delegate = config}}
          {{     body()}}
          {{     pipeline {}}
          {{         ...}}
          {{         stages {}}
          {{             stage("Checkout") {}}
          {{                 steps {}}
          {{                     checkout perforce(}}
          {{                         ...}}
          {{                         workspace: manualSpec(}}
          {{                             ...}}
          {{                             name: 'jenkins-{color:#00875a}${JOB_NAME}{color}',}}
          {{                             ...}}
          {{                             spec: clientSpec(}}
          {{                                 view: config.p4view}}
          {{                                 ...}}
          {{                             )}}
          {{                         ...}}
          {{                         )}}
          {{                     ...}}
          {{                     )}}
          {{                }}}
          {{            }}}
          {{        }}}
          {{    }}}
          {{}}}

          that when called with a Jenkinsfile script like:

          {{#!groovy}}
          {{@Library('pipelines-lib') _}}
          {{ basicDeclarative {}}
          {{     p4view = """\}}
          {{     //depot/foo/bar/... //jenkins-{color:#de350b}${JOB_NAME}{color}/...}}
          {{     """}}
          {{}}}

          results in errors like:

          {{... p4 client -o jenkins-pipelines-lib-test +}}
           {{... p4 client -i +}}
           {{P4: Unable to setup workspace: com.perforce.p4java.exception.RequestException: Error in client specification.}}
           {{Mapping '//jenkins-null/...' is not under '//jenkins-pipelines-lib-test/...'.}}

          note the {color:#00875a}workspace name{color} is expanded properly but the {color:#de350b}view mapping{color} is not

           
          New: similar to JENKINS-50393 but as a global declarative shared library

          I have a pipelines-lib/vars/basicDeclarative.groovy file with contents like:

          {{def call(body) {}}
              def config = [:]
              body.resolveStrategy = Closure.DELEGATE_FIRST
              body.delegate = config
              body()
              pipeline {
                  ...
                  stages {
                      stage("Checkout") {
                          steps {
                              checkout perforce(
                                  ...
                                  workspace: manualSpec(
                                      ...
                                      name: 'jenkins-{color:#00875a}${JOB_NAME}{color}',
                                      ...
                                      spec: clientSpec(
                                          view: config.p4view
                                          ...
                                      )
                                  ...
                                  )
                              ...
                              )
                         }
                     }
                 }
             }
           {{}}}

          that when called with a Jenkinsfile script like:

          {{#!groovy}}
           {{@Library('pipelines-lib') _}}
          basicDeclarative {
           {{     p4view = """}}
           {{     //depot/foo/bar/... //jenkins-{color:#de350b}${JOB_NAME}{color}/...}}
           {{     """}}
           {{}}}

          results in errors like:

          {{... p4 client -o jenkins-pipelines-lib-test +}}
           {{... p4 client -i +}}
           {{P4: Unable to setup workspace: com.perforce.p4java.exception.RequestException: Error in client specification.}}
           {{Mapping '//jenkins-null/...' is not under '//jenkins-pipelines-lib-test/...'.}}

          note the {color:#00875a}workspace name{color} is expanded properly but the {color:#de350b}view mapping{color} is not

           
          Daniel Hsueh made changes -
          Description Original: similar to JENKINS-50393 but as a global declarative shared library

          I have a pipelines-lib/vars/basicDeclarative.groovy file with contents like:

          {{def call(body) {}}
              def config = [:]
              body.resolveStrategy = Closure.DELEGATE_FIRST
              body.delegate = config
              body()
              pipeline {
                  ...
                  stages {
                      stage("Checkout") {
                          steps {
                              checkout perforce(
                                  ...
                                  workspace: manualSpec(
                                      ...
                                      name: 'jenkins-{color:#00875a}${JOB_NAME}{color}',
                                      ...
                                      spec: clientSpec(
                                          view: config.p4view
                                          ...
                                      )
                                  ...
                                  )
                              ...
                              )
                         }
                     }
                 }
             }
           {{}}}

          that when called with a Jenkinsfile script like:

          {{#!groovy}}
           {{@Library('pipelines-lib') _}}
          basicDeclarative {
           {{     p4view = """}}
           {{     //depot/foo/bar/... //jenkins-{color:#de350b}${JOB_NAME}{color}/...}}
           {{     """}}
           {{}}}

          results in errors like:

          {{... p4 client -o jenkins-pipelines-lib-test +}}
           {{... p4 client -i +}}
           {{P4: Unable to setup workspace: com.perforce.p4java.exception.RequestException: Error in client specification.}}
           {{Mapping '//jenkins-null/...' is not under '//jenkins-pipelines-lib-test/...'.}}

          note the {color:#00875a}workspace name{color} is expanded properly but the {color:#de350b}view mapping{color} is not

           
          New: similar to JENKINS-50393 but as a global declarative shared library

          I have a pipelines-lib/vars/basicDeclarative.groovy file with contents like:

          {{def call(body) {}}
               def config = [:]
               body.resolveStrategy = Closure.DELEGATE_FIRST
               body.delegate = config
               body()
               pipeline {
                   ...
                   stages {
                       stage("Checkout") {
                           steps {
                               checkout perforce(
                                   ...
                                   workspace: manualSpec(
                                       ...
                                       name: 'jenkins-{color:#00875a}${JOB_NAME}{color}',
                                       ...
                                       spec: clientSpec(
                                           view: config.p4view
                                           ...
                                       )
                                   ...
                                   )
                               ...
                               )
                          }
                      }
                  }
              }
           {{}}}

          that when called with a Jenkinsfile script like:

          {{#!groovy}}
           {{@Library('pipelines-lib') _}}
           basicDeclarative {
           {{     p4view = """\}}
           {{     //depot/foo/bar/... //jenkins-{color:#de350b}${JOB_NAME}{color}/...}}
           {{     """}}
           {{}}}

          results in errors like:

          {{... p4 client -o jenkins-pipelines-lib-test +}}
           {{... p4 client -i +}}
           {{P4: Unable to setup workspace: com.perforce.p4java.exception.RequestException: Error in client specification.}}
           {{Mapping '//jenkins-null/...' is not under '//jenkins-pipelines-lib-test/...'.}}

          note the {color:#00875a}workspace name{color} is expanded properly but the {color:#de350b}view mapping{color} is not

           

          --

          many edits to try and fix formatting - preformatted/monospace does not work well with curly braces
          Daniel Hsueh made changes -
          Description Original: similar to JENKINS-50393 but as a global declarative shared library

          I have a pipelines-lib/vars/basicDeclarative.groovy file with contents like:

          {{def call(body) {}}
               def config = [:]
               body.resolveStrategy = Closure.DELEGATE_FIRST
               body.delegate = config
               body()
               pipeline {
                   ...
                   stages {
                       stage("Checkout") {
                           steps {
                               checkout perforce(
                                   ...
                                   workspace: manualSpec(
                                       ...
                                       name: 'jenkins-{color:#00875a}${JOB_NAME}{color}',
                                       ...
                                       spec: clientSpec(
                                           view: config.p4view
                                           ...
                                       )
                                   ...
                                   )
                               ...
                               )
                          }
                      }
                  }
              }
           {{}}}

          that when called with a Jenkinsfile script like:

          {{#!groovy}}
           {{@Library('pipelines-lib') _}}
           basicDeclarative {
           {{     p4view = """\}}
           {{     //depot/foo/bar/... //jenkins-{color:#de350b}${JOB_NAME}{color}/...}}
           {{     """}}
           {{}}}

          results in errors like:

          {{... p4 client -o jenkins-pipelines-lib-test +}}
           {{... p4 client -i +}}
           {{P4: Unable to setup workspace: com.perforce.p4java.exception.RequestException: Error in client specification.}}
           {{Mapping '//jenkins-null/...' is not under '//jenkins-pipelines-lib-test/...'.}}

          note the {color:#00875a}workspace name{color} is expanded properly but the {color:#de350b}view mapping{color} is not

           

          --

          many edits to try and fix formatting - preformatted/monospace does not work well with curly braces
          New: similar to JENKINS-50393 but as a global declarative shared library

          I have a pipelines-lib/vars/basicDeclarative.groovy file with contents like:

          {{def call(body) {}}
               def config = [:]
               body.resolveStrategy = Closure.DELEGATE_FIRST
               body.delegate = config
               body()
               pipeline {
                   ...
                   stages {
                       stage("Checkout") {
                           steps {
                               checkout perforce(
                                   ...
                                   workspace: manualSpec(
                                       ...
                                       name: 'jenkins-{color:#00875a}${JOB_NAME}{color}',
                                       ...
                                       spec: clientSpec(
                                           view: config.p4view
                                           ...
                                       )
                                   ...
                                   )
                               ...
                               )
                          }
                      }
                  }
              }
           {{}}}

          that when called with a Jenkinsfile script like:

          {{#!groovy}}
           {{@Library('pipelines-lib') _}}
           basicDeclarative {
           {{     p4view = """\\}}
           {{     //depot/foo/bar/... //jenkins-{color:#de350b}${JOB_NAME}{color}/...}}
           {{     """}}
           {{}}}

          results in errors like:

          {{... p4 client -o jenkins-pipelines-lib-test +}}
           {{... p4 client -i +}}
           {{P4: Unable to setup workspace: com.perforce.p4java.exception.RequestException: Error in client specification.}}
           {{Mapping '//jenkins-null/...' is not under '//jenkins-pipelines-lib-test/...'.}}

          note the {color:#00875a}workspace name{color} is expanded properly but the {color:#de350b}view mapping{color} is not

           



          many edits to try and fix formatting - preformatted/monospace does not work well with curly braces
          Daniel Hsueh made changes -
          Description Original: similar to JENKINS-50393 but as a global declarative shared library

          I have a pipelines-lib/vars/basicDeclarative.groovy file with contents like:

          {{def call(body) {}}
               def config = [:]
               body.resolveStrategy = Closure.DELEGATE_FIRST
               body.delegate = config
               body()
               pipeline {
                   ...
                   stages {
                       stage("Checkout") {
                           steps {
                               checkout perforce(
                                   ...
                                   workspace: manualSpec(
                                       ...
                                       name: 'jenkins-{color:#00875a}${JOB_NAME}{color}',
                                       ...
                                       spec: clientSpec(
                                           view: config.p4view
                                           ...
                                       )
                                   ...
                                   )
                               ...
                               )
                          }
                      }
                  }
              }
           {{}}}

          that when called with a Jenkinsfile script like:

          {{#!groovy}}
           {{@Library('pipelines-lib') _}}
           basicDeclarative {
           {{     p4view = """\\}}
           {{     //depot/foo/bar/... //jenkins-{color:#de350b}${JOB_NAME}{color}/...}}
           {{     """}}
           {{}}}

          results in errors like:

          {{... p4 client -o jenkins-pipelines-lib-test +}}
           {{... p4 client -i +}}
           {{P4: Unable to setup workspace: com.perforce.p4java.exception.RequestException: Error in client specification.}}
           {{Mapping '//jenkins-null/...' is not under '//jenkins-pipelines-lib-test/...'.}}

          note the {color:#00875a}workspace name{color} is expanded properly but the {color:#de350b}view mapping{color} is not

           



          many edits to try and fix formatting - preformatted/monospace does not work well with curly braces
          New: similar to JENKINS-50393 but as a global declarative shared library

          I have a pipelines-lib/vars/basicDeclarative.groovy file with contents like:

          {{def call(body) {}}
               def config = [:]
               body.resolveStrategy = Closure.DELEGATE_FIRST
               body.delegate = config
               body()
               pipeline {
                   ...
                   stages {
                       stage("Checkout") {
                           steps {
                               checkout perforce(
                                   ...
                                   workspace: manualSpec(
                                       ...
                                       name: 'jenkins-{color:#00875a}${JOB_NAME}{color}',
                                       ...
                                       spec: clientSpec(
                                           view: config.p4view
                                           ...
                                       )
                                   ...
                                   )
                               ...
                               )
                          }
                      }
                  }
              }
           {{}}}

          that when called with a Jenkinsfile script like:

          {{#!groovy}}
           {{@Library('pipelines-lib') _}}
           basicDeclarative {
              p4view = """\
          {{    //depot/foo/bar/... //jenkins-{color:#de350b}${JOB_NAME}{color}/...}}
           {{    """}}
           {{}}}

          results in errors like:

          {{... p4 client -o jenkins-pipelines-lib-test +}}
           {{... p4 client -i +}}
           {{P4: Unable to setup workspace: com.perforce.p4java.exception.RequestException: Error in client specification.}}
           {{Mapping '//jenkins-null/...' is not under '//jenkins-pipelines-lib-test/...'.}}

          note the {color:#00875a}workspace name{color} is expanded properly but the {color:#de350b}view mapping{color} is not

           



          many edits to try and fix formatting - preformatted/monospace does not work well with curly braces
          Daniel Hsueh made changes -
          Description Original: similar to JENKINS-50393 but as a global declarative shared library

          I have a pipelines-lib/vars/basicDeclarative.groovy file with contents like:

          {{def call(body) {}}
               def config = [:]
               body.resolveStrategy = Closure.DELEGATE_FIRST
               body.delegate = config
               body()
               pipeline {
                   ...
                   stages {
                       stage("Checkout") {
                           steps {
                               checkout perforce(
                                   ...
                                   workspace: manualSpec(
                                       ...
                                       name: 'jenkins-{color:#00875a}${JOB_NAME}{color}',
                                       ...
                                       spec: clientSpec(
                                           view: config.p4view
                                           ...
                                       )
                                   ...
                                   )
                               ...
                               )
                          }
                      }
                  }
              }
           {{}}}

          that when called with a Jenkinsfile script like:

          {{#!groovy}}
           {{@Library('pipelines-lib') _}}
           basicDeclarative {
              p4view = """\
          {{    //depot/foo/bar/... //jenkins-{color:#de350b}${JOB_NAME}{color}/...}}
           {{    """}}
           {{}}}

          results in errors like:

          {{... p4 client -o jenkins-pipelines-lib-test +}}
           {{... p4 client -i +}}
           {{P4: Unable to setup workspace: com.perforce.p4java.exception.RequestException: Error in client specification.}}
           {{Mapping '//jenkins-null/...' is not under '//jenkins-pipelines-lib-test/...'.}}

          note the {color:#00875a}workspace name{color} is expanded properly but the {color:#de350b}view mapping{color} is not

           



          many edits to try and fix formatting - preformatted/monospace does not work well with curly braces
          New: similar to JENKINS-50393 but as a global declarative shared library

          I have a pipelines-lib/vars/basicDeclarative.groovy file with contents like:

          {{def call(body) {}}
               def config = [:]
               body.resolveStrategy = Closure.DELEGATE_FIRST
               body.delegate = config
               body()
               pipeline {
                   ...
                   stages {
                       stage("Checkout") {
                           steps {
                               checkout perforce(
                                   ...
                                   workspace: manualSpec(
                                       ...
                                       name: 'jenkins-{color:#00875a}${JOB_NAME}{color}',
                                       ...
                                       spec: clientSpec(
                                           view: config.p4view
                                           ...
                                       )
                                   ...
                                   )
                               ...
                               )
                          }
                      }
                  }
              }
           {{}}}

          that when called with a Jenkinsfile script like:

          {{#!groovy}}
           {{@Library('pipelines-lib') _}}
           basicDeclarative {
               p4view = """\
           {{    //depot/foo/bar/... //jenkins-{color:#de350b}${JOB_NAME}{color}/...}}
           {{    """}}
           {{}}}

          results in errors like:

          {{... p4 client -o jenkins-pipelines-lib-test +}}
           {{... p4 client -i +}}
           {{P4: Unable to setup workspace: com.perforce.p4java.exception.RequestException: Error in client specification.}}
           {{Mapping '//jenkins-{color:#de350b}null{color}/...' is not under '//jenkins-{color:#00875a}pipelines-lib-test{color}/...'.}}

          note the {color:#00875a}workspace name{color} is expanded properly but the {color:#de350b}view mapping{color} is not

           



          many edits to try and fix formatting - preformatted/monospace does not work well with curly braces
          Paul Allen made changes -
          Labels Original: environment-variables pipeline New: P4_VERIFY environment-variables pipeline

          Paul Allen added a comment -

          Have you tried using single quotes for the workspace view as double quotes are expanded by Groovy and not the plugin.

          e.g.

           p4view = '''\
              //depot/foo/bar/... //jenkins-${JOB_NAME}/...
           '''

          Paul Allen added a comment - Have you tried using single quotes for the workspace view as double quotes are expanded by Groovy and not the plugin. e.g. p4view = '''\     //depot/foo/bar/... //jenkins-${JOB_NAME}/...  '''
          Paul Allen made changes -
          Labels Original: P4_VERIFY environment-variables pipeline New: P4_SUPPORT environment-variables pipeline

            p4kevin Kevin Williamson
            dchsueh Daniel Hsueh
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved: