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

Warnings plugin doesn't allow environment variables in file names

    • Icon: Bug Bug
    • Resolution: Fixed
    • Icon: Minor Minor
    • warnings-plugin
    • None
    • Jenkins 1.656
      Centos 5
      Warnings plugin 2.52

      When configuring file names to be scanned for compiler warnings, it would be good to be able to use build environment variables (similar to other fields e.g. the Command field in an Execute Shell box).

      I'd like to be able to enter "${CLEARCASE_VIEWPATH}/vobs/somePath/build_output" into the File Pattern field of Scan Workspace Files. But it doesn't expand the ${CLEARCASE_VIEWPATH}.

      I can work around it by using "*/vobs/somePath/build_output" as that filename is unique. But I shouldn't have to.

          [JENKINS-34157] Warnings plugin doesn't allow environment variables in file names

          Ulli Hafner added a comment -

          Hmm, this has been implemented in https://github.com/jenkinsci/warnings-plugin/pull/33.

          Ulli Hafner added a comment - Hmm, this has been implemented in https://github.com/jenkinsci/warnings-plugin/pull/33 .

          I can use Build Parameters but not env variables.

          Anna Freiholtz added a comment - I can use Build Parameters but not env variables.

          Ulli Hafner added a comment -

          I see. I thought both types are expanded by the API.

          Ulli Hafner added a comment - I see. I thought both types are expanded by the API.

          Do you think it is doable to handle env variables as well?

          Anna Freiholtz added a comment - Do you think it is doable to handle env variables as well?

          Ulli Hafner added a comment -

          Of course. The current expansion just needs to be replaced with a different API call. I need to look into some other plug-ins how these are done...

          Ulli Hafner added a comment - Of course. The current expansion just needs to be replaced with a different API call. I need to look into some other plug-ins how these are done...

          Code changed in jenkins
          User: Ulli Hafner
          Path:
          src/test/java/plugins/WarningsPluginTest.java
          http://jenkins-ci.org/commit/acceptance-test-harness/11b0e681946950461406e9fd4e4bd35211f85347
          Log:
          JENKINS-34157 Added test case that shows that environment variabes are expanded.

          SCM/JIRA link daemon added a comment - Code changed in jenkins User: Ulli Hafner Path: src/test/java/plugins/WarningsPluginTest.java http://jenkins-ci.org/commit/acceptance-test-harness/11b0e681946950461406e9fd4e4bd35211f85347 Log: JENKINS-34157 Added test case that shows that environment variabes are expanded.

          Ulli Hafner added a comment -

          In my test environment variables are correctly expanded.

          How is your environment variable set?

          Can you add a build step that echoes the variable?

          echo value=${CLEARCASE_VIEWPATH};
          

          Ulli Hafner added a comment - In my test environment variables are correctly expanded. How is your environment variable set? Can you add a build step that echoes the variable? echo value=${CLEARCASE_VIEWPATH};

          Ulli Hafner added a comment -

          Or maybe the problem is the place of the expansion!

          Where should the environment variable be expanded? On master or slave? (I.e. which node has the correct value?)

          Ulli Hafner added a comment - Or maybe the problem is the place of the expansion! Where should the environment variable be expanded? On master or slave? (I.e. which node has the correct value?)

          Anna Freiholtz added a comment - - edited

          My Jenkins job runs on three slaves, each with two threads. I use a custom workspace where each build gets its own directory. The directory is named using the Jenkins environment variable BUILD_NUMBER and a parameter.

          I would like to scan a workspace file, but since BUILD_NUMBER is not expanded the file is not found.

          Anna Freiholtz added a comment - - edited My Jenkins job runs on three slaves, each with two threads. I use a custom workspace where each build gets its own directory. The directory is named using the Jenkins environment variable BUILD_NUMBER and a parameter. I would like to scan a workspace file, but since BUILD_NUMBER is not expanded the file is not found.

          Code changed in jenkins
          User: Ulli Hafner
          Path:
          src/test/java/plugins/WarningsPluginTest.java
          http://jenkins-ci.org/commit/acceptance-test-harness/34ccddbd9c8a1fa32d630647e09c2fab9a7caeb3
          Log:
          JENKINS-34157 Added expansion of BUILD_NUMBER to test.

          SCM/JIRA link daemon added a comment - Code changed in jenkins User: Ulli Hafner Path: src/test/java/plugins/WarningsPluginTest.java http://jenkins-ci.org/commit/acceptance-test-harness/34ccddbd9c8a1fa32d630647e09c2fab9a7caeb3 Log: JENKINS-34157 Added expansion of BUILD_NUMBER to test.

          Code changed in jenkins
          User: Ulli Hafner
          Path:
          src/test/java/plugins/WarningsPluginTest.java
          http://jenkins-ci.org/commit/acceptance-test-harness/8b6dd81e4343c419c10a2cf60bfdf90887522232
          Log:
          JENKINS-34157 Let test run on a slave.

          SCM/JIRA link daemon added a comment - Code changed in jenkins User: Ulli Hafner Path: src/test/java/plugins/WarningsPluginTest.java http://jenkins-ci.org/commit/acceptance-test-harness/8b6dd81e4343c419c10a2cf60bfdf90887522232 Log: JENKINS-34157 Let test run on a slave.

          Ulli Hafner added a comment - - edited

          Hmm, the test expands everything. Can you please paste the [WARNINGS] part of the console log? There should be something like:

          [WARNINGS] Parsing warnings in files '**/compile-log.txt' with parser Clang (LLVM based)
          [WARNINGS] Finding all files that match the pattern **/compile-log.txt
          [WARNINGS] Parsing 1 file in /var/folders/yj/bbp1px3x0wnfqd56p4hnv2b00000gn/T/complex_target/workspace/welcome_ritual
          [WARNINGS] Successfully parsed file /var/folders/yj/bbp1px3x0wnfqd56p4hnv2b00000gn/T/complex_target/workspace/welcome_ritual/compile-log.txt with 10 unique warnings and 0 duplicates.
          [WARNINGS] Parsing warnings in files '1/nothing' with parser Java Compiler (javac)
          [WARNINGS] Finding all files that match the pattern 1/nothing
          

          The patterns in the test are defined as

          settings.addWorkspaceScanner(CLANG, "${ENV_PREFIX}/compile-log.txt");
          settings.addWorkspaceScanner(JAVA_COMPILER, "${BUILD_NUMBER}/nothing");
          

          Ulli Hafner added a comment - - edited Hmm, the test expands everything. Can you please paste the [WARNINGS] part of the console log? There should be something like: [WARNINGS] Parsing warnings in files '**/compile-log.txt' with parser Clang (LLVM based) [WARNINGS] Finding all files that match the pattern **/compile-log.txt [WARNINGS] Parsing 1 file in /var/folders/yj/bbp1px3x0wnfqd56p4hnv2b00000gn/T/complex_target/workspace/welcome_ritual [WARNINGS] Successfully parsed file /var/folders/yj/bbp1px3x0wnfqd56p4hnv2b00000gn/T/complex_target/workspace/welcome_ritual/compile-log.txt with 10 unique warnings and 0 duplicates. [WARNINGS] Parsing warnings in files '1/nothing' with parser Java Compiler (javac) [WARNINGS] Finding all files that match the pattern 1/nothing The patterns in the test are defined as settings.addWorkspaceScanner(CLANG, "${ENV_PREFIX}/compile-log.txt" ); settings.addWorkspaceScanner(JAVA_COMPILER, "${BUILD_NUMBER}/nothing" );

          My file pattern:

          ${BUILD_NUMBER}_${Reference}\ND4\ReleaseTools\Build\Log\warning.log
          
          

          where Reference is a build parameter.

          Console output:

          [WARNINGS] Parsing warnings in files '${BUILD_NUMBER}_master\ND4\ReleaseTools\Build\Log\warning.log' with parser Warning.log parser
          [WARNINGS] Finding all files that match the pattern ${BUILD_NUMBER}_master\ND4\ReleaseTools\Build\Log\warning.log
          [WARNINGS] Computing warning deltas based on reference build #1982_M01_13387_B
          
          

          Anna Freiholtz added a comment - My file pattern: ${BUILD_NUMBER}_${Reference}\ND4\ReleaseTools\Build\Log\warning.log where Reference is a build parameter. Console output: [WARNINGS] Parsing warnings in files '${BUILD_NUMBER}_master\ND4\ReleaseTools\Build\Log\warning.log' with parser Warning.log parser [WARNINGS] Finding all files that match the pattern ${BUILD_NUMBER}_master\ND4\ReleaseTools\Build\Log\warning.log [WARNINGS] Computing warning deltas based on reference build #1982_M01_13387_B

          Code changed in jenkins
          User: Ulli Hafner
          Path:
          src/test/java/plugins/WarningsPluginTest.java
          http://jenkins-ci.org/commit/acceptance-test-harness/5dda784528e28ce1a5c67446fd728656a97b1542
          Log:
          JENKINS-34157 Added expansion of build parameters to test.

          SCM/JIRA link daemon added a comment - Code changed in jenkins User: Ulli Hafner Path: src/test/java/plugins/WarningsPluginTest.java http://jenkins-ci.org/commit/acceptance-test-harness/5dda784528e28ce1a5c67446fd728656a97b1542 Log: JENKINS-34157 Added expansion of build parameters to test.

          Ulli Hafner added a comment -

          I still can't reproduce this. I added now your pattern in the testcase, however everything is correctly expanded.

          Is there still anything missing in the test what is different to your setup?

          How is your BUILD_NUMBER variable computed? Seems that it does contain a totally strange input. Maybe that is the problem?

          Ulli Hafner added a comment - I still can't reproduce this. I added now your pattern in the testcase , however everything is correctly expanded. Is there still anything missing in the test what is different to your setup? How is your BUILD_NUMBER variable computed? Seems that it does contain a totally strange input. Maybe that is the problem?

          Anna Freiholtz added a comment - BUILD_NUMBER is a built in Jenkins environment variable: https://wiki.jenkins-ci.org/display/JENKINS/Building+a+software+project#Buildingasoftwareproject-below

          Ulli Hafner added a comment - - edited

          Yes, I know. I already used in my test. But your number looks quite strange: #1982_M01_13387_B. Is this value changed by a plug-in?

          Ulli Hafner added a comment - - edited Yes, I know. I already used in my test. But your number looks quite strange: #1982_M01_13387_B. Is this value changed by a plug-in?

          Ah, I see.

          1982 is the previous build number. I create a directory for each build using <BUILD_NUMBER>_<Reference> where reference could be M01_13387_B, master or something similar.

          So it seems to me it is only in the setting for file pattern the environment variable is not working for me. But since you cannot reproduce the error, I'm beginning to suspect there is something else interfering...

          Anna Freiholtz added a comment - Ah, I see. 1982 is the previous build number. I create a directory for each build using <BUILD_NUMBER>_<Reference> where reference could be M01_13387_B, master or something similar. So it seems to me it is only in the setting for file pattern the environment variable is not working for me. But since you cannot reproduce the error, I'm beginning to suspect there is something else interfering...

          Ulli Hafner added a comment - - edited

          Do you have a plug-in installed, that changes the build number? Or that works with environment variables?

          Can you add an additional build step (shell command) after your build that just echoes the value of BUILD_NUMBER? Just to be sure...

          echo $BUILD_NUMBER
          

          Ulli Hafner added a comment - - edited Do you have a plug-in installed, that changes the build number? Or that works with environment variables? Can you add an additional build step (shell command) after your build that just echoes the value of BUILD_NUMBER? Just to be sure... echo $BUILD_NUMBER

          Anna Freiholtz added a comment - - edited

          I couldn't shell command, I don't know why. (We never use shell in Jenkins.) So I added a build step Execute Windows Batch Command instead:

          echo %BUILD_NUMBER%
          

          Console output:

          D:\Q1>echo 2186 
          2186
          
          D:\Q1>exit 0 
          [WARNINGS] Parsing warnings in files '${BUILD_NUMBER}_master\ND4\ReleaseTools\Build\Log\warning.log' with parser Warning.log parser
          [WARNINGS] Finding all files that match the pattern ${BUILD_NUMBER}_master\ND4\ReleaseTools\Build\Log\warning.log
          [WARNINGS] Computing warning deltas based on reference build #2181_TP_10564
          

          2181 is the previous successful build.

          My Jenkins job also use the plugin for injecting env variables.

          Anna Freiholtz added a comment - - edited I couldn't shell command, I don't know why. (We never use shell in Jenkins.) So I added a build step Execute Windows Batch Command instead: echo %BUILD_NUMBER% Console output: D:\Q1>echo 2186 2186 D:\Q1>exit 0 [WARNINGS] Parsing warnings in files '${BUILD_NUMBER}_master\ND4\ReleaseTools\Build\Log\warning.log' with parser Warning.log parser [WARNINGS] Finding all files that match the pattern ${BUILD_NUMBER}_master\ND4\ReleaseTools\Build\Log\warning.log [WARNINGS] Computing warning deltas based on reference build #2181_TP_10564 2181 is the previous successful build. My Jenkins job also use the plugin for injecting env variables.

          I tested to create a new Jenkins job where the only build step is

          echo %BUILD_NUMBER%
          

          Console output:

          d:\JenkinsSlave\workspace\TestWarningPlugin>echo 2 
          2
          
          d:\JenkinsSlave\workspace\TestWarningPlugin>exit 0 
          [WARNINGS] Parsing warnings in files '${BUILD_NUMBER}' with parser Texas Instruments Code Composer Studio (C/C++)
          [WARNINGS] Finding all files that match the pattern ${BUILD_NUMBER}
          [WARNINGS] Computing warning deltas based on reference build #1
          

          Anna Freiholtz added a comment - I tested to create a new Jenkins job where the only build step is echo %BUILD_NUMBER% Console output: d:\JenkinsSlave\workspace\TestWarningPlugin>echo 2 2 d:\JenkinsSlave\workspace\TestWarningPlugin>exit 0 [WARNINGS] Parsing warnings in files '${BUILD_NUMBER}' with parser Texas Instruments Code Composer Studio (C/C++) [WARNINGS] Finding all files that match the pattern ${BUILD_NUMBER} [WARNINGS] Computing warning deltas based on reference build #1

          Ulli Hafner added a comment -

          I see. Maybe expansion does not work in the same way on Windows. I'm not sure if I can setup a test fixture that uses a Windows slave.

          Ulli Hafner added a comment - I see. Maybe expansion does not work in the same way on Windows. I'm not sure if I can setup a test fixture that uses a Windows slave.

          I apologize, I was under the impression that I had installed the latest version of the plugin. But I hadn't... Now I have updated the plugin and it is working! Sorry again.

          Anna Freiholtz added a comment - I apologize, I was under the impression that I had installed the latest version of the plugin. But I hadn't... Now I have updated the plugin and it is working! Sorry again.

          Ulli Hafner added a comment -

          When you are reopening an issue it makes sense to write a comment why it is not solved. Or why it happens again.

          Ulli Hafner added a comment - When you are reopening an issue it makes sense to write a comment why it is not solved. Or why it happens again.

            drulli Ulli Hafner
            gfim Graham Menhennitt
            Votes:
            1 Vote for this issue
            Watchers:
            4 Start watching this issue

              Created:
              Updated:
              Resolved: