Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

JENKINS-76298 - Add default value cache to AbstractScriptableParameter#591

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Open
Jendoliver wants to merge2 commits intojenkinsci:master
base:master
Choose a base branch
Loading
fromJendoliver:fix/JENKINS-76298

Conversation

@Jendoliver
Copy link

@JendoliverJendoliver commentedNov 19, 2025
edited
Loading

This is a tentative fix forhttps://issues.jenkins.io/browse/JENKINS-76298

In a nutshell, builds that start without parameter values callAbstractScriptableParameter#getDefaultParameterValue for everyAbstractScriptableParameter in the job parameters once per everyparams read, which causes the same script to be executed over and over just to render the same value. In my case this is making first builds of multibranch pipeline jobs extremely slow once users push their new branches, as that build starts without parameters and my pipeline does a lot ofparams access at the first stage, which triggers this situation.

Testing done

You can reproduce the problem and validate my fix by following these steps:

  1. Start a local Jenkins instance
  2. Create a Pipeline: New Item -> Pipeline, doesn't need to be multibranch.
  3. Definition: Pipeline script, and use this repro pipeline:
properties([    parameters([        string(name:"STRING_PARAM",defaultValue:"default",description:"A string parameter"),        [$class:'ChoiceParameter',choiceType:'PT_CHECKBOX',description:"PARAM_1",name:"PARAM_1",script: [               $class:'GroovyScript',script: [classpath: [],sandbox:true,script:"""                   Thread.sleep(2_000)                   return ['1']"""               ]           ]        ],        [$class:'ChoiceParameter',choiceType:'PT_CHECKBOX',description:"PARAM_2",name:"PARAM_2",script: [               $class:'GroovyScript',script: [classpath: [],sandbox:true,script:"""                   Thread.sleep(2_000)                   return ['2']"""               ]           ]        ],        [$class:'ChoiceParameter',choiceType:'PT_CHECKBOX',description:"PARAM_3",name:"PARAM_3",script: [               $class:'GroovyScript',script: [classpath: [],sandbox:true,script:"""                   Thread.sleep(2_000)                   return ['3']"""               ]           ]        ]    ])])stage('Test') {    echo"- STRING_PARAM -"    echo params.STRING_PARAM    echo params.STRING_PARAM    echo params.STRING_PARAM    echo"- PARAM_1 -"    echo params.PARAM_1    echo params.PARAM_1    echo params.PARAM_1    echo"- PARAM_2 -"    echo params.PARAM_2    echo params.PARAM_2    echo params.PARAM_2    echo"- PARAM_3 -"    echo params.PARAM_3    echo params.PARAM_3    echo params.PARAM_3}properties([parameters()])
  1. Run it once, go into the console and make sure you accept thestaticMethod java.lang.Thread sleep long signature or else the scripts won't actually be running.
  2. Now run it again, and notice how the pipeline takes 72 seconds to finish. This is the number of parameter accesses (12) multiplied by the total sleep time of the scripts (6 seconds), which proves that every access toparams is retriggering all the scripts in series while calculating the default value.
  3. Install my version of the plugin and rerun the pipeline. You might need to accept thestaticMethod java.lang.Thread sleep long signature again if you restart Jenkins and don't have that persisted.
  4. It will now take just 6 seconds, as the first access toparams will calculate all the default values, but further accesses will use the cached values.

Here's a screenshot before/after (middle hidden build is where I needed to accept the signature again):
active-choices-defaults-fix

Submitter checklist

  • Make sure you are opening from atopic/feature/bugfix branch (right side) and not your main branch!
  • Ensure that the pull request title represents the desired changelog entry
  • Please describe what you did
  • Link to relevant issues in GitHub or Jira
  • Link to relevant pull requests, esp. upstream and downstream changes
  • Ensure you have provided tests that demonstrate the feature works or the issue is fixed

@JendoliverJendoliver requested a review froma team as acode ownerNovember 19, 2025 11:38
@kinow
Copy link
Member

Sounds like a good improvement,@Jendoliver ! Haven't looked at the code yet, but the explanation is very clear, thanks. Will try to review over next days (I'll be offline next week working on a personal project, so I should have some spare time 👍 ). Thanks

Copy link
Member

@kinowkinow left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

Just had a look a the code, and was surprised by how small your change was! Great job for spotting where that can be done.

I'm curious whether it will break any existing scripts (cc@imoutsatsos). I will try a few examples, and see if I can add a test (if you can add a test it'll be faster to review/merge if it works).

Thanks again!

@Jendoliver
Copy link
Author

Thanks so much for the review@kinow! Will have a look into adding that test myself to speed things up 👍

kinow reacted with heart emoji

Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment

Reviewers

@kinowkinowAwaiting requested review from kinow

1 more reviewer

@BobinarBobinarBobinar approved these changes

Reviewers whose approvals may not affect merge requirements

Assignees

No one assigned

Labels

None yet

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

3 participants

@Jendoliver@kinow@Bobinar

[8]ページ先頭

©2009-2025 Movatter.jp