re: Jenkins Pipelines and their dirty secrets 2. VIEW POST


I was new to Jenkisfiles. I'm using scripted pipeline and this posted helped me a lot, so thanks.

There is still an issue I'm trying to work around and had no luck so far.

As you stated "when you can't set your parameters yet, your job basically just starts running with its default parameters. This can be bad, as you may not want that."

I've used you're trick to avoid this but tbh in my case it doesn't make much of a diference because they will still be set the second time... and on a 3rd run it will still have the parameters from the second run...

In my case this is important because I'm trying to run 3 diferent tools that share some parameters but differ on others...

Using input and a switch case I can add those in later... what I do is to set the parameters they all share in an initParams var

so I do:

props = []
initParams = [
        description: "Please specify which tool to run.",
        name: "tool",
        choices: "tool1\ntool2\ntool3"

tool1Params = [ .... ]

switch (params.tool) {
    case "tool1":
        extraParams = input( id: "extraParams",
            message: "Tool 1 was selected,  please provide extra params:",
            parameters: tool1params
        initParams +=  tool1params


with this in the first run, I sue "build now" and now "Build with parameters is available" showing only the initParams and moving to a input asking for the rest...

The problem is if I go to "Parameters" it still tells me I've only used the intParams... and I want to be able to see all there...

If I don't to the workaround it will show all args there.... but if I run it again for "tool2" it will list always the parameters used in the first run...

Sadly jenkins docs aren't the best... specially for Jenkisfiles and scripted pipeline so maybe you know another trick to accomplish this or tell me I'm doing something very wrong :P


Replying to myself... from what I was able to google "properpties" can only be used once in the Jenkinsfile and it also overwrites whatever was in the UI (if we are using it which is not my case)

So what I want is pretty much impossible to do.

All I can do is have the initial args in the properties then use input for the rest (as I do, but not attempt to set them in properties(parameters(...)) as this would simple configure the job to use whatever my first choice is.

Would be great if we could save the parms for "input" too as this offers easy visibility, but it seems it is not the case.


Hi, Is there a way, through with i can pass a value to the job and use it in the job ? I want to send the branch name from pipeline, which can be used in the job to build , is it possible?

the branch name should be available with the workspace env env.BRANCH_NAME

I have a few jobs where I use it to only allow triggered jobs if the branch is master.

if (env.BRANCH_NAME == 'master')
                H 19 * * * %param=value


Hi, I believe that BRANCH_NAME is only populated when running a multi-branch pipeline. FYI then.

code of conduct - report abuse