Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to get the jobname from jenkins

Tags:

jenkins

Is there a way to get the jobname for the current build in jenkins and pass it as a parameter to an ant build script?

like image 242
kidloco Avatar asked Nov 29 '11 10:11

kidloco


People also ask

How do I find the build number of Jenkins?

BUILD_NUMBER is the current build number. You can use it in the command you execute for the job, or just use it in the script your job executes. See the Jenkins documentation for the full list of available environment variables.

How do I get the current URL in Jenkins?

$BUILD_URL is the easiest way to do it, just add it in your Body mail and it will show the hyperlink of your latest build. Save this answer. Show activity on this post. Optionally specify the HTTP address of the Jenkins installation, such as http://yourhost.yourdomain/jenkins/.


1 Answers

Jenkins sets some environment variables such as JOB_NAME (see here) for more details on the variables set.

You can then access these in ant via ${env.JOB_NAME}.

Edit: There's also a little howto for environment variables on the same page here.

like image 180
Martin Foot Avatar answered Sep 18 '22 20:09

Martin Foot