Saita
Saita

Reputation: 1044

Jenkins - get EnvInject Plugin info by rest api

I am using https://wiki.jenkins.io/display/JENKINS/EnvInject+Plugin 1.93.1 in my Jenkins installation.

I need to fetch the EnvInject properties configuration for every job I have, but I can't seem to find a way to do this in the job rest api.

The way I figured to do this is by fetching the last build for every job and then hit the injectedEnvVars/api/.

This strategy is not optimal because I have to do a request for every job, and that is taking too long (4000+ jobs).

Am I missing something? Is there a way to fetch the envInject properties together with the job information?

Upvotes: 0

Views: 305

Answers (1)

yong
yong

Reputation: 13712

If you think send 4000 HTTP requests is not effective, You can iterate the JENKINS_HOME folder on Jenkins Master.

Following picture illustrate the structure for injectedEnvVars.txt which stores the value of EnvInject.

  1. .jenkins is JENKINS_HOME folder
  2. fetch-envinject-value is jenkins job
  3. builds/1 is the 1st job build
  4. builds/1/injectedEnvVars.txt is all environment variables for this job build.

enter image description here

Upvotes: 1

Related Questions