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

Detemine parameters before running job

    Details

    • Similar Issues:

      Description

      When job parameters are defined in the Jenkinsfile/script, Jenkins doesn't know what parameters are required until the job is run. You see the problem? to run the job you need the parameters. To know what parameters are required to run the job.

      This is most visible with a new branch in multibranch jobs (there have been complaints).

      In scope:

      • Investigate if it is possible to know without executing what parameters will be required
      • If possible, an api to return such parameters

      This could span general pipeline script, or pipeline model.

        Attachments

          Issue Links

            Activity

            michaelneale Michael Neale created issue -
            jamesdumay James Dumay made changes -
            Field Original Value New Value
            Epic Link JENKINS-36291 [ 172300 ]
            Hide
            abayer Andrew Bayer added a comment - - edited

            So I'm only thinking in terms of Declarative for the moment, because, well, viability.

            The first thing coming to mind is to have the logic that takes the parameters section check if each parameter is already defined on the job at that point (with the same type too), and if not, add an environment variable for the parameter name using the default value for the parameter. i.e., the first run still would not prompt for parameters, but it would act as if the default parameters had been specified.

            Show
            abayer Andrew Bayer added a comment - - edited So I'm only thinking in terms of Declarative for the moment, because, well, viability. The first thing coming to mind is to have the logic that takes the parameters section check if each parameter is already defined on the job at that point (with the same type too), and if not, add an environment variable for the parameter name using the default value for the parameter. i.e., the first run still would not prompt for parameters, but it would act as if the default parameters had been specified.
            Hide
            abayer Andrew Bayer added a comment -

            Also - the editor knows the parameters defined in the Jenkinsfile (even if the job isn't run) since it's parsing the Jenkinsfile. Not sure how we could get this to Blue Ocean for kicking off builds without also doing a Jenkinsfile parse there too...

            Show
            abayer Andrew Bayer added a comment - Also - the editor knows the parameters defined in the Jenkinsfile (even if the job isn't run) since it's parsing the Jenkinsfile. Not sure how we could get this to Blue Ocean for kicking off builds without also doing a Jenkinsfile parse there too...
            Hide
            abayer Andrew Bayer added a comment -

            So since https://github.com/jenkinsci/workflow-cps-plugin/pull/60 landed, there's a new global variable, params. If you do a properties call adding parameters (let's say we add one named foo) and then do params.foo afterwards in the same run, you'll get the default value for foo, assuming one was defined. It's still not possible to prompt the user for parameters before having the build run with properties, but at least you can prevent the build from breaking due to undefined parameters this way. Thoughts as to whether that's sufficient? Should we also add it to the env global variable?

            Show
            abayer Andrew Bayer added a comment - So since https://github.com/jenkinsci/workflow-cps-plugin/pull/60 landed, there's a new global variable, params . If you do a properties call adding parameters (let's say we add one named foo ) and then do params.foo afterwards in the same run, you'll get the default value for foo , assuming one was defined. It's still not possible to prompt the user for parameters before having the build run with properties , but at least you can prevent the build from breaking due to undefined parameters this way. Thoughts as to whether that's sufficient? Should we also add it to the env global variable?
            michaelneale Michael Neale made changes -
            Description When job parameters are defined in the Jenkinsfile/script, Jenkins doesn't know what parameters are required until the job is run. You see the problem? to run the job you need the parameters. To know what parameters are required to run the job.

            In scope:
            * Investigate if it is possible to know without executing what parameters will be required
            * If possible, an api to return such parameters

            This could span general pipeline script, or pipeline model.
            When job parameters are defined in the Jenkinsfile/script, Jenkins doesn't know what parameters are required until the job is run. You see the problem? to run the job you need the parameters. To know what parameters are required to run the job.

            This is most visible with a new branch in multibranch jobs (there have been complaints).

            In scope:
            * Investigate if it is possible to know without executing what parameters will be required
            * If possible, an api to return such parameters

            This could span general pipeline script, or pipeline model.
            Hide
            michaelneale Michael Neale added a comment - - edited

            hrm ok.. this may have to sit in the backlog for a while.

            So whilst PR#60 helps with error message, it is still a broken UX that pops up for the wrong things... so we may need to park this for some future work to make it work out ahead of time what the params are via some kind of evaluation... I don't think this is a problem specific to declarative, and perhaps declarative shouldn't solve it?

            EDIT: I am prepared to park this and then let things come in as bug reports... more thought is needed ...

            Show
            michaelneale Michael Neale added a comment - - edited hrm ok.. this may have to sit in the backlog for a while. So whilst PR#60 helps with error message, it is still a broken UX that pops up for the wrong things... so we may need to park this for some future work to make it work out ahead of time what the params are via some kind of evaluation... I don't think this is a problem specific to declarative, and perhaps declarative shouldn't solve it? EDIT: I am prepared to park this and then let things come in as bug reports... more thought is needed ...
            abayer Andrew Bayer made changes -
            Link This issue relates to JENKINS-40631 [ JENKINS-40631 ]
            Hide
            imod Dominik Bartholdi added a comment -

            Andrew Bayer although the params really works well, I would still add them to env too - thats just what people are used to.

            Show
            imod Dominik Bartholdi added a comment - Andrew Bayer although the params really works well, I would still add them to env too - thats just what people are used to.
            jamesdumay James Dumay made changes -
            Priority Major [ 3 ] Minor [ 4 ]
            Show
            jamesdumay James Dumay added a comment - Vivek Pandey https://github.com/jenkinsci/blueocean-plugin/pull/669/files#r94509252
            Hide
            vivek Vivek Pandey added a comment -

            Andrew Bayer params.foo will give it's default value, how about type? Can we get type value without executing a run of the script?

            Show
            vivek Vivek Pandey added a comment - Andrew Bayer params.foo will give it's default value, how about type? Can we get type value without executing a run of the script?
            jamesdumay James Dumay made changes -
            Priority Minor [ 4 ] Major [ 3 ]
            jamesdumay James Dumay made changes -
            Sprint post-release [ 181 ]
            jamesdumay James Dumay made changes -
            Rank Ranked higher
            jamesdumay James Dumay made changes -
            Sprint post-release [ 181 ] 1.1 [ 251 ]
            Hide
            jamesdumay James Dumay added a comment -

            This came up in discussion with a CB customer (for Script, but I was discussing that this was more viable to do in Declarative). Apart from schedule, what seems to be the blocker here?

            Show
            jamesdumay James Dumay added a comment - This came up in discussion with a CB customer (for Script, but I was discussing that this was more viable to do in Declarative). Apart from schedule, what seems to be the blocker here?
            jamesdumay James Dumay made changes -
            Rank Ranked higher
            jamesdumay James Dumay made changes -
            Priority Major [ 3 ] Critical [ 2 ]
            jamesdumay James Dumay made changes -
            Rank Ranked higher
            jamesdumay James Dumay made changes -
            Rank Ranked higher
            jamesdumay James Dumay made changes -
            Rank Ranked lower
            jamesdumay James Dumay made changes -
            Sprint Blue Ocean up next [ 251 ]
            jamesdumay James Dumay made changes -
            Rank Ranked lower
            abayer Andrew Bayer made changes -
            Link This issue duplicates JENKINS-41929 [ JENKINS-41929 ]
            abayer Andrew Bayer made changes -
            Status Open [ 1 ] Resolved [ 5 ]
            Resolution Duplicate [ 3 ]
            Hide
            benjigoldberg Benjamin Goldberg added a comment -

            This is marked as resolved, but by what? Is there an open PR somewhere we can look at? Would love to see this feature in our installation of Jenkins and wondering if its available in the latest release.

            Show
            benjigoldberg Benjamin Goldberg added a comment - This is marked as resolved, but by what? Is there an open PR somewhere we can look at? Would love to see this feature in our installation of Jenkins and wondering if its available in the latest release.
            Hide
            jamesdumay James Dumay added a comment -

            It's duplicated. See the linked tickets for where this is really tracked.

            Show
            jamesdumay James Dumay added a comment - It's duplicated. See the linked tickets for where this is really tracked.
            Hide
            benjigoldberg Benjamin Goldberg added a comment -

            James Dumay I clicked through a number of associated tickets (many of which are duplicated themselves) and I am unable to find the PR that resolves this issue. Any chance we could add the link here as well?

            Show
            benjigoldberg Benjamin Goldberg added a comment - James Dumay I clicked through a number of associated tickets (many of which are duplicated themselves) and I am unable to find the PR that resolves this issue. Any chance we could add the link here as well?
            Hide
            michaelneale Michael Neale added a comment -

            Benjamin Goldberg https://issues.jenkins-ci.org/browse/JENKINS-41929 is ticket. There is no PR I am aware of that fixes this. Pipeline being scripted by default (outside of `pipeline`) makes this impossible in a sense (ie need to execute it before you know what parameters are used). Declarative has a chance that this can be elided pre-flight. 

            Show
            michaelneale Michael Neale added a comment - Benjamin Goldberg https://issues.jenkins-ci.org/browse/JENKINS-41929  is ticket. There is no PR I am aware of that fixes this. Pipeline being scripted by default (outside of `pipeline`) makes this impossible in a sense (ie need to execute it before you know what parameters are used). Declarative has a chance that this can be elided pre-flight. 
            Hide
            bitwiseman Liam Newman added a comment -

            Bulk closing resolved issues.

            Show
            bitwiseman Liam Newman added a comment - Bulk closing resolved issues.
            bitwiseman Liam Newman made changes -
            Status Resolved [ 5 ] Closed [ 6 ]

              People

              • Assignee:
                abayer Andrew Bayer
                Reporter:
                michaelneale Michael Neale
              • Votes:
                4 Vote for this issue
                Watchers:
                17 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved: