Assign variable from shell output using declarative pipeline

This issue is archived. You can view it, but you can't modify it. Learn more

XMLWordPrintable

      Currently, we can capture the output of a shell step inside of a script block, but have no way to do that in clean declarative pipeline syntax. For example, this post on StackOverflow must instead be:

      // Git committer email
      script {
        GIT_COMMIT_EMAIL = sh (
          script: 'git --no-pager show -s --format=\'%ae\'',
          returnStdout: true
        ).trim()
      }
      echo "Git committer email: ${GIT_COMMIT_EMAIL}"
      

      It also doesn't work to wrap it in a declarative environment block, though that may perhaps be a reasonable place to extend the syntax.

            Assignee:
            Unassigned
            Reporter:
            Bryce Schober
            Archiver:
            Jenkins Service Account

              Created:
              Updated:
              Resolved:
              Archived: