Uploaded image for project: 'Jenkins'
  1. Jenkins
  2. JENKINS-17875

Make Jenkins environment variables available to dynamic providers

XMLWordPrintable

      For the dynamic providers (Shell, Groovy) it should be possible to get information about the current job.

      Example:
      When triggering a parameterized build job, the System Groovy script, which is executed to collect the choices, should be able to get the name of the current job. With the prefix of the current job we want to find all jobs that have the same prefix and make them available as choices.
      The job "prefix-admin-create-branch-job" executes a System Groovy script to collect all jobs with the same "prefix". The user selects one of the jobs to copy a job for a new subversion branch.

      I could not find a way how to get the name during the extensible choice provider execution. Later during the build (Ant, Maven, ...), the environment variable "JOB_NAME" is accessible, but it has not been set when the extensible choice parameter plugin is executed.

      Jenkins has a longer list of environment variables:
      https://wiki.jenkins-ci.org/display/JENKINS/Building+a+software+project#Buildingasoftwareproject-JenkinsSetEnvironmentVariables

      Environment variables could not be used for the System Groovy scripts as the script is not forked into a separate process and thus there is no chance to set the variables. For a shell provider this is possible, as the shell script is forked out into a new process anyway.

            ikedam ikedam
            mirumpf Michael Rumpf
            Votes:
            2 Vote for this issue
            Watchers:
            5 Start watching this issue

              Created:
              Updated:
              Resolved: