[JIRA] (JENKINS-58865) Electric flow plugin does not return the json details of a REST call

4 views
Skip to first unread message

ataylor@cloudbees.com (JIRA)

unread,
Aug 8, 2019, 2:26:03 PM8/8/19
to jenkinsc...@googlegroups.com
Alex Taylor created an issue
 
Jenkins / Improvement JENKINS-58865
Electric flow plugin does not return the json details of a REST call
Issue Type: Improvement Improvement
Assignee: ElectricFlow ElectricCloud
Components: electricflow-plugin
Created: 2019-08-08 18:25
Priority: Minor Minor
Reporter: Alex Taylor

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

Add Comment Add Comment
 
This message was sent by Atlassian Jira (v7.11.2#711002-sha1:fdc329d)

ataylor@cloudbees.com (JIRA)

unread,
Aug 27, 2019, 4:33:02 PM8/27/19
to jenkinsc...@googlegroups.com
Alex Taylor commented on Improvement JENKINS-58865
 
Re: Electric flow plugin does not return the json details of a REST call

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:

def returnOut = step([$class: 'ElectricFlowGenericRestApi',
            configuration: 'CBFConfiguration',
            urlPath : '/projects',
            httpMethod : 'POST',
            body : '',
            parameters : [
                [$class: 'Pair',
                    key: 'projectName',
                    value: 'EC-TEST-Jenkins-1.00.00.01'
                ],
                [$class: 'Pair',
                    key: 'description',
                    value: 'Native Jenkins Test Project'
                ]
            ]
    ])

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`

ovasilko@electric-cloud.com (JIRA)

unread,
Oct 1, 2019, 8:42:02 AM10/1/19
to jenkinsc...@googlegroups.com

Alex Taylor, thanks for the ticket, great suggestions and help on resolving the ticket!

New version of the plugin 1.1.10 was released which includes new workflow step "Call REST API" where results can be stored within environment variable available during the build for scripted and declarative pipelines or can be returned from the function within scripted pipelines:

https://wiki.jenkins.io/display/JENKINS/CloudBees+Flow+Plugin#CloudBeesFlowPlugin-CallRESTAPIofCloudBeesFlow.1

 

 

This message was sent by Atlassian Jira (v7.13.6#713006-sha1:cc4451f)
Atlassian logo

pluginsdev@electric-cloud.com (JIRA)

unread,
Dec 13, 2019, 10:33:06 AM12/13/19
to jenkinsc...@googlegroups.com
Reply all
Reply to author
Forward
0 new messages