I would like to access variables from the Jenkins job console output on a different server using REST API. How can I archive this. Jenkins job runs on server A and I would like to read or get all variables on Server B. There is no connection between server A and server B.
Asked
Active
Viewed 3,747 times
2 Answers
0
There is no connection between server A and server B.
Hopefully, there is enough a connection to allow a curl.
That would allow to curl a property file that server A job would have generated, in order to write the variables (and for the curl to fetch them)
See this solution as an example, using the publisher artifact method of the Jenkins Job DSL API.

VonC
- 1,262,500
- 529
- 4,410
- 5,250
-
Jenkins job runs on server A, after every successful build I want to trigger a script on another server B ( I do not want to hard code any build numbers or anything in the url while using the curl command. env variables of Jenkins successful build should be available to my script on server B. However, this above method is asking to enter the credentials. Is there any way not to use username and password method. thanks again for your help – Learing Always Apr 22 '19 at 17:52
-
@LearingAlways You could use an Jenkins API token (https://stackoverflow.com/a/45466184/6309) to be used in your curl call (https://stackoverflow.com/a/26619131/6309) – VonC Apr 22 '19 at 18:06
-
Unfortunately, the production version of Jenkins at my work place is 2.10 :( .... and the link that is given is 2.129 – Learing Always Apr 22 '19 at 22:44
0
You can do it with the API of the EnvInject plugin with:
curl <jenkins-host>/job/<job_name>/<buildNumber>/injectedEnvVars/export
Already answered here.

Aníbal
- 785
- 8
- 24