Hey,

You can use the groovy.transform.Field with a global variable in the 
pipeline, for instance, the below snippet set the value of myStep in the 
variable myStepData which it's consumed later on in another stage


import groovy.transform.Field
@Field def myStepData = [:]

pipeline {
    ...
    stage('producer') {
        ...
        steps {
            script {
               // myStep returns a map with values
               myStepData = myStep(....)
               ...
            }
         }
     }
     ....
    stage('consumer') {
        ...
        steps {
            script {
               // where <field> is one of the entries
               if (myStepData?.<field>?.equals('acme'))) {
          
               }
            }
         }
     }
}

Cheers
On Thursday, 12 November 2020 at 05:08:37 UTC Lakshmi Narasimhan wrote:

> Hello Jenkins devs,
>
> Is it possible to get back a return value from a pipeline step? I am 
> looking for a map similar to  checkout step 
> https://issues.jenkins.io/browse/JENKINS-26100.
>
> Currently, I am exporting the values I need to get back from the step to 
> the environment using an EnvironmentContributingAction.
>
> Thanks in advance for your help.
>

-- 
You received this message because you are subscribed to the Google Groups 
"Jenkins Developers" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/jenkinsci-dev/18afc1eb-aa0e-484b-88c9-01bf724c4b2an%40googlegroups.com.

Reply via email to