-
Bug
-
Resolution: Fixed
-
Minor
-
None
-
Jenkins 1.656
Centos 5
Warnings plugin 2.52
-
Powered by SuggestiMate
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
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.
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};
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?)
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.
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.
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
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.
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?
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...
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
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
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.
When you are reopening an issue it makes sense to write a comment why it is not solved. Or why it happens again.
Hmm, this has been implemented in https://github.com/jenkinsci/warnings-plugin/pull/33.