# How to convert freestyle "Current build parameters" setting to pipeline?

**URL:** <https://community.jenkins.io/t/how-to-convert-freestyle-current-build-parameters-setting-to-pipeline/30221>\
**Category:** Using Jenkins\
**Created:** [April 23, 2025, 8:28pm UTC](https://community.jenkins.io/t/how-to-convert-freestyle-current-build-parameters-setting-to-pipeline/30221 "2025-04-23T20:28:53Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![hogarth](https://avatars.discourse-cdn.com/v4/letter/h/a9a28c/32.png) [@hogarth](https://community.jenkins.io/u/hogarth)\
**Post date:** [April 23, 2025, 8:28pm UTC](https://community.jenkins.io/t/how-to-convert-freestyle-current-build-parameters-setting-to-pipeline/30221/1 "2025-04-23T20:28:53Z")

</div>

I have a parameterized freestyle project that uses the Parameterized Trigger plugin with the “Current build parameters” setting to pass all of the job’s current parameters to any triggered jobs. I have converted this freestyle project to a declarative pipeline, and I want to enable this “Current build parameters” behavior in the new pipeline so all jobs triggered using the build command share the same parameters as the parent pipeline. However, I can’t really find any pipeline examples that utilize the “Current build parameters” option. What is the correct way to set up a pipeline so it makes all triggered jobs use the same set of parameters?

---

<div class="post-metadata">

**Author:** ![Artalus](https://dub1.discourse-cdn.com/flex013/user_avatar/community.jenkins.io/artalus/32/11413_2.png) [@Artalus](https://community.jenkins.io/u/Artalus)\
**Post date:** [April 24, 2025, 1:18pm UTC](https://community.jenkins.io/t/how-to-convert-freestyle-current-build-parameters-setting-to-pipeline/30221/2 "2025-04-24T13:18:58Z")

</div>

I am not sure if there is any automation to magically pass all of the current Pipeline build parameters to any and all jobs triggered by it. But you can iterate over the parameters and construct new data from it on your own.

Let’s say you have a pipeline with **Choice parameter `FOO`** , of values `1,2,3` **Boolean parameter `BAR`** unchecked by default, and **Password parameter `BAZ`** empty by default, that just prints whatever is passed to it:

```auto
params.each { k, v ->
    println "${k.class} / ${v.class}"
    println "$k / $v"
}

```

If I trigger this pipeline manually with `FOO` selected to 2, `BAR` unchecked and `BAZ` changed to 12345, I get

```plaintext
16:48:45 class java.lang.String / class java.lang.Boolean
16:48:46 BAR / false
16:48:46 class java.lang.String / class java.lang.String
16:48:46 FOO / 2
16:48:46 class java.lang.String / class hudson.util.Secret
16:48:46 BAZ / 12345

```

Now let’s have a second pipeline with **String parameters `BAR`, `XXX`** that would trigger the first one with everything it has plus some additional parameters:

```auto
build(
    job: 'sandbox/tmp-params-child',
    parameters: params.collect { k, v ->
        string(name: k, value: v)
    } + [
        string(name: 'FOO', value: '3')
    ]
)

```

> Note that if you’re using Declarative pipelines, you will probably need to do this wrapped inside a `script { }` step.

Despite different types in the original pipeline, here I pass everything as `string()`s. Most of the parameters often used in Jenkins jobs may be considered “derivatives of a string”, and usually are constructed from strings. When I run it with `BAR=true, XXX=ccc`, Jenkins will notify me about a type mismatch (only for `BAR` though, somehow – but a couple years back we didn’t have even that), and complete the build just fine:

```plaintext
16:58:58 Scheduling project: sandbox » tmp-params-child
16:58:58 The parameter 'BAR' did not have the type expected by sandbox » tmp-params-child. Converting to Boolean Parameter.
16:59:05 Starting building: sandbox » tmp-params-child #6
16:59:07 Build sandbox » tmp-params-child #6 completed: SUCCESS

```

Looking in the triggered job’s build, we can see that the types are right and it have actually accepted the extra parameter:

```plaintext
16:59:05 class java.lang.String / class java.lang.Boolean
16:59:06 BAR / true
16:59:06 class java.lang.String / class java.lang.String
16:59:06 FOO / 3
16:59:06 class java.lang.String / class java.lang.String
16:59:06 XXX / ccc
16:59:07 class java.lang.String / class hudson.util.Secret
16:59:07 BAZ / 

```

If I were to run it with some invalid value for `FOO`, Jenkins would complain about it without actually triggering the second job:

```plaintext
16:54:59 Scheduling project: sandbox » tmp-params-child
16:54:59 [Pipeline] End of Pipeline
16:54:59 ERROR: Invalid parameter value: (StringParameterValue) FOO='true'

```

* * *

If your pipelines operate on more complex parameters, and you’d have to maintain the types already on the calling side, you would probably need to make a utility function (and consider putting it into a shared library, so it could be reused between jobs) that would look at the type of your inputs – via `instanceof` for example – and construct elements of different types for `parameters` list.

```java
...
parameters: params.collect { k, v -> parameterize(k, v) }
...
def parameterize(name, value) {
  if (value instanceof String) {
    return string(name: name, value: value)
  } else if ...

```

---

<div class="post-metadata">

**Author:** ![hogarth](https://avatars.discourse-cdn.com/v4/letter/h/a9a28c/32.png) [@hogarth](https://community.jenkins.io/u/hogarth)\
**Post date:** [April 25, 2025, 1:49pm UTC](https://community.jenkins.io/t/how-to-convert-freestyle-current-build-parameters-setting-to-pipeline/30221/3 "2025-04-25T13:49:57Z")

</div>

This seems to work. However, I did get tripped up by the parameters for the Jenkins Subversion Plugin. The “List Subversion Tags” parameter provided by that plugin will generate parameter entries in params, but they’re always NULL. You have to instead reference environment variables created by the plugin.

Thanks for the assistance.
