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

Cannot get Jenkins environment variables from Custom stylesheets when using Custom tool configuration

    • Icon: Bug Bug
    • Resolution: Not A Defect
    • Icon: Minor Minor
    • xunit-plugin
    • None
    • Jenkins 2.235.5
      xunit-plugin 2.3.9

      Cannot get Jenkins environment variables from Custom stylesheets when using Custom tool configuration

      Since XLST 3.0 there are two functions to get environment variables within a stylesheet 
      (available-environment-variables and environment-variable)
      I can access to the regular system environment variables but no the environment variables set by Jenkins such as JENKINS_URL, JOB_URL, BUILD_NUMBER, ....

      I've tested with Freestyle jobs and pipeline jobs in Windows and Linux with the same results.

      An example with pipeline:

      pipeline {
          agent  any
          stages {
              stage('Build') { 
                  steps {
                  xunit([Custom(customXSL: 'transform.xslt', deleteOutputFiles: false, failIfNotNew: false, pattern: 'aresult.xml', skipNoTestFiles: false, stopProcessingIfError: false)]) 
       
                  }
              }
          }  
      }
      

      Check the xml file generated in generatedJUnitFiles/ folder. It doesn't list the Jenkins environment variables
       

          [JENKINS-63594] Cannot get Jenkins environment variables from Custom stylesheets when using Custom tool configuration

          Nikolas Falco added a comment - - edited

          The jenkins build variable are not enviroment variable. If so all the JVM will share the same variable but different value for each job. Some plugin like Shell o BachFile can creates a new environment adding those build variables just because they execute an external process.

          In this case like in other plugins is not possible, they are executed inside the agent/master JVM node. What usually is done is a token replace using variables injected by jenkins or other plugins in the plugin configurations (for example in Custom XML path -> $JENKINS_ROOT/..../transform.xslt)

          Nikolas Falco added a comment - - edited The jenkins build variable are not enviroment variable. If so all the JVM will share the same variable but different value for each job. Some plugin like Shell o BachFile can creates a new environment adding those build variables just because they execute an external process. In this case like in other plugins is not possible, they are executed inside the agent/master JVM node. What usually is done is a token replace using variables injected by jenkins or other plugins in the plugin configurations (for example in Custom XML path -> $JENKINS_ROOT/..../transform.xslt)

            nfalco Nikolas Falco
            jaruzafa jaruzafa
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved: