get build number

54 views
Skip to first unread message

Thilina Madhusanka

unread,
Sep 3, 2015, 2:30:20 AM9/3/15
to Jenkins Developers
hi

Is there a method to retrieve current  build number for a plugin to use. ?

thanks

Victor Martinez

unread,
Sep 3, 2015, 2:40:49 AM9/3/15
to Jenkins Developers
Hi,

 It depends on what you need to do. Check the below javadoc:

 - From a particular Jenkins job you can query its latest build: http://javadoc.jenkins-ci.org/hudson/model/AbstractProject.html#getLastBuild()
 
 - From a particular Job build you can query its current build number: http://javadoc.jenkins-ci.org/hudson/model/Run.html#number

Cheers

Thilina Madhusanka

unread,
Sep 3, 2015, 4:27:42 AM9/3/15
to Jenkins Developers
Hi

thanks for the reply

im new to this. my plugin will start as a post build option in jenkis so which  methods should i use? 

can u tell me how can i get the number in string or int format?

thanks.

Victor Martinez

unread,
Sep 3, 2015, 6:11:50 AM9/3/15
to Jenkins Developers
Alright, 

Are you developing a new jenkins plugin? Or you mean configuring a jenkins job? If so, please refs the below page:


And also use jenkinsci-users mailing list or IRC for such topics since this mailing list is for Jenkins core and plugins development discussions

Cheers

Thilina Madhusanka

unread,
Sep 3, 2015, 6:21:35 AM9/3/15
to Jenkins Developers
Hi

im trying to modify a plugin, that plugin generate a report i need to add the build number to the report name

thanks

Christopher Orr

unread,
Sep 3, 2015, 8:35:16 AM9/3/15
to jenkin...@googlegroups.com
Most likely the plugin has a perform() method with an AbstractBuild.

Call getNumber() on the build.

http://javadoc.jenkins-ci.org/hudson/tasks/BuildStepCompatibilityLayer.html#perform(hudson.model.AbstractBuild,
hudson.Launcher, hudson.model.BuildListener)
http://javadoc.jenkins-ci.org/hudson/model/Run.html#getNumber()
> --
> 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
> <mailto:jenkinsci-de...@googlegroups.com>.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/jenkinsci-dev/3ececc8d-e84b-4233-8ac6-104e1dc152f5%40googlegroups.com
> <https://groups.google.com/d/msgid/jenkinsci-dev/3ececc8d-e84b-4233-8ac6-104e1dc152f5%40googlegroups.com?utm_medium=email&utm_source=footer>.
> For more options, visit https://groups.google.com/d/optout.

Thilina Madhusanka

unread,
Sep 13, 2015, 11:16:32 PM9/13/15
to Jenkins Developers
Hi

thanks a lot. 

Thilina.
Reply all
Reply to author
Forward
0 new messages