How I can pass custom HTML+js code to Jenkins Input step page?
I'm trying to achieve flexible UI in Jenkins "Input step" from pipeline library, currently I'm using Extended choice parameters plugin (https://wiki.jenkins.io/display/JENKINS/Extended+Choice+Parameter+plugin), that built on top of Json Editor library (https://github.com/json-editor/json-editor) and used to provide various HTML input elements (created from JSON schema) and generating JSON output.
Does "Input step" can accept some html template code to fill it with data, collected during build and print it on "Input step" page with some custom HTML elements and js binding, beyond input forms provided by "Extended choice parameters"?
Now I'm generating dynamic drop-down list via groovy shared library script, but can't make it print on "Input step page" non-input elements.
Example of what I need on input step
jenkins input groovy pipeline
add a comment |
I'm trying to achieve flexible UI in Jenkins "Input step" from pipeline library, currently I'm using Extended choice parameters plugin (https://wiki.jenkins.io/display/JENKINS/Extended+Choice+Parameter+plugin), that built on top of Json Editor library (https://github.com/json-editor/json-editor) and used to provide various HTML input elements (created from JSON schema) and generating JSON output.
Does "Input step" can accept some html template code to fill it with data, collected during build and print it on "Input step" page with some custom HTML elements and js binding, beyond input forms provided by "Extended choice parameters"?
Now I'm generating dynamic drop-down list via groovy shared library script, but can't make it print on "Input step page" non-input elements.
Example of what I need on input step
jenkins input groovy pipeline
add a comment |
I'm trying to achieve flexible UI in Jenkins "Input step" from pipeline library, currently I'm using Extended choice parameters plugin (https://wiki.jenkins.io/display/JENKINS/Extended+Choice+Parameter+plugin), that built on top of Json Editor library (https://github.com/json-editor/json-editor) and used to provide various HTML input elements (created from JSON schema) and generating JSON output.
Does "Input step" can accept some html template code to fill it with data, collected during build and print it on "Input step" page with some custom HTML elements and js binding, beyond input forms provided by "Extended choice parameters"?
Now I'm generating dynamic drop-down list via groovy shared library script, but can't make it print on "Input step page" non-input elements.
Example of what I need on input step
jenkins input groovy pipeline
I'm trying to achieve flexible UI in Jenkins "Input step" from pipeline library, currently I'm using Extended choice parameters plugin (https://wiki.jenkins.io/display/JENKINS/Extended+Choice+Parameter+plugin), that built on top of Json Editor library (https://github.com/json-editor/json-editor) and used to provide various HTML input elements (created from JSON schema) and generating JSON output.
Does "Input step" can accept some html template code to fill it with data, collected during build and print it on "Input step" page with some custom HTML elements and js binding, beyond input forms provided by "Extended choice parameters"?
Now I'm generating dynamic drop-down list via groovy shared library script, but can't make it print on "Input step page" non-input elements.
Example of what I need on input step
jenkins input groovy pipeline
jenkins input groovy pipeline
asked Nov 16 '18 at 15:28


Commander AsdasdCommander Asdasd
61
61
add a comment |
add a comment |
1 Answer
1
active
oldest
votes
Everything was quite simple, ExtendedChoiceParameterDefinition have parameter "String javascript", that can take any js string which can not only return JSON string for Json-editor, but also can modify input page itself.
Example pipeline:
stage('UserInput'){
steps {
script {
//...groovy script is omitted, it need only return json in valid form
def jsString = '''
var bodyElement = document.createElement('div');
bodyElement.innerHTML = '<h1 id="title">Some Title</h1><span style="display:inline-block; width=100px;">Some arbitrary text</span>';
document.getElementsByTagName('body')[0].appendChild(bodyElement);'''
def jsonParams = new ExtendedChoiceParameterDefinition(
'Cookbooks', //String name,
'PT_JSON', //String type,
null, //String value,
null, //String projectName,
null, //String propertyFile,
jsonGroovyScript, //String groovyScript (that returns JSON for generating Json-Input forms),
null, //String groovyScriptFile,
"jsonText=$jsonText", //String bindings,
'', //String groovyClasspath,
null, //String propertyKey,
null, //String defaultValue,
null, //String defaultPropertyFile,
null, //String defaultGroovyScript,
null, //String defaultGroovyScriptFile,
null, //String defaultBindings,
null, //String defaultGroovyClasspath,
null, //String defaultPropertyKey,
null, //String descriptionPropertyValue,
null, //String descriptionPropertyFile,
null, //String descriptionGroovyScript,
null, //String descriptionGroovyScriptFile,
null, //String descriptionBindings,
null, //String descriptionGroovyClasspath,
null, //String descriptionPropertyKey,
null, //String javascriptFile,
jsString, //String javascript (js code that modify input page itself),
false, //boolean saveJSONParameterToFile,
false, //boolean quoteValue,
10, //int visibleItemCount,
'', //String description,
',' //String multiSelectDelimiter
))
parameterList << jsonParams
def form = input(
id: 'form', message: 'input parameters', parameters: parameterList
) // generating input page step and store it in "form" var
env.FORM = form
}
}
}
add a comment |
Your Answer
StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});
function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53340830%2fhow-i-can-pass-custom-htmljs-code-to-jenkins-input-step-page%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
Everything was quite simple, ExtendedChoiceParameterDefinition have parameter "String javascript", that can take any js string which can not only return JSON string for Json-editor, but also can modify input page itself.
Example pipeline:
stage('UserInput'){
steps {
script {
//...groovy script is omitted, it need only return json in valid form
def jsString = '''
var bodyElement = document.createElement('div');
bodyElement.innerHTML = '<h1 id="title">Some Title</h1><span style="display:inline-block; width=100px;">Some arbitrary text</span>';
document.getElementsByTagName('body')[0].appendChild(bodyElement);'''
def jsonParams = new ExtendedChoiceParameterDefinition(
'Cookbooks', //String name,
'PT_JSON', //String type,
null, //String value,
null, //String projectName,
null, //String propertyFile,
jsonGroovyScript, //String groovyScript (that returns JSON for generating Json-Input forms),
null, //String groovyScriptFile,
"jsonText=$jsonText", //String bindings,
'', //String groovyClasspath,
null, //String propertyKey,
null, //String defaultValue,
null, //String defaultPropertyFile,
null, //String defaultGroovyScript,
null, //String defaultGroovyScriptFile,
null, //String defaultBindings,
null, //String defaultGroovyClasspath,
null, //String defaultPropertyKey,
null, //String descriptionPropertyValue,
null, //String descriptionPropertyFile,
null, //String descriptionGroovyScript,
null, //String descriptionGroovyScriptFile,
null, //String descriptionBindings,
null, //String descriptionGroovyClasspath,
null, //String descriptionPropertyKey,
null, //String javascriptFile,
jsString, //String javascript (js code that modify input page itself),
false, //boolean saveJSONParameterToFile,
false, //boolean quoteValue,
10, //int visibleItemCount,
'', //String description,
',' //String multiSelectDelimiter
))
parameterList << jsonParams
def form = input(
id: 'form', message: 'input parameters', parameters: parameterList
) // generating input page step and store it in "form" var
env.FORM = form
}
}
}
add a comment |
Everything was quite simple, ExtendedChoiceParameterDefinition have parameter "String javascript", that can take any js string which can not only return JSON string for Json-editor, but also can modify input page itself.
Example pipeline:
stage('UserInput'){
steps {
script {
//...groovy script is omitted, it need only return json in valid form
def jsString = '''
var bodyElement = document.createElement('div');
bodyElement.innerHTML = '<h1 id="title">Some Title</h1><span style="display:inline-block; width=100px;">Some arbitrary text</span>';
document.getElementsByTagName('body')[0].appendChild(bodyElement);'''
def jsonParams = new ExtendedChoiceParameterDefinition(
'Cookbooks', //String name,
'PT_JSON', //String type,
null, //String value,
null, //String projectName,
null, //String propertyFile,
jsonGroovyScript, //String groovyScript (that returns JSON for generating Json-Input forms),
null, //String groovyScriptFile,
"jsonText=$jsonText", //String bindings,
'', //String groovyClasspath,
null, //String propertyKey,
null, //String defaultValue,
null, //String defaultPropertyFile,
null, //String defaultGroovyScript,
null, //String defaultGroovyScriptFile,
null, //String defaultBindings,
null, //String defaultGroovyClasspath,
null, //String defaultPropertyKey,
null, //String descriptionPropertyValue,
null, //String descriptionPropertyFile,
null, //String descriptionGroovyScript,
null, //String descriptionGroovyScriptFile,
null, //String descriptionBindings,
null, //String descriptionGroovyClasspath,
null, //String descriptionPropertyKey,
null, //String javascriptFile,
jsString, //String javascript (js code that modify input page itself),
false, //boolean saveJSONParameterToFile,
false, //boolean quoteValue,
10, //int visibleItemCount,
'', //String description,
',' //String multiSelectDelimiter
))
parameterList << jsonParams
def form = input(
id: 'form', message: 'input parameters', parameters: parameterList
) // generating input page step and store it in "form" var
env.FORM = form
}
}
}
add a comment |
Everything was quite simple, ExtendedChoiceParameterDefinition have parameter "String javascript", that can take any js string which can not only return JSON string for Json-editor, but also can modify input page itself.
Example pipeline:
stage('UserInput'){
steps {
script {
//...groovy script is omitted, it need only return json in valid form
def jsString = '''
var bodyElement = document.createElement('div');
bodyElement.innerHTML = '<h1 id="title">Some Title</h1><span style="display:inline-block; width=100px;">Some arbitrary text</span>';
document.getElementsByTagName('body')[0].appendChild(bodyElement);'''
def jsonParams = new ExtendedChoiceParameterDefinition(
'Cookbooks', //String name,
'PT_JSON', //String type,
null, //String value,
null, //String projectName,
null, //String propertyFile,
jsonGroovyScript, //String groovyScript (that returns JSON for generating Json-Input forms),
null, //String groovyScriptFile,
"jsonText=$jsonText", //String bindings,
'', //String groovyClasspath,
null, //String propertyKey,
null, //String defaultValue,
null, //String defaultPropertyFile,
null, //String defaultGroovyScript,
null, //String defaultGroovyScriptFile,
null, //String defaultBindings,
null, //String defaultGroovyClasspath,
null, //String defaultPropertyKey,
null, //String descriptionPropertyValue,
null, //String descriptionPropertyFile,
null, //String descriptionGroovyScript,
null, //String descriptionGroovyScriptFile,
null, //String descriptionBindings,
null, //String descriptionGroovyClasspath,
null, //String descriptionPropertyKey,
null, //String javascriptFile,
jsString, //String javascript (js code that modify input page itself),
false, //boolean saveJSONParameterToFile,
false, //boolean quoteValue,
10, //int visibleItemCount,
'', //String description,
',' //String multiSelectDelimiter
))
parameterList << jsonParams
def form = input(
id: 'form', message: 'input parameters', parameters: parameterList
) // generating input page step and store it in "form" var
env.FORM = form
}
}
}
Everything was quite simple, ExtendedChoiceParameterDefinition have parameter "String javascript", that can take any js string which can not only return JSON string for Json-editor, but also can modify input page itself.
Example pipeline:
stage('UserInput'){
steps {
script {
//...groovy script is omitted, it need only return json in valid form
def jsString = '''
var bodyElement = document.createElement('div');
bodyElement.innerHTML = '<h1 id="title">Some Title</h1><span style="display:inline-block; width=100px;">Some arbitrary text</span>';
document.getElementsByTagName('body')[0].appendChild(bodyElement);'''
def jsonParams = new ExtendedChoiceParameterDefinition(
'Cookbooks', //String name,
'PT_JSON', //String type,
null, //String value,
null, //String projectName,
null, //String propertyFile,
jsonGroovyScript, //String groovyScript (that returns JSON for generating Json-Input forms),
null, //String groovyScriptFile,
"jsonText=$jsonText", //String bindings,
'', //String groovyClasspath,
null, //String propertyKey,
null, //String defaultValue,
null, //String defaultPropertyFile,
null, //String defaultGroovyScript,
null, //String defaultGroovyScriptFile,
null, //String defaultBindings,
null, //String defaultGroovyClasspath,
null, //String defaultPropertyKey,
null, //String descriptionPropertyValue,
null, //String descriptionPropertyFile,
null, //String descriptionGroovyScript,
null, //String descriptionGroovyScriptFile,
null, //String descriptionBindings,
null, //String descriptionGroovyClasspath,
null, //String descriptionPropertyKey,
null, //String javascriptFile,
jsString, //String javascript (js code that modify input page itself),
false, //boolean saveJSONParameterToFile,
false, //boolean quoteValue,
10, //int visibleItemCount,
'', //String description,
',' //String multiSelectDelimiter
))
parameterList << jsonParams
def form = input(
id: 'form', message: 'input parameters', parameters: parameterList
) // generating input page step and store it in "form" var
env.FORM = form
}
}
}
answered Nov 20 '18 at 17:09


Commander AsdasdCommander Asdasd
61
61
add a comment |
add a comment |
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53340830%2fhow-i-can-pass-custom-htmljs-code-to-jenkins-input-step-page%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown