Current Stage name inside the SimpleBuildStep.perform(...) method?

379 views
Skip to first unread message

Adakar

unread,
Jan 20, 2017, 11:48:29 AM1/20/17
to Jenkins Developers
Hi All!

I'm refactoring jenkins plugin to make it callable from Pipeline jobs. Do you have any suggestion how to get current Stage name inside the SimpleBuildStep.perform(Run<?,?> run, FilePath workspace, Launcher launcher, TaskListener listener)method?

Best Regards,
Adakar

Jesse Glick

unread,
Jan 21, 2017, 9:05:45 PM1/21/17
to Jenkins Dev
On Fri, Jan 20, 2017 at 11:48 AM, Adakar <jaku...@gmail.com> wrote:
> how to get current Stage name inside the
> SimpleBuildStep.perform(Run<?,?> run, FilePath workspace, Launcher launcher,
> TaskListener listener)method?

You cannot.

If you switched from `SimpleBuildStep` to a full-fledged `Step`, you
could get your `FlowNode` from the `StepContext` and use
`FlowScanningUtils.fetchEnclosingBlocks` to look for `LabelAction`,
which will match `stage(…) {…}` as well as some other steps that
define labels in block scope.

(But do you *really* need this information?)

Adakar

unread,
Jan 22, 2017, 6:07:00 AM1/22/17
to Jenkins Developers
Thanks for answer!
I need it for some logging purposes. Let's sey that each step call genetares a report and I need this information to distinguish which report was generated for which stage.
If you have any suggestion how to handle this different way, I would be grateful.

;

Björn Pedersen

unread,
Jan 23, 2017, 4:13:27 AM1/23/17
to Jenkins Developers
(comments inline)


This sounds interessing. I also have a use case for that (the  gerrit-verify-status-reporter-plugin)
It should report back the status and timing of parts of a job in a pipeline run, possibly setting a link
to the relevant part of the log as well. There I would either need  the predecessor node or an enclosing
block, if I am not mistaken. So this then needs to be a full step. How to handle non-pipeline jobs then?
Do  I need a separate  implementation then?

Björn

Jesse Glick

unread,
Jan 23, 2017, 3:52:16 PM1/23/17
to Jenkins Dev
On Mon, Jan 23, 2017 at 4:13 AM, 'Björn Pedersen' via Jenkins
Developers <jenkin...@googlegroups.com> wrote:
> It should report back the status and timing of parts of a job in a pipeline
> run, possibly setting a link
> to the relevant part of the log as well.

https://issues.jenkins-ci.org/browse/JENKINS-28119

Jesse Glick

unread,
Jan 23, 2017, 3:53:33 PM1/23/17
to Jenkins Dev
On Sun, Jan 22, 2017 at 6:06 AM, Adakar <jaku...@gmail.com> wrote:
> Let's sey that each step call genetares
> a report and I need this information to distinguish which report was
> generated for which stage.

There is not a general system for this yet, so better not to try. Cf.:
https://issues.jenkins-ci.org/browse/JENKINS-26522
Reply all
Reply to author
Forward
0 new messages