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

Pipeline editor does not recognize agent { label "labelName" } without node

    • Blue Ocean - Candidates

      Quoting from https://jenkins.io/doc/book/pipeline/syntax/

      agent { node { label 'labelName' } } behaves the same as agent { label 'labelName' }, but node allows for additional options (such as customWorkspace).

      If I use the longer syntax, then the Blue Ocean Pipeline Editor shows the label in "Pipeline Settings". However, if I use the shorter syntax, then the "Agent" drop-down list just shows "Select an option". The UI should be the same in either case.

      Test with Jenkinsfile:

      pipeline {
        agent {
          label 'labelName'
        }
        stages {
          stage('Build') {
            steps {
              sleep 1
            }
          }
        }
      }
      

      vs.

      pipeline {
        agent {
          node {
            label 'labelName'
          }
        }
        stages {
          stage('Build') {
            steps {
              sleep 1
            }
          }
        }
      }
      

      IMHO, it would be OK to silently convert one syntax to the other.

          [JENKINS-48092] Pipeline editor does not recognize agent { label "labelName" } without node

          Kalle Niemitalo created issue -
          Kalle Niemitalo made changes -
          Description Original: Quoting from [https://jenkins.io/doc/book/pipeline/syntax/]

          {quote}
          agent \{ node \{ label 'labelName' } } behaves the same as agent \{ label 'labelName' }, but node allows for additional options (such as customWorkspace).
          {quote}

          If I use the longer syntax, then the Blue Ocean Pipeline Editor shows the label in "Pipeline Settings". However, if I use the shorter syntax, then the "Agent" combo box just shows "Select an option". The UI should be the same in either case.

          Test with Jenkinsfile:

          {code}
          pipeline {
            agent {
              label 'labelName'
            }
            stages {
              stage('Build') {
                steps {
                  sleep 1
                }
              }
            }
          }
          {code}

          vs.

          {code}
          pipeline {
            agent {
              node {
                label 'labelName'
              }
            }
            stages {
              stage('Build') {
                steps {
                  sleep 1
                }
              }
            }
          }
          {code}

          IMHO, it would be OK to silently convert one syntax to the other.
          New: Quoting from [https://jenkins.io/doc/book/pipeline/syntax/]

          {quote}
          agent \{ node \{ label 'labelName' } } behaves the same as agent \{ label 'labelName' }, but node allows for additional options (such as customWorkspace).
          {quote}

          If I use the longer syntax, then the Blue Ocean Pipeline Editor shows the label in "Pipeline Settings". However, if I use the shorter syntax, then the "Agent" drop-down list just shows "Select an option". The UI should be the same in either case.

          Test with Jenkinsfile:

          {code}
          pipeline {
            agent {
              label 'labelName'
            }
            stages {
              stage('Build') {
                steps {
                  sleep 1
                }
              }
            }
          }
          {code}

          vs.

          {code}
          pipeline {
            agent {
              node {
                label 'labelName'
              }
            }
            stages {
              stage('Build') {
                steps {
                  sleep 1
                }
              }
            }
          }
          {code}

          IMHO, it would be OK to silently convert one syntax to the other.

          James Dumay added a comment -

          Thanks for the report kon

          James Dumay added a comment - Thanks for the report kon
          James Dumay made changes -
          Epic Link New: JENKINS-36291 [ 172300 ]
          James Dumay made changes -
          Sprint New: Blue Ocean 1.4 - beta 4 [ 441 ]

          Karl Shultz added a comment -

          Testing notes:
          For the immediate near term, a one-time manual confirmation that this is working would probably suffice.

          jamesdumay, would it be worthwhile to start compiling a list of things like this for inclusion into an eventual automated test? Something like a reference Jenkinsfile (or multiples), where we could make sure that the editor successfully reads/writes a Jenkinsfile which has a "greatest hits" of issues?

          Rough example:

          pipeline {
              agent any
              stages {
                  stage('JENKINS-48092 Tests short-form agent labels') {
                      agent label 'JENKINS-48092' 
                      steps {
                          echo "Short-form agent labels should work"
                      }
                  }
                  stage ('JENKINS-43016 Tests blank agent labels') {
                      agent label ' '
                      steps {
                          echo "Blank labels are allowed
                      }
                  }
              }
          }
          

          Karl Shultz added a comment - Testing notes: For the immediate near term, a one-time manual confirmation that this is working would probably suffice. jamesdumay , would it be worthwhile to start compiling a list of things like this for inclusion into an eventual automated test? Something like a reference Jenkinsfile (or multiples), where we could make sure that the editor successfully reads/writes a Jenkinsfile which has a "greatest hits" of issues? Rough example: pipeline { agent any stages { stage('JENKINS-48092 Tests short-form agent labels') { agent label 'JENKINS-48092' steps { echo "Short-form agent labels should work" } } stage ('JENKINS-43016 Tests blank agent labels') { agent label ' ' steps { echo "Blank labels are allowed } } } }
          Karl Shultz made changes -
          Labels New: testing-notes-reviewed
          big ming made changes -
          Rank New: Ranked higher
          big ming made changes -
          Rank New: Ranked lower

            Unassigned Unassigned
            kon Kalle Niemitalo
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated: