Como leer el build number de jenkins y otros parametros de Jenkins

Como leer el build number de jenkins y otros parametros de Jenkins

Despues de buscar como leer o saber el ultimo build number de jenkins en java, encontre una manera bien facil de hacerlo, encontre en esta pagina https://wiki.jenkins-ci.org/display/JENKINS/EnvInject+Plugin, que se tiene una variables de ambiente q se pueden leer con cURL
para bajar cURL para 32 bits http://curl.haxx.se/dlwiz/?type=bin&os=Win32&flav=-&ver=-
para bajar cURL para 64 bits http://curl.haxx.se/dlwiz/?type=bin&os=Win64&flav=-

--------------------------------------------------------------------------------------------------------------------
Variables Traceability

Each build captures environment variables and stores them in an environment file called 'injectedEnvVars.txt' located in
$JENKINS_HOME/jobs/<your_job>/builds/<your_build>.

For an old build, you can display injected environment variables through the right UI menu on the build page.

You can also get build environment variables by the following HTTP GET URL: <jenkins_url>/job/<job_name>/<build_number>/injectedEnvVars/export
XML, JSON and TXT format are supported.
For example:
curl -X GET H"Accept:text/plain" <jenkins_url>/job/<job_name>//lastBuild/injectedEnvVars/export
curl -X GET H"Accept:application/xml" <jenkins_url>/job/<job_name>//18/injectedEnvVars/export
curl -X GET H"Accept:application/json" <jenkins_url>/job/<job_name>//18/injectedEnvVars/export ------------------------------------------------------------------------------------------------------------------------

 Lo probe y me sale un error asi q le quite H"Accept:text/plain"
curl -X GET <jenkins_url>/job/<job_name>//lastBuild/injectedEnvVars/export

 C:\Program Files\cURL\bin>curl -X GET http://jenkins.soft.local:8080/job/XDS/S
erverTest=master/lastSuccessfulBuild/injectedEnvVars/export

ARTIFACTORY_HOME=/usr/local/artifactory
BUILD_CAUSE=UPSTREAMTRIGGER
BUILD_CAUSE_UPSTREAMTRIGGER=true
BUILD_DISPLAY_NAME=#337
BUILD_ID=2015-01-16_02-52-44
BUILD_NUMBER=337
BUILD_TAG=jenkins-XDS-ServerTest=master-337
BUILD_URL=http://jenkins.soft.local:8080/job/XDS/ServerTest=master/337/
EXECUTOR_NUMBER=0
GRADLE_OPTS=-Xmx1024m -XX:MaxPermSize=256m
GRADLE_USER_HOME=/var/lib/jenkins/.gradle
HOME=/var/lib/jenkins
HUDSON_HOME=/var/lib/jenkins
HUDSON_SERVER_COOKIE=434a955acd8b5416
HUDSON_URL=http://jenkins.soft.local:8080/
JAVA_HOME=/usr/lib/jvm/java-7-openjdk-amd64
JENKINS_HOME=/var/lib/jenkins
JENKINS_SERVER_COOKIE=434a955acd8b5416
JENKINS_URL=http://jenkins.soft.local:8080/
JOB_NAME=XDS/ServerTest=master
JOB_URL=http://jenkins.soft.local:8080/job/XDS/ServerTest=master/
LANG=en_US.UTF-8
LOGNAME=jenkins
MAIL=/var/mail/jenkins
NODE_LABELS=master
NODE_NAME=
PATH=/usr/local/bin:/usr/bin:/bin:/usr/local/games:/usr/games:/usr/local/go/bin
PWD=/var/lib/jenkins
SHELL=/bin/bash
SHLVL=1
ServerTest=master
TERM=linux
USER=jenkins
_=/usr/bin/daemon

C:\Program Files\cURL\bin>

Comentarios