How to get current running job name without build number?

86 views
Skip to first unread message

Navnath Kumbhar

unread,
Aug 10, 2019, 8:04:18 AM8/10/19
to Jenkins Developers
Hello,

I want to get my current running job name without build number.  [Because I do not have build number]
How can I do that?

Thank you in advance!

Gavin

unread,
Aug 10, 2019, 12:28:35 PM8/10/19
to jenkin...@googlegroups.com
In what context? Are you building a pipeline plugin? You should have access to just about everything.

--
You received this message because you are subscribed to the Google Groups "Jenkins Developers" group.
To unsubscribe from this group and stop receiving emails from it, send an email to jenkinsci-de...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/jenkinsci-dev/cc54491c-6123-4517-a016-615c209e7a1e%40googlegroups.com.

Jeff Pearce

unread,
Aug 10, 2019, 12:30:11 PM8/10/19
to jenkin...@googlegroups.com
Where are you trying to get it from? Groovy script, plugin extension point, something else?
Sent from my iPhone

Navnath Kumbhar

unread,
Aug 11, 2019, 2:47:56 AM8/11/19
to Jenkins Developers
No, I am trying to get it from Java Jenkins API.


On Saturday, 10 August 2019 22:00:11 UTC+5:30, Jeff Pearce wrote:
Where are you trying to get it from? Groovy script, plugin extension point, something else?
Sent from my iPhone

On Aug 10, 2019, at 5:04 AM, Navnath Kumbhar <nnkumb...@gmail.com> wrote:

Hello,

I want to get my current running job name without build number.  [Because I do not have build number]
How can I do that?

Thank you in advance!

--
You received this message because you are subscribed to the Google Groups "Jenkins Developers" group.
To unsubscribe from this group and stop receiving emails from it, send an email to jenkin...@googlegroups.com.

Navnath Kumbhar

unread,
Aug 11, 2019, 2:54:23 AM8/11/19
to Jenkins Developers
No, it is not a pipeline plugin. It is simple plugin with which adds a custom build step. Link to wiki : https://wiki.jenkins.io/display/JENKINS/Reqtify+Plugin


On Saturday, 10 August 2019 21:58:35 UTC+5:30, Gavin Mogan wrote:
In what context? Are you building a pipeline plugin? You should have access to just about everything.

On Sat., Aug. 10, 2019, 5:04 a.m. Navnath Kumbhar, <nnkumb...@gmail.com> wrote:
Hello,

I want to get my current running job name without build number.  [Because I do not have build number]
How can I do that?

Thank you in advance!

--
You received this message because you are subscribed to the Google Groups "Jenkins Developers" group.
To unsubscribe from this group and stop receiving emails from it, send an email to jenkin...@googlegroups.com.

Gavin Mogan

unread,
Aug 11, 2019, 3:13:41 AM8/11/19
to jenkin...@googlegroups.com

You can call run.getId() will give you the build Id
run.getParent().getId()


I'm not sure where you are not having the build number.


To unsubscribe from this group and stop receiving emails from it, send an email to jenkinsci-de...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/jenkinsci-dev/217e7825-fda6-420b-ba5f-b640ab6cf1a4%40googlegroups.com.

Navnath Kumbhar

unread,
Aug 11, 2019, 3:57:20 AM8/11/19
to Jenkins Developers
Thank you Gavin. But I want this job name when I am in job config page. And there I do not have "run" object. This is the scenario. Is there any other alternative that I use to get job name when I am inside the config page?


On Sunday, 11 August 2019 12:43:41 UTC+5:30, Gavin Mogan wrote:

You can call run.getId() will give you the build Id
run.getParent().getId()


I'm not sure where you are not having the build number.


On Sat, Aug 10, 2019 at 11:54 PM Navnath Kumbhar <nnkumb...@gmail.com> wrote:
No, it is not a pipeline plugin. It is simple plugin with which adds a custom build step. Link to wiki : https://wiki.jenkins.io/display/JENKINS/Reqtify+Plugin

On Saturday, 10 August 2019 21:58:35 UTC+5:30, Gavin Mogan wrote:
In what context? Are you building a pipeline plugin? You should have access to just about everything.

On Sat., Aug. 10, 2019, 5:04 a.m. Navnath Kumbhar, <nnkumb...@gmail.com> wrote:
Hello,

I want to get my current running job name without build number.  [Because I do not have build number]
How can I do that?

Thank you in advance!

--
You received this message because you are subscribed to the Google Groups "Jenkins Developers" group.
To unsubscribe from this group and stop receiving emails from it, send an email to jenkin...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/jenkinsci-dev/cc54491c-6123-4517-a016-615c209e7a1e%40googlegroups.com.

--
You received this message because you are subscribed to the Google Groups "Jenkins Developers" group.
To unsubscribe from this group and stop receiving emails from it, send an email to jenkin...@googlegroups.com.

Robert Sandell

unread,
Aug 12, 2019, 10:27:01 AM8/12/19
to jenkin...@googlegroups.com
If your code is running in an http request thread, which it normally is when a user is visiting a config page you can ask Stapler for the current ancestor path;

Stapler.getCurrentRequest().findAncestorObject(Job.class)

/B

To unsubscribe from this group and stop receiving emails from it, send an email to jenkinsci-de...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/jenkinsci-dev/1dd02966-7c54-4e56-8fda-c18f8b4b0aaf%40googlegroups.com.


--
Robert Sandell
Software Engineer
CloudBees, Inc.
CloudBees-Logo.png
Twitter: robert_sandell

Jesse Glick

unread,
Aug 12, 2019, 12:54:46 PM8/12/19
to Jenkins Dev
On Mon, Aug 12, 2019 at 10:27 AM Robert Sandell <rsan...@cloudbees.com> wrote:
> If your code is running in an http request thread, which it normally is when a user is visiting a config page you can ask Stapler for the current ancestor path;
>
> Stapler.getCurrentRequest().findAncestorObject(Job.class)

Or if you are writing a web method (`doFillXXX` etc.), just add a parameter

@AncestorInPath Job job

If this is part of a `config.jelly`, the variable `instance` will
normally refer to the `Job`.

In all cases you must check for null, in case your code is running in
some other context, such as `http://jenkins/pipeline-syntax/` where
there is no particular associated `Job` object.
Reply all
Reply to author
Forward
0 new messages