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

Offer "Build with Parameters" on first build when declarative Jenkinsfile found

    XMLWordPrintable

    Details

    • Similar Issues:

      Description

      By default a branch project will automatically run the first build, with no parameters, so params will just pick up any default values. You have the option to suppress the automatic first build, but this does not give you any way to enter parameters for it (at least in the UI; perhaps possible via CLI/REST), since Jenkins does not know what the parameters are going to be until it starts running. But in the case of Declarative we could in principle inspect the Jenkinsfile when the branch project is created (via SCMFileSystem) and determine the parameter definitions by static parsing without actually running.

      More generally, if Declarative is in use and there are properties, we could set all the project properties when the branch project is created, even if the first build is run automatically. (Though I would suggest that the automatic first build should be automatically suppressed if there is a ParametersDefinitionProperty.)

        Attachments

          Issue Links

            Activity

            jglick Jesse Glick created issue -
            jglick Jesse Glick made changes -
            Field Original Value New Value
            Link This issue relates to JENKINS-41865 [ JENKINS-41865 ]
            jglick Jesse Glick made changes -
            Link This issue is duplicated by JENKINS-42922 [ JENKINS-42922 ]
            abayer Andrew Bayer made changes -
            Link This issue is duplicated by JENKINS-40241 [ JENKINS-40241 ]
            jglick Jesse Glick made changes -
            Link This issue is duplicated by JENKINS-45454 [ JENKINS-45454 ]
            childnode Marcel 'childNo͡.de' Trautwein made changes -
            Link This issue is duplicated by JENKINS-42922 [ JENKINS-42922 ]
            childnode Marcel 'childNo͡.de' Trautwein made changes -
            Link This issue duplicates JENKINS-40574 [ JENKINS-40574 ]
            abayer Andrew Bayer made changes -
            Link This issue is duplicated by JENKINS-40574 [ JENKINS-40574 ]
            abayer Andrew Bayer made changes -
            Link This issue is duplicated by JENKINS-46594 [ JENKINS-46594 ]
            darwinjs Darwin Sanoy made changes -
            Comment [ Parameters prompting is also skipped when you simply run a declarative pipeline (that contains a parameters block) from the classic UI.  Since everything else about Declarative Pipelines seems to work in Classic UI, I'm thinking this is a bug.

            Perhaps the two are related since "Scan Multibranch Pipeline Now" is only available on Classic UI ? ]
            jamesdumay James Dumay made changes -
            Remote Link This issue links to "CloudBees Internal OSS-2277 (Web Link)" [ 18360 ]
            jamesdumay James Dumay made changes -
            Remote Link This issue links to "CloudBees Internal OSS-2103 (Web Link)" [ 18419 ]
            jglick Jesse Glick made changes -
            Link This issue relates to JENKINS-49079 [ JENKINS-49079 ]
            jglick Jesse Glick made changes -
            Remote Link This issue links to "CloudBees Internal OSS-2103 (Web Link)" [ 18419 ]
            jglick Jesse Glick made changes -
            Remote Link This issue links to "CloudBees Internal OSS-2277 (Web Link)" [ 18360 ]
            jglick Jesse Glick made changes -
            Remote Link This issue links to "CloudBees-internal CD-559 (Web Link)" [ 20776 ]
            cloudbees CloudBees Inc. made changes -
            Remote Link This issue links to "CloudBees Internal OSS-2103 (Web Link)" [ 20783 ]
            jglick Jesse Glick made changes -
            Labels multibranch
            rodrigc Craig Rodrigues made changes -
            Link This issue is related to JENKINS-52939 [ JENKINS-52939 ]
            slonopotamusorama Marat Radchenko made changes -
            Link This issue duplicates JENKINS-40574 [ JENKINS-40574 ]
            abayer Andrew Bayer made changes -
            Assignee Andrew Bayer [ abayer ]
            chunyanpei ChunyanPei made changes -
            Comment [ Have faced the same issue that:
            I have 50+ jobs, all of them are pipeline jobs with parameters, and the Jenkins is deployed as code so every time when the Jenkins is deployed, the jobs' first running will be failed.
            What I planed to do is to create a job to run all the jobs once (actually you can define a list of jobs to run)
            {code:java}
            def allJobNames() {
              job_list=[]
              Jenkins.instance.getAllItems(AbstractItem.class).each {
                job_list.add(0, it.fullName);
            }
              job_list.remove("currect_job") /*remove the current job name from list otherwise it will loop forever*/
              return job_list
            }

            pipeline {
                agent {
                      kubernetes {
                          yaml '''
            apiVersion: v1
            kind: Pod
            spec:
              containers:
              - name: jnlp
                image: xxxxx
              - name: container
                image: yyyyy
                tty: true
              nodeSelector:
                zzzzz
            ''' }
                }
             stages {
                    stage('Clean the workspace') {
                        steps{
                        container("container") {
                          script {
                            deleteDir()
                          }
                          }
                          }
                    }
                    stage('Run all the jobs') {
                        steps {
                            container("container") {
                                 script {
                                    job_list = allJobNames()
                                    println(job_list)
                                    single_job = [:]
                                    job_list.each{
                                        single_job["$it"]={
                                        build job: "$it"}
                                    }
                                    parallel single_job
                                    }
                            }
                        }
                    }
                }
            }
            {code} ]
            oshmyrko Oleksandr made changes -
            Link This issue duplicates JENKINS-50365 [ JENKINS-50365 ]

              People

              Assignee:
              Unassigned Unassigned
              Reporter:
              jglick Jesse Glick
              Votes:
              145 Vote for this issue
              Watchers:
              155 Start watching this issue

                Dates

                Created:
                Updated: