Reputation:
There is a snippet generator available under the following url:
http://<your-jenkins-instance>/job/<your-job>/pipeline-syntax/
It will generate the pipeline step snippet based on the data you enter on a form. Let's look at libraryResource
step, as that will be a good example. If we do not fill in Character encoding
, it will not be included in the generated snippet. This the behaviour I'm trying to implement in a custom plugin, to no avail. The way it works in my plugin is that every unset variable is always translated into empty in the generated snippet, e.g. value: ''
rather than omited altogether.
I have been looking at the code and cannot find anything that would override the default behaviour that I've observed:
Any clues how to enforce skipping unset values while generating the snippet?
Upvotes: 1
Views: 311
Reputation: 2283
In general, value is skipped during the generation of snippet if it is null
, so in case of ResourceStep.encoding
it is converted to null in method
@DataBoundSetter public void setEncoding(String encoding) {
this.encoding = Util.fixEmptyAndTrim(encoding);
}
More information You can find here: https://jenkins.io/doc/developer/plugin-development/pipeline-integration/
Upvotes: 0