• Icon: New Feature New Feature
    • Resolution: Unresolved
    • Icon: Minor Minor
    • envinject-plugin
    • None

      It would be nice if we could inject env variables by a script store in filesystem but not only using "Evaluated Groovy Script" pasted in job parameters.

          [JENKINS-26989] Inject env variables via stored script

          Alexander Komarov added a comment - - edited

          Agreed that it would be nice.

          In the meantime, I've worked around this by retrieving scripts via http from jenkins userContent,
          (Scripts in that directory get auto-updated from scm via puppet).
          All scripts return a closure.

          One-liner for brevity:

          evaluate("${jenkins.model.Jenkins.getInstance().getRootUrl()}/userContent/my-script-name.groovy".toURL().text)()
          

          Script example:

          return {
             ['something': 'someValue']
          }
          

          Same with parameter passed to the shared script:

              evaluate("${jenkins.model.Jenkins.getInstance().getRootUrl()}/userContent/my-script-name.groovy".toURL().text)('some-parameter-value')
          

          Script example:

          return { myParam ->
                [ 'something': myParam]
          }
          

          Alexander Komarov added a comment - - edited Agreed that it would be nice. In the meantime, I've worked around this by retrieving scripts via http from jenkins userContent, (Scripts in that directory get auto-updated from scm via puppet). All scripts return a closure. One-liner for brevity: evaluate( "${jenkins.model.Jenkins.getInstance().getRootUrl()}/userContent/my-script-name.groovy" .toURL().text)() Script example: return { [ 'something' : 'someValue' ] } Same with parameter passed to the shared script: evaluate( "${jenkins.model.Jenkins.getInstance().getRootUrl()}/userContent/my-script-name.groovy" .toURL().text)( 'some-parameter-value' ) Script example: return { myParam -> [ 'something' : myParam] }

            gbois Gregory Boissinot
            erthad Timur Batyrshin
            Votes:
            2 Vote for this issue
            Watchers:
            4 Start watching this issue

              Created:
              Updated: