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

Need to lint pipeline from UI, and also parse parameters

    XMLWordPrintable

    Details

    • Similar Issues:

      Description

      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.

        Attachments

          Issue Links

            Activity

            Hide
            rodrigc 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. 
            Show
            rodrigc 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.
            Hide
            rodrigc 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.')
                                }
                            }
                        }
                    }
            }

             

            Show
            rodrigc 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.' ) } } } } }  
            Hide
            rodrigc 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.

            Show
            rodrigc 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.
            Hide
            rodrigc 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.

             

            Show
            rodrigc 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.  
            Hide
            kzantow Keith Zantow added a comment -

            Craig Rodrigues yes, I mentioned there is a validation function already. If you load the editor, you can simply copy/paste a declarative pipeline - E.g. go to http://<jenkins-host>/blue/organizations/jenkins/pipeline-editor/ then press Ctrl-S / Cmd-S on windows/osx to get a text area to paste the pipeline into. It doesn't validate every bit of the pipeline, though, but does a good job of linting it:

            Show
            kzantow Keith Zantow added a comment - Craig Rodrigues yes, I mentioned there is a validation function already. If you load the editor, you can simply copy/paste a declarative pipeline - E.g. go to http://<jenkins-host>/blue/organizations/jenkins/pipeline-editor/ then press Ctrl-S / Cmd-S on windows/osx to get a text area to paste the pipeline into. It doesn't validate every bit of the pipeline, though, but does a good job of linting it:
            Hide
            kzantow Keith Zantow added a comment -

            I'd suggest to add a different ticket for Updating Input Parameters. It's currently a limitation of pipeline itself, nothing to do with blue ocean or jenkins ui per se.

            Show
            kzantow Keith Zantow added a comment - I'd suggest to add a different ticket for Updating Input Parameters . It's currently a limitation of pipeline itself, nothing to do with blue ocean or jenkins ui per se.

              People

              • Assignee:
                abayer Andrew Bayer
                Reporter:
                rodrigc Craig Rodrigues
              • Votes:
                0 Vote for this issue
                Watchers:
                4 Start watching this issue

                Dates

                • Created:
                  Updated: