Uploaded image for project: 'Jenkins'
  1. Jenkins
  2. JENKINS-42698

Support default value for parameters if they are not set

    Details

    • Similar Issues:

      Description

      Please consider supporting a default value for parameters if they are empty or unset. There are cases where env parameters ${ENV, var="SOME_ENV_VAR"} are not set. And for build parameters there can be the case when it is not set at all. For example, this happens with Groovy scripts that trigger builds, see e.g. JENKINS-13768

      In these cases it would be nice to be able to print something instead of the empty string. For env vars this seems easy, as it's just another parameters then: ${ENV, var="SOME_ENV_VAR", ifUnset="[not set]"}". For build parameters it might be more tricky, but the the same concept might apply. And since they end up in env variables anyway, one workaround would be simply using ${ENV, var="MyBuildParameter", ifUnset="[not set]"}.

       

        Attachments

          Issue Links

            Activity

            Hide
            davidvanlaatum David van Laatum added a comment -

            Alex Earl I beleave this is done in the token macros plugin

            Show
            davidvanlaatum David van Laatum added a comment - Alex Earl I beleave this is done in the token macros plugin
            Hide
            slide_o_mix Alex Earl added a comment -

            I could add this for ENV, but not globally.

            Show
            slide_o_mix Alex Earl added a comment - I could add this for ENV, but not globally.
            Hide
            axelh Axel Heider added a comment -

            Yes, please do this 

            Show
            axelh Axel Heider added a comment - Yes, please do this 
            Hide
            scm_issue_link SCM/JIRA link daemon added a comment -

            Code changed in jenkins
            User: Alex Earl
            Path:
            src/main/java/org/jenkinsci/plugins/tokenmacro/impl/EnvironmentVariableMacro.java
            src/test/java/org/jenkinsci/plugins/tokenmacro/impl/EnvironmentVariableMacroTest.java
            http://jenkins-ci.org/commit/token-macro-plugin/8fe0f665717596deff76306dea8f583b35d6d891
            Log:
            Fix JENKINS-42698

            Show
            scm_issue_link SCM/JIRA link daemon added a comment - Code changed in jenkins User: Alex Earl Path: src/main/java/org/jenkinsci/plugins/tokenmacro/impl/EnvironmentVariableMacro.java src/test/java/org/jenkinsci/plugins/tokenmacro/impl/EnvironmentVariableMacroTest.java http://jenkins-ci.org/commit/token-macro-plugin/8fe0f665717596deff76306dea8f583b35d6d891 Log: Fix JENKINS-42698
            Hide
            slide_o_mix Alex Earl added a comment -

            Fixed in 8fe0f6

            usage is $
            {ENV,var="foo", default="foo not set"}

            Show
            slide_o_mix Alex Earl added a comment - Fixed in 8fe0f6 usage is $ {ENV,var="foo", default="foo not set"}
            Hide
            axelh Axel Heider added a comment -

            THANK YOU!

            Show
            axelh Axel Heider added a comment - THANK YOU!
            Hide
            slide_o_mix Alex Earl added a comment -

            Will be in 2.2

            Show
            slide_o_mix Alex Earl added a comment - Will be in 2.2

              People

              • Assignee:
                slide_o_mix Alex Earl
                Reporter:
                axelh Axel Heider
              • Votes:
                0 Vote for this issue
                Watchers:
                4 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved: