-
Improvement
-
Resolution: Fixed
-
Minor
-
None
Issue:
I am trying to do a REST API call to create a electricflow job execution. When I run that REST call it will respond with a json of the ID for that execution and I want to parse that ID into a groovy variable
Steps to resolve:
From what I am seeing the `perform` method here: https://github.com/jenkinsci/electricflow-plugin/blob/master/src/main/java/org/jenkinsci/plugins/electricflow/ElectricFlowGenericRestApi.java#L68 does not return a value into a groovy variable. In my opinion it should be like `ReturnStdOut` on a shell step inside of a pipeline rather than just printing into the logs. This would allow other REST calls to check on the status the build using the ID which is returned
This could be done one of 3 ways:
1. The Electric flow REST API function could be changed into a `Step` rather than implementing a `SimpleBuildStep` since the Simple build step does not allow for return values. This would mean writing a custom step which will send out the API call and then return the response from the Electric Flow server into a groovy variable
2. This REST API could be converted into a block-scoped Step (or SimpleBuildWrapper) and then the response could be captured inside of an Environment variable which is able to be used later inside of the pipeline.
3. https://issues.jenkins-ci.org/browse/JENKINS-29144 could be fixed and a SimpleBuildStep could be used to create the same environment variable in #2
For 1 this would look like:
and that returnOut would be a groovy variable and able to be used anywhere else
For 2 and 3 there would be a general ENV variable called something like `REST_API_OUPUT` which is set on the return and then that can be used in the pipeline with `$env.REST_API_OUTPUT`