Pipeline as a code events mechanism

141 views
Skip to first unread message

Ido Gadiel

unread,
Jun 26, 2016, 6:23:11 AM6/26/16
to Jenkins Developers
Hi everybody!

I am trying to get events from the “Stages” that created by the groovy script.
For “regular” jobs, we extended the RunListener<Run> class, and got the onStarted & onComplete methods,
But that doesn’t seems to work with those new “Stages”.

Is there any way to make a registration for a WorkflowJob’s (or WorkflowRun ) events ?
Is there any other class to extend in order the get events?

Thank you very much,
Ido

Michael Neale

unread,
Jun 27, 2016, 4:27:18 AM6/27/16
to Jenkins Developers
Hi Ido. 

Yes, there is a way. If you excuse my scratchings: 


I was trying to listen for the same. A run listener registers a graph listener - and from that, there are many events. 

Ido Gadiel

unread,
Jun 27, 2016, 9:49:27 AM6/27/16
to Jenkins Developers
Hi Michael, thanks for your answer.
You helped a lot!

Michael Neale

unread,
Jun 27, 2016, 8:04:12 PM6/27/16
to Jenkins Developers
thanks! good to hear. 

I know Tom Fennelly was working on some other ways to get at these events, so there may be better code examples soon. 

Whatever you end up doing, post it here as others may likely benefit from this as well. 

Thorsten Scherler

unread,
Jun 28, 2016, 6:49:46 AM6/28/16
to Jenkins Developers
Hi Ido,

Tom is ATM working with me on that. You may want to look into https://github.com/jenkinsci/blueocean-plugin/tree/feature/JENKINS-36211/blueocean-events/src/main/java/io/jenkins/blueocean/events for an outlook of what events will be fired. Do you need more, or more attributes?

Sample output for a reported event:
{"pipeline_job_name":"pipelinetest","pipeline_run_id":"111","pipeline_step_name":"echo","pipeline_step_stage_id":"5","pipeline_step_flownode_id":"8","pipeline_step_stage_name":"Stage 2","jenkins_event":"pipeline_step","pipeline_context":"4","jenkins_channel":"pipeline"}"

HTH

salu2

Jesse Glick

unread,
Jun 28, 2016, 12:27:06 PM6/28/16
to Jenkins Dev
On Mon, Jun 27, 2016 at 4:27 AM, Michael Neale <mne...@cloudbees.com> wrote:
> https://github.com/jenkinsci/blueocean-plugin/blob/a2f6c7376b88b2a93bf0d4a68238099174d11560/blueocean-rest-impl/src/main/java/io/jenkins/blueocean/service/embedded/util/StageEventRunListener.java

This of course has the disadvantage of casting to `WorkflowRun`, and
will not work if and when we implement a Pipeline console with no
associated `Run`. So clearly a different extension point is needed to
be notified of new `FlowExecution`s. There is a `FlowExecutionList`
but not a corresponding listener yet. Would be easy to create one.
Reply all
Reply to author
Forward
0 new messages