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

Need to lint pipeline from UI, and also parse parameters

      I create a lot of pipelines where I specify the parameters inside the pipeline like this:

       

      pipeline {
          agent any;
          parameters {
              string(defaultValue: 'master',
                     description: 'SCM branch',
                     name: 'BRANCH')
          }
          stages {
              stage("Do stuff") {
                  steps {
                      sh "echo blah"
                  }
              }
          }
      } 

       

      It would be very handy if:

       

      1.  There was a way to invoke the linter for a Pipeline from the classic UI and the blueocean UI.  Right now, this method is a bit clunky to use: https://jenkins.io/doc/book/pipeline/development/#linter

      2.  It would be good if there was an option in the classic UI and blueocean UI to Reload or Update a pipeline.  If this option could lint the pipeline, and update the parameters from the pipeline into the job, that would be very useful.

          [JENKINS-52939] Need to lint pipeline from UI, and also parse parameters

          Craig Rodrigues created issue -
          Craig Rodrigues made changes -
          Description Original: I create a lot of pipelines where I specify the parameters inside the pipeline like this:

           
          {noformat}
          pipeline {
              agent any;
              parameters {
                  string(defaultValue: 'master',
                         description: 'Portworx docker tag',
                         name: 'BRANCH')
              }
              stages {
                  stage("Do stuff") {
                      steps {
                          sh "echo blah"
                      }
                  }
              }
          } {noformat}
           

          It would be very handy if:

           

          1.  There was a way to invoke the linter for a Pipeline from the classic UI and the blueocean UI.  Right now, this method is a bit clunky to use: [https://jenkins.io/doc/book/pipeline/development/#linter]

          2.  It would be good if there was an option in the classic UI and blueocean UI to *Reload* or *Update* a pipeline.  If this option could lint the pipeline, and update the parameters from the pipeline into the job, that would be very useful.
          New: I create a lot of pipelines where I specify the parameters inside the pipeline like this:

           
          {noformat}
          pipeline {
              agent any;
              parameters {
                  string(defaultValue: 'master',
                         description: 'SCM branch',
                         name: 'BRANCH')
              }
              stages {
                  stage("Do stuff") {
                      steps {
                          sh "echo blah"
                      }
                  }
              }
          } {noformat}
           

          It would be very handy if:

           

          1.  There was a way to invoke the linter for a Pipeline from the classic UI and the blueocean UI.  Right now, this method is a bit clunky to use: [https://jenkins.io/doc/book/pipeline/development/#linter]

          2.  It would be good if there was an option in the classic UI and blueocean UI to *Reload* or *Update* a pipeline.  If this option could lint the pipeline, and update the parameters from the pipeline into the job, that would be very useful.
          Craig Rodrigues made changes -
          Link New: This issue is related to JENKINS-41929 [ JENKINS-41929 ]
          Andrew Bayer made changes -
          Link New: This issue is duplicated by JENKINS-50365 [ JENKINS-50365 ]

          From IRC discussion:

          https://botbot.me/freenode/jenkins/2018-08-08/?msg=103071157&page=3

          10:31 am rodrigc In the UI for a pipeline, if I had a thing to click on like "Update" or "Reload"
          10:31 am abayer That's very intriguing.
          10:31 am rodrigc which ran the linter, and updated the parameters in the job, that would do mostly what I need
          10:31 am abayer That could maybe work.
          10:31 am Like, that seems legitimately viable.
          10:32 am abayer Hit the button, it'll get the Pipeline script (either from the job config or from SCM), validate it, update job properties (which includes parameters) based on the parsed Pipeline script…it's really plausible. 

          Craig Rodrigues added a comment - From IRC discussion: https://botbot.me/freenode/jenkins/2018-08-08/?msg=103071157&page=3 10:31 am rodrigc In the UI for a pipeline, if I had a thing to click on like "Update" or "Reload" 10:31 am abayer That's very intriguing. 10:31 am rodrigc which ran the linter, and updated the parameters in the job, that would do mostly what I need 10:31 am abayer That could maybe work. 10:31 am Like, that seems legitimately viable. 10:32 am abayer Hit the button, it'll get the Pipeline script (either from the job config or from SCM), validate it, update job properties (which includes parameters) based on the parsed Pipeline script…it's really plausible.

          A workaround for this problem is shown here: https://dev.to/pencillr/jenkins-pipelines-and-their-dirty-secrets-2

          where you can put the following stage in your pipeline:

           

          stages {
                  stage("parameterizing") {
                      steps {
                          script {
                              if ("${params.Invoke_Parameters}" == "Yes") {
                                  currentBuild.result = 'ABORTED'
                                  error('DRY RUN COMPLETED. JOB PARAMETERIZED.')
                              }
                          }
                      }
                  }
          }

           

          Craig Rodrigues added a comment - A workaround for this problem is shown here: https://dev.to/pencillr/jenkins-pipelines-and-their-dirty-secrets-2 where you can put the following stage in your pipeline:   stages { stage( "parameterizing" ) { steps { script { if ( "${params.Invoke_Parameters}" == "Yes" ) { currentBuild.result = 'ABORTED' error( 'DRY RUN COMPLETED. JOB PARAMETERIZED.' ) } } } } }  

          It would be good to fix the Jenkins and Blue Ocean UI so as to eliminate the need for this workaround.

          Craig Rodrigues added a comment - It would be good to fix the Jenkins and Blue Ocean UI so as to eliminate the need for this workaround.

          Craig Rodrigues added a comment - - edited

          It looks like the Blue Ocean Pipeline Editor has some code which calls the pipeline validation URL:

           

          https://github.com/jenkinsci/blueocean-plugin/blob/1510403599e366d124cce71232cdb3aff5423edd/blueocean-pipeline-editor/src/main/js/services/PipelineValidator.js#L115 

          It would be good if there was a way to call the functions in this code outside of the Pipeline editor.

           

          Craig Rodrigues added a comment - - edited It looks like the Blue Ocean Pipeline Editor has some code which calls the pipeline validation URL:   https://github.com/jenkinsci/blueocean-plugin/blob/1510403599e366d124cce71232cdb3aff5423edd/blueocean-pipeline-editor/src/main/js/services/PipelineValidator.js#L115   It would be good if there was a way to call the functions in this code outside of the Pipeline editor.  
          Keith Zantow made changes -
          Issue Type Original: Bug [ 1 ] New: Improvement [ 4 ]
          Keith Zantow made changes -
          Attachment New: screenshot-1.png [ 44495 ]

            Unassigned Unassigned
            rodrigc Craig Rodrigues
            Votes:
            8 Vote for this issue
            Watchers:
            14 Start watching this issue

              Created:
              Updated: