How I can pass custom HTML+js code to Jenkins Input step page?












0















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










share|improve this question



























    0















    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










    share|improve this question

























      0












      0








      0








      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










      share|improve this question














      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






      share|improve this question













      share|improve this question











      share|improve this question




      share|improve this question










      asked Nov 16 '18 at 15:28









      Commander AsdasdCommander Asdasd

      61




      61
























          1 Answer
          1






          active

          oldest

          votes


















          0














          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
          }
          }
          }





          share|improve this answer























            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
            });


            }
            });














            draft saved

            draft discarded


















            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









            0














            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
            }
            }
            }





            share|improve this answer




























              0














              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
              }
              }
              }





              share|improve this answer


























                0












                0








                0







                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
                }
                }
                }





                share|improve this answer













                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
                }
                }
                }






                share|improve this answer












                share|improve this answer



                share|improve this answer










                answered Nov 20 '18 at 17:09









                Commander AsdasdCommander Asdasd

                61




                61






























                    draft saved

                    draft discarded




















































                    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.




                    draft saved


                    draft discarded














                    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





















































                    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







                    Popular posts from this blog

                    MongoDB - Not Authorized To Execute Command

                    How to fix TextFormField cause rebuild widget in Flutter

                    in spring boot 2.1 many test slices are not allowed anymore due to multiple @BootstrapWith