# Remove/Delete build parameters once used

**URL:** <https://community.jenkins.io/t/remove-delete-build-parameters-once-used/8011>\
**Category:** Ask a question\
**Tags:** jenkinsfile, pipeline\
**Created:** [June 14, 2023, 1:18pm UTC](https://community.jenkins.io/t/remove-delete-build-parameters-once-used/8011 "2023-06-14T13:18:33Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![pmon](https://avatars.discourse-cdn.com/v4/letter/p/c4cdca/32.png) [@pmon](https://community.jenkins.io/u/pmon)\
**Post date:** [June 14, 2023, 1:18pm UTC](https://community.jenkins.io/t/remove-delete-build-parameters-once-used/8011/1 "2023-06-14T13:18:33Z")

</div>

We have some multi-branch pipeline jobs which are set up via Jenkinsfiles.  
When we were setting up the jobs, we used build parameters to parameterize the build.

Now this is not relevant anymore, so we removed the parameters from the Jenkinsfile.  
But they are still visible via the UI and the _“build”_ button is still a _“build with parameters”_ button.

The configuration of each branch only lists the parameters.  
But they cannot be deleted and the _“this build is parameterized”_ checkbox is activated but greyed out.

Is there any way to remove these old parameters?

THX 🙂

---

<div class="post-metadata">

**Author:** ![VladyslavKovalov](https://dub1.discourse-cdn.com/flex013/user_avatar/community.jenkins.io/vladyslavkovalov/32/4473_2.png) [@VladyslavKovalov](https://community.jenkins.io/u/VladyslavKovalov)\
**Post date:** [June 15, 2023, 12:45pm UTC](https://community.jenkins.io/t/remove-delete-build-parameters-once-used/8011/2 "2023-06-15T12:45:16Z")

</div>

@pmon try to add empty parameters notation to your Jenkinsfile like this:

```auto
properties([
  parameters([])
])

```

If it will not help you have to use groovy from scripted console to manually obtain job’s object and remove parameters from it. I can just provide an example how to obtain a job, but I have not experience with code which allows to remove parameters from job. Here is how we you can use it:

```auto
import jenkins.model.Jenkins

def jobName = "your-multibranch-pipeline-name"

def jenkins = Jenkins.instance

def job = jenkins.getItemByFullName(jobName)
if (job == null) {
    println("Could not find the Multibranch Pipeline: $jobName")
    return
}
if (pipeline instanceof org.jenkinsci.plugins.workflow.multibranch.WorkflowMultiBranchProject) {
    def branchProjects = pipeline.getItems()
    branchProjects.each { branch ->
        // Do your staff
    }
}

```

---

<div class="post-metadata">

**Author:** ![pmon](https://avatars.discourse-cdn.com/v4/letter/p/c4cdca/32.png) [@pmon](https://community.jenkins.io/u/pmon)\
**Post date:** [June 15, 2023, 1:20pm UTC](https://community.jenkins.io/t/remove-delete-build-parameters-once-used/8011/3 "2023-06-15T13:20:18Z")

</div>

THX a lot for your instant reply.  
It kind of helped, please see the screenshot below.

![image](https://europe1.discourse-cdn.com/flex013/uploads/jenkins/original/2X/2/2cffd090530fdbd71fb60d4ac82febf8a04c8f05.png)

---

<div class="post-metadata">

**Author:** ![VladyslavKovalov](https://dub1.discourse-cdn.com/flex013/user_avatar/community.jenkins.io/vladyslavkovalov/32/4473_2.png) [@VladyslavKovalov](https://community.jenkins.io/u/VladyslavKovalov)\
**Post date:** [June 15, 2023, 1:53pm UTC](https://community.jenkins.io/t/remove-delete-build-parameters-once-used/8011/4 "2023-06-15T13:53:18Z")

</div>

@pmon nice to hear. It seems, like complete solution can be achieved by groovy way only. Jenkins job object has. `removeProperty​(JobProperty jobProperty)` method that allows to remove some job properties (for example build discarder, periodic trigger, parameters, etc.). So you should find parameters class and combine this wit code I’ve sent above. It will remove parameters completely. Here is javadoc link: [https://javadoc.jenkins.io/plugin/workflow-job/org/jenkinsci/plugins/workflow/job/WorkflowJob.html#removeProperty(hudson.model.JobProperty)](https://javadoc.jenkins.io/plugin/workflow-job/org/jenkinsci/plugins/workflow/job/WorkflowJob.html#removeProperty(hudson.model.JobProperty))
