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

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

    Details

    • Similar Issues:
    • Epic Link:

      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

            Hide
            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.

            Show
            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 .
            Hide
            michaelneale Michael Neale added a comment -

            Patrick Wolf 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?)

            Show
            michaelneale Michael Neale added a comment - Patrick Wolf 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?)
            Hide
            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 Jesse Glick 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.

            Show
            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 Jesse Glick 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.
            Hide
            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.

            Show
            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.
            Hide
            bitwiseman Liam Newman added a comment -

            Bulk closing resolved issues.

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

              People

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

                Dates

                • Created:
                  Updated:
                  Resolved: