# Understanding default parameter value in declarative pipeline

**URL:** <https://community.jenkins.io/t/understanding-default-parameter-value-in-declarative-pipeline/8424>\
**Category:** Using Jenkins\
**Created:** [July 11, 2023, 2:07pm UTC](https://community.jenkins.io/t/understanding-default-parameter-value-in-declarative-pipeline/8424 "2023-07-11T14:07:24Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![DavidA2014](https://dub1.discourse-cdn.com/flex013/user_avatar/community.jenkins.io/davida2014/32/88_2.png) [@DavidA2014](https://community.jenkins.io/u/DavidA2014)\
**Post date:** [July 11, 2023, 2:07pm UTC](https://community.jenkins.io/t/understanding-default-parameter-value-in-declarative-pipeline/8424/1 "2023-07-11T14:07:24Z")

</div>

Hi, my declarative pipeline has several build parameters. I would like a parameter default value to be applied the first time the pipeline is run but, thereafter, the value entered by the user should become the default. Is that possible?

It seems strange that it is possible to set a parameter’s default value in the GUI Configure page, but the entered value gets overwritten by the script value the next time the job is run. How is this intended to work?

---

<div class="post-metadata">

**Author:** ![daotoan-hd](https://dub1.discourse-cdn.com/flex013/user_avatar/community.jenkins.io/daotoan-hd/32/4716_2.png) [@daotoan-hd](https://community.jenkins.io/u/daotoan-hd)\
**Post date:** [July 15, 2023, 7:33am UTC](https://community.jenkins.io/t/understanding-default-parameter-value-in-declarative-pipeline/8424/2 "2023-07-15T07:33:05Z")

</div>

Hi,  
I believe that is not supported “natively” by Jenkins

---

<div class="post-metadata">

**Author:** ![hts0000](https://avatars.discourse-cdn.com/v4/letter/h/cab0a1/32.png) [@hts0000](https://community.jenkins.io/u/hts0000)\
**Post date:** [June 19, 2024, 8:04am UTC](https://community.jenkins.io/t/understanding-default-parameter-value-in-declarative-pipeline/8424/3 "2024-06-19T08:04:40Z")

</div>

Yes you can!  
You can set your jenkinsfile like this.

```jenkinsfile
pipeline {
  parameters {
    choice(
      name: "key1",
      choices: params.key1 ? params.key1 : [""],
      description: "key1"
    )
    gitParameter(
      name: "branch",
      type: "PT_BRANCH",
      defaultValue: params.branch ? params.branch : "master",
      description: "branch",
      sortMode: "ASCENDING_SMART",
      selectedValue: "DEFAULT",
      useRepository: "git@172.16.0.17:test/.*git",
    )
  }
  ...
}

```

Hope this helps.
