Hello. I had the same issue and I discovered the cause and solution.
In my case, I was using the Active Choice Parameter plugin in the Jenkins file, with the following properties block placed outside the pipeline block:
properties([
parameters([
[$class: 'ChoiceParameter', choiceType: 'PT_SINGLE_SELECT',
description: 'Color of the car',
name: 'COLOR',
script:
[$class: 'GroovyScript',
fallbackScript: [classpath: [], sandbox: true, script: 'return ["ERROR"]'],
script: [classpath: [], script: myCustomScript]
]
]
])
])
pipeline {
}
As can be seen, I included the entry sandbox: true in the key fallbackScript, but not in the one right after it, script. So all I had to do was to set it as:
script: [classpath: [], sandbox: true, script: myCustomScript]
With this set, the "Use Groovy Sandbox" checkbox in the GUI configuration of the pipeline should get checked automatically.
What was happening to me was that I was checking this checkbox in the GUI configuration for my script, but I was forgetting to explicitly set it in the properties block as well. The properties block was then taking precedence over the GUI configuration of the pipeline and was unchecking that checkbox after each build, i.e. it was overwriting the configuration I was setting in the GUI. In my experience, the latter is always the case. In other words, what we put in a properties block in the Jenkinsfile, overwrites what we set in the GUI configuration of the pipeline for the Active Choice Parameter plugin. And I do like this behavior, as I prefer to have all the settings of my pipelines in Jenkisnfiles (text files) that I can version and easily copy/paste.
My Jenkins version is 2.414.1 and my Active Choice Parameter plugin version is 2.7.2.
Hope this help!
I was not able to reproduce it. I created a job with a single parameter and with a Groovy script with that checkbox checked.
Reloaded configuration a couple times, and the checkbox was still checked.
Executed the job twice, producing two succeeded builds. Checked the checkbox status in-executions, and after both builds were produced. The check box was always selected.
Same plug-in version, only Jenkins version a bit older 2.204.1. Not sure if the Jenkins version could interfere; or perhaps the Scriptler version?
If anybody else is able to reproduce in another environment, and if possible to share the config.xml of the job, then I will try it again.
Thanks
Bruno