• Icon: Bug Bug
    • Resolution: Cannot Reproduce
    • Icon: Major Major
    • warnings-plugin
    • None
    • Jenkins 1.580.1, plugin is CI version 4.44 downloaded on 11/5

      variables Warning_Count, Warning_Result and most likely others are not showing correct values.

      Setup is 3 Warning Parsers, MSBuild, Robocopy, and a custom one. When run many warnings are found in all the types but when trying to use Variables Count always shows 0 and Results always shows Succss

          [JENKINS-25501] Results not being propagated to ENV variables

          Ulli Hafner added a comment - - edited

          Did you use it as ENV variable or as token with the https://wiki.jenkins-ci.org/display/JENKINS/Token+Macro+Plugin?

          Ulli Hafner added a comment - - edited Did you use it as ENV variable or as token with the https://wiki.jenkins-ci.org/display/JENKINS/Token+Macro+Plugin?

          Jon Starbird added a comment -

          I tried the ENV method and without it. Neither works.

          Jon Starbird added a comment - I tried the ENV method and without it. Neither works.

          Ulli Hafner added a comment -

          Ok thanks. I'll first try to add a test case to our acceptance test suite https://github.com/jenkinsci/acceptance-test-harness.
          What would be the best way to verify that the tokens are correctly set? How can one access these tokens, (I never consumed them yet)?

          Ulli Hafner added a comment - Ok thanks. I'll first try to add a test case to our acceptance test suite https://github.com/jenkinsci/acceptance-test-harness . What would be the best way to verify that the tokens are correctly set? How can one access these tokens, (I never consumed them yet)?

          Jon Starbird added a comment -

          You can use Batch or Powershell or pretty much anything that can access Environment variables.
          For example if you put his into a Windows batch script and run it you'll get the values for all the WARNINGS variables.

          SET WARNINGS

          That will list them out in Jenkins console for the build.

          Or you can use the Jenkins tokens in a build Email and email them to yourself.
          To test I just used both, ${WARNINGS_COUNT} and ${ENV,var="WARNING_COUNT"} with a text tag before each one and then just waited for an email.
          Of course you also need something to have Warnings in it.

          I used a previous build log that had MSBuild warnings in it. Then set the Warnings scanner to use the file instead of the workspace.

          Jon Starbird added a comment - You can use Batch or Powershell or pretty much anything that can access Environment variables. For example if you put his into a Windows batch script and run it you'll get the values for all the WARNINGS variables. SET WARNINGS That will list them out in Jenkins console for the build. Or you can use the Jenkins tokens in a build Email and email them to yourself. To test I just used both, ${WARNINGS_COUNT} and ${ENV,var="WARNING_COUNT"} with a text tag before each one and then just waited for an email. Of course you also need something to have Warnings in it. I used a previous build log that had MSBuild warnings in it. Then set the Warnings scanner to use the file instead of the workspace.

          Code changed in jenkins
          User: Ulli Hafner
          Path:
          src/test/java/plugins/AbstractAnalysisTest.java
          src/test/java/plugins/CheckStylePluginTest.java
          src/test/java/plugins/FindbugsPluginTest.java
          src/test/java/plugins/PmdPluginTest.java
          src/test/java/plugins/TaskScannerPluginTest.java
          src/test/java/plugins/WarningsPluginTest.java
          http://jenkins-ci.org/commit/acceptance-test-harness/0fb931ed51111147e9adf9bbd0449a549346d8eb
          Log:
          JENKINS-25501 Added test case verifying that tokens are correctly produced and consumed.

          SCM/JIRA link daemon added a comment - Code changed in jenkins User: Ulli Hafner Path: src/test/java/plugins/AbstractAnalysisTest.java src/test/java/plugins/CheckStylePluginTest.java src/test/java/plugins/FindbugsPluginTest.java src/test/java/plugins/PmdPluginTest.java src/test/java/plugins/TaskScannerPluginTest.java src/test/java/plugins/WarningsPluginTest.java http://jenkins-ci.org/commit/acceptance-test-harness/0fb931ed51111147e9adf9bbd0449a549346d8eb Log: JENKINS-25501 Added test case verifying that tokens are correctly produced and consumed.

          Ulli Hafner added a comment -

          I finally managed it to set up some test cases. All tests are running quite well, so I think we are talking about different things in this issue. The analysis plugins only produce tokens for the token macro plugin. These tokens can then be consumed by supporting plugins (like email-ext). I.e. you can use ${WARNINGS_COUNT} as content of the mail subject or body. These tokens are not available as environment variables.

          Ulli Hafner added a comment - I finally managed it to set up some test cases. All tests are running quite well, so I think we are talking about different things in this issue. The analysis plugins only produce tokens for the token macro plugin. These tokens can then be consumed by supporting plugins (like email-ext). I.e. you can use ${WARNINGS_COUNT} as content of the mail subject or body. These tokens are not available as environment variables.

          Jon Starbird added a comment -

          Ok. I didn't know that. However, I put them into the email-ext one and still don't get the correct values.
          I'll try it again today. I have all plugins you've mentioned and the latest versions, based on the Long-term Support Release of Jenkins.

          Jon Starbird added a comment - Ok. I didn't know that. However, I put them into the email-ext one and still don't get the correct values. I'll try it again today. I have all plugins you've mentioned and the latest versions, based on the Long-term Support Release of Jenkins.

          Ulli Hafner added a comment -

          You need to use the latest warnings plugin 4.44 (this contains the fix of the snapshot version you have tested).

          Is there a plugin that exposes tokens as environment variables?

          Ulli Hafner added a comment - You need to use the latest warnings plugin 4.44 (this contains the fix of the snapshot version you have tested). Is there a plugin that exposes tokens as environment variables?

          Jon Starbird added a comment -

          No. What I was doing for my testing was using the Tokens Macro values and saving them into Environment variables.
          But for the emails I was using only the Tokens. I'll try it again this afternoon.

          Jon Starbird added a comment - No. What I was doing for my testing was using the Tokens Macro values and saving them into Environment variables. But for the emails I was using only the Tokens. I'll try it again this afternoon.

          Jon Starbird added a comment -

          Ok it is working in emails now, thanks.

          Question, what I'm trying to accomplish is I only want my build to Fail or be Unstable with MSBuild warnings but I want the reports for Robocopy and a homemade parser to still be produced. So what I was doing was using the Conditional Multi Step task to run Warnings earlier in the build to get my MSBuild Warnings and then was trying to save those results out and that is where I was trying to put the values saved out as Environment Variables.

          Is there any way for to get those separate values out??

          Jon Starbird added a comment - Ok it is working in emails now, thanks. Question, what I'm trying to accomplish is I only want my build to Fail or be Unstable with MSBuild warnings but I want the reports for Robocopy and a homemade parser to still be produced. So what I was doing was using the Conditional Multi Step task to run Warnings earlier in the build to get my MSBuild Warnings and then was trying to save those results out and that is where I was trying to put the values saved out as Environment Variables. Is there any way for to get those separate values out??

            drulli Ulli Hafner
            jstarbird Jon Starbird
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated:
              Resolved: