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

Ability to set output of a step to environment variable(s)

    XMLWordPrintable

Details

    Description

      When using steps like input that capture data from a user, it makes sense to be able to set the resultant values to environment variables.

      This could be generalised to other steps that return values (perhaps as maps).

      In pipeline-model, the way data is passed around is via (environment) variables as there are no local variables, so the ability to set environment variables to the output is required.

      Attachments

        Issue Links

          Activity

            jglick Jesse Glick added a comment -

            Currently input returns typed objects, so JENKINS-34101 would be needed to get these in a form amenable to passing to withEnv.

            jglick Jesse Glick added a comment - Currently input returns typed objects, so JENKINS-34101 would be needed to get these in a form amenable to passing to withEnv .
            michaelneale Michael Neale added a comment -

            hrmpw what do you think about a pipeline-model specific "captureInput" step - which wraps input and grabs its stuff as env vars? (may be easier than the changes needed to input?)

            michaelneale Michael Neale added a comment - hrmpw what do you think about a pipeline-model specific "captureInput" step - which wraps input and grabs its stuff as env vars? (may be easier than the changes needed to input?)
            hrmpw Patrick Wolf added a comment -

            I think a generalized method to set the output of a step in an environment variable is a decent hack but it feels like a temporary workaround until the step is supported natively. Otherwise, a quick script block works just as well.

            For input I think we need a more elegant solution. I agree with jglick that input might require a more specialized setup in declarative. I think we should look into including an input section of the per-stage configuration like notifications.

            hrmpw Patrick Wolf added a comment - I think a generalized method to set the output of a step in an environment variable is a decent hack but it feels like a temporary workaround until the step is supported natively. Otherwise, a quick script block works just as well. For input I think we need a more elegant solution. I agree with jglick that input might require a more specialized setup in declarative. I think we should look into including an input section of the per-stage configuration like notifications.
            abayer Andrew Bayer added a comment -

            So in JENKINS-48379, we're adding a stage-level input section, which runs before the agent and when, and will put any parameters it's given into the environment. I think this does the trick.

            abayer Andrew Bayer added a comment - So in JENKINS-48379 , we're adding a stage -level input section, which runs before the agent and when , and will put any parameters it's given into the environment. I think this does the trick.
            bitwiseman Liam Newman added a comment -

            Bulk closing resolved issues.

            bitwiseman Liam Newman added a comment - Bulk closing resolved issues.

            People

              abayer Andrew Bayer
              michaelneale Michael Neale
              Votes:
              1 Vote for this issue
              Watchers:
              8 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: