-
Notifications
You must be signed in to change notification settings - Fork 33
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 our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add support for sandbox and custom config names #3
Conversation
This adds two options to the Jenkins UI for configuring pipeline multibranch with defaults. 1. Customizing the config file name to something other than `Jenkinsfile`. 2. Enabling groovy sandbox on the default Jenkinsfile being run. Additionally, with these new options using the `@DataBoundSetter`, Job DSL is now available for configuring these settings. Example Job DSL: ```groovy multibranchPipelineJob('example') { factory { pipelineBranchDefaultsProjectFactory { // The ID of the default Jenkinsfile to use from the global Config File Management. scriptId('Jenkinsfile') // If enabled, the configured default Jenkinsfile will be run within a Groovy sandbox. useSandbox(true) } } } ``` See also: - [JENKINS-43285][JENKINS-43285] jobdsl for pipeline multibranch defaults - [JENKINS-41108][JENKINS-41108] Posibility to specify the name of jenkinsfile [JENKINS-41108]: https://issues.jenkins-ci.org/browse/JENKINS-41108 [JENKINS-43285]: https://issues.jenkins-ci.org/browse/JENKINS-43285
this.useSandbox = useSandbox; | ||
} | ||
|
||
public Object readResolve() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why is this here? Should never be used AFAICT.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I saw it in another-like class and thought there was maybe something Jenkins behind the scenes that I didn't understand so I added it. I'll remove it because I agree.
public static final String SCRIPT = "Jenkinsfile"; | ||
|
||
private String scriptId = SCRIPT; | ||
private Boolean useSandbox = false; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should be boolean
. Otherwise you will get an NPE after load from previous settings.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good call, I will update it.
@jglick I removed |
I need to build and try out the latest code changes before this gets merged. |
I have successfully tested the latest changes. |
@vaimr do you still support this plugin or should I request ownership to maintain this plugin? |
defaults plugin This is so that I can merge and release [a pull request][jenkins-infra#3] in case the original maintainer does not reply. The pipeline multibranch defaults plugin has not had any changes in two years so it is unlikely anybody supports it. [jenkins-infra#3]: jenkinsci/pipeline-multibranch-defaults-plugin#3
Very nice, this is exactly what I need, can we get a build to test it ? I thinks this branch should be merged asap :) |
@yan796 if you have maven 3 and jdk8 installed, the build procedure is:
The plugin will be in |
@yan796 you should still be able to customize the ID in config file management plugin. |
@samrocketman thanks for your message. I am unfortunately only a end-user so I don't have anything setup to compile myself the plug-in. I must be doing something wrong but when I generate a groovy script, the ID is randomly generated and read-only while the rest, i.e. name, and script, is editable. |
You must customize the ID when creating the script. Once it is created I don’t think you can change it. |
@samrocketman you were right, it must be set before creating the script. Thanks a lot for your help. |
I really like and want this feature ;) |
@daniel-beck Please review this change. |
defaults plugin This is so that I can merge and release [a pull request][#3] in case the original maintainer does not reply. The pipeline multibranch defaults plugin has not had any changes in two years so it is unlikely anybody supports it. [#3]: jenkinsci/pipeline-multibranch-defaults-plugin#3
This adds two options to the Jenkins UI for configuring pipeline multibranch with defaults.
Jenkinsfile
.Additionally, with these new options using the
@DataBoundSetter
, Job DSL is now available for configuring these settings.Example Job DSL:
See also: