How can I distinguish between two custom steps of the same class?

11 views
Skip to first unread message

Moshe Cohen

unread,
Jan 26, 2017, 12:33:42 PM1/26/17
to Jenkins Developers
Hi,

I have a custom build step (extends Builder).
Its 'perform' method gets a build object as an argument.

When there are more than one such steps in a job, how can I distinguish between them within the 'perform' method?

The need to do this is because an artifact is published for each such steps and I have to name them differently so one does not overwrite the other.

TIA



Jesse Glick

unread,
Jan 26, 2017, 1:47:03 PM1/26/17
to Jenkins Dev
On Thu, Jan 26, 2017 at 12:33 PM, Moshe Cohen <mos...@gmail.com> wrote:
> When there are more than one such steps in a job, how can I distinguish
> between them within the 'perform' method?

You cannot, as such, but you can attach a custom `Action` to the `Run`
which records which artifacts have already been published, which makes
it easy to choose new names.

Moshe Cohen

unread,
Jan 26, 2017, 1:52:57 PM1/26/17
to jenkin...@googlegroups.com
Thank you.
Can you point me to an example that does what you just mentioned?


--
You received this message because you are subscribed to a topic in the Google Groups "Jenkins Developers" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/jenkinsci-dev/m1HPCnZaD7I/unsubscribe.
To unsubscribe from this group and all its topics, send an email to jenkinsci-dev+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/jenkinsci-dev/CANfRfr15LOo28wYfeaceBZXQNNvL0oCU5StxAgtkrohmdJ6GLQ%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

Daniel Beck

unread,
Jan 26, 2017, 3:54:15 PM1/26/17
to jenkin...@googlegroups.com

> On 26.01.2017, at 19:52, Moshe Cohen <mos...@gmail.com> wrote:
>
> Can you point me to an example that does what you just mentioned?
>

This PR (that I really need to finish some time…) does something similar in Copy Artifact:

https://github.com/jenkinsci/copyartifact-plugin/pull/32

A single action is used to record copied files, and amended as needed.

Jesse Glick

unread,
Jan 27, 2017, 10:06:59 AM1/27/17
to Jenkins Dev
On Thu, Jan 26, 2017 at 3:54 PM, Daniel Beck <m...@beckweb.net> wrote:
> A single action is used to record copied files, and amended as needed.

BTW in this example no backreference to the `Run` was needed. If the
action does need to refer to the `Run` for any reason, typically so it
can Stapler-bind some UI, the field should be `transient` and should
be set via `RunAction2`.
Reply all
Reply to author
Forward
0 new messages