[JENKINS-45892] How to identify jobs

18 views
Skip to first unread message

Ullrich Hafner

unread,
Mar 19, 2018, 5:52:31 PM3/19/18
to Jenkins Developers
I would like to keep a reference to a Run of another Job in one of my actions. Due to [JENKINS-45892] I’m not allowed to reference the Run as an object anymore, the object needs to be transient. In order to restore the reference after deserialization, I rather need to store an ID. Which ID can I use for jobs? Seems that the only thing I can use is the full name. However, if someone renames the job, then my references will break. Is there an ID I can use to identify a job?
signature.asc

Jesse Glick

unread,
Mar 19, 2018, 6:39:10 PM3/19/18
to Jenkins Dev
On Mon, Mar 19, 2018 at 5:52 PM, Ullrich Hafner
<ullrich...@gmail.com> wrote:
> I would like to keep a reference to a Run of another Job in one of my actions.

Normally `Run.toExternalizableId` is used for this purpose.

> if someone renames the job, then my references will break. Is there an ID I can use to identify a job?

There is a `unique-id` plugin, though I am not much of a fan. You can
simply implement `ItemListener.onLocationChanged` and update
references. Or just reconsider whether you really want to do this.
Reply all
Reply to author
Forward
0 new messages