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

[Email-ext plugin] ${ENV, var="FOO"} for 2.29 doesn't work anymore.

    Details

    • Similar Issues:

      Description

      After upgrading Email-ext plugin to 2.29 from 2.27.1 using the ${ENV, var="FOO"} format no longer works. $FOO does however. Once I reverted back to 2.27.1 it started working again.

        Attachments

          Issue Links

            Activity

            ericthefree Eric Freeman created issue -
            Hide
            slide_o_mix Alex Earl added a comment -

            Do you have the token-macro plugin installed?

            Show
            slide_o_mix Alex Earl added a comment - Do you have the token-macro plugin installed?
            Hide
            slide_o_mix Alex Earl added a comment -

            I just tried with 2.29 and I was able to use both formats. ${ENV, var="USERNAME"} and $USERNAME both worked and produced the correct output. You need to verify that token-macro is installed and enabled.

            Show
            slide_o_mix Alex Earl added a comment - I just tried with 2.29 and I was able to use both formats. ${ENV, var="USERNAME"} and $USERNAME both worked and produced the correct output. You need to verify that token-macro is installed and enabled.
            Hide
            ericthefree Eric Freeman added a comment -

            I do have the token-macro plugin installed. Is this a conflict causing an issue for me?

            Show
            ericthefree Eric Freeman added a comment - I do have the token-macro plugin installed. Is this a conflict causing an issue for me?
            Hide
            slide_o_mix Alex Earl added a comment -

            No, the email-ext plugin relies on the token-macro plugin. Please make sure token-macro is updated to 1.6

            Show
            slide_o_mix Alex Earl added a comment - No, the email-ext plugin relies on the token-macro plugin. Please make sure token-macro is updated to 1.6
            Hide
            ericthefree Eric Freeman added a comment -

            I have that plugin installed and is version 1.6. I updated to 2.9 again and still see the same issue. Now I can't downgrade to 2.27.1 and I'm broken again unless I update all these variables.

            Show
            ericthefree Eric Freeman added a comment - I have that plugin installed and is version 1.6. I updated to 2.9 again and still see the same issue. Now I can't downgrade to 2.27.1 and I'm broken again unless I update all these variables.
            Hide
            slide_o_mix Alex Earl added a comment -

            Is there anything in the jenkins log? I can't reproduce this with the 1.508.1 LTS (which is what email-ext is based on for core dependency) + email-ext 2.29 and token-macro 1.6

            Show
            slide_o_mix Alex Earl added a comment - Is there anything in the jenkins log? I can't reproduce this with the 1.508.1 LTS (which is what email-ext is based on for core dependency) + email-ext 2.29 and token-macro 1.6
            Hide
            ericthefree Eric Freeman added a comment -

            I have moved my Jenkins server back to 1.509.1...latest LTS. Same issue still exists.

            Show
            ericthefree Eric Freeman added a comment - I have moved my Jenkins server back to 1.509.1...latest LTS. Same issue still exists.
            Hide
            slide_o_mix Alex Earl added a comment -

            Can you attach your job's config.xml (after stripping username/passwords/etc).

            Show
            slide_o_mix Alex Earl added a comment - Can you attach your job's config.xml (after stripping username/passwords/etc).
            Hide
            ericthefree Eric Freeman added a comment -

            Attached.

            Show
            ericthefree Eric Freeman added a comment - Attached.
            ericthefree Eric Freeman made changes -
            Field Original Value New Value
            Attachment MyJobXML.xml [ 23668 ]
            Hide
            slide_o_mix Alex Earl added a comment -

            It's the \ in front of the $ I think. Token macro uses that as an escape character and the ENV token is now provided by the Token macro plugin.

            Show
            slide_o_mix Alex Earl added a comment - It's the \ in front of the $ I think. Token macro uses that as an escape character and the ENV token is now provided by the Token macro plugin.
            Hide
            ericthefree Eric Freeman added a comment -

            So now we have to go change this in all of our jobs that use this? If I disable the token macro, will it work as is again? Why can't you leave existing functionality as is?

            Show
            ericthefree Eric Freeman added a comment - So now we have to go change this in all of our jobs that use this? If I disable the token macro, will it work as is again? Why can't you leave existing functionality as is?
            Hide
            slide_o_mix Alex Earl added a comment -

            No, token macro is required for email-ext.

            Show
            slide_o_mix Alex Earl added a comment - No, token macro is required for email-ext.
            Hide
            slide_o_mix Alex Earl added a comment -

            I've been trying to figure out a way around this, as I know its frustrating, but because of the way that the tokens are implemented now (all tokens use the token macro plugin now), there really is no way around the way that Token Macro uses the escape. What issue did you have downgrading to 2.27.1?

            Show
            slide_o_mix Alex Earl added a comment - I've been trying to figure out a way around this, as I know its frustrating, but because of the way that the tokens are implemented now (all tokens use the token macro plugin now), there really is no way around the way that Token Macro uses the escape. What issue did you have downgrading to 2.27.1?
            Hide
            slide_o_mix Alex Earl added a comment -

            Changed token macro escape to use $$ instead of \$

            Show
            slide_o_mix Alex Earl added a comment - Changed token macro escape to use $$ instead of \$
            slide_o_mix Alex Earl made changes -
            Status Open [ 1 ] Resolved [ 5 ]
            Resolution Fixed [ 1 ]
            Hide
            ralf_rausch Ralf Rausch added a comment -

            When does the fix be available? I updated the token macro plugin to 1.7 and the email-ext-plugin to 2.30.2 but it still fails.

            Show
            ralf_rausch Ralf Rausch added a comment - When does the fix be available? I updated the token macro plugin to 1.7 and the email-ext-plugin to 2.30.2 but it still fails.
            Hide
            slide_o_mix Alex Earl added a comment -

            The issue that Eric was running into is that his ${ENV} token was preceeded by a \. The token itself works just fine. Please provide more information on your failure.

            Show
            slide_o_mix Alex Earl added a comment - The issue that Eric was running into is that his ${ENV} token was preceeded by a \. The token itself works just fine. Please provide more information on your failure.
            Hide
            ralf_rausch Ralf Rausch added a comment -

            I think it is the same issue.
            In the default content section of the editable email notification we defined this value: Server-Log-Files:
            ${ENV, var="COMPUTERNAME"}\logs\${PROJECT_NAME}.

            In the e-mail we get: Server-Log-Files:
            ${ENV, var="COMPUTERNAME"}\logs\${PROJECT_NAME} The ${ENV} and ${PROJECT_NAME} are not converted.

            Show
            ralf_rausch Ralf Rausch added a comment - I think it is the same issue. In the default content section of the editable email notification we defined this value: Server-Log-Files: ${ENV, var="COMPUTERNAME"}\logs\${PROJECT_NAME}. In the e-mail we get: Server-Log-Files: ${ENV, var="COMPUTERNAME"}\logs\${PROJECT_NAME} The ${ENV} and ${PROJECT_NAME} are not converted.
            Hide
            slide_o_mix Alex Earl added a comment -

            Strange, I'll take a look. I tested with the new token-macro and it passed this type of case.

            Show
            slide_o_mix Alex Earl added a comment - Strange, I'll take a look. I tested with the new token-macro and it passed this type of case.
            Hide
            slide_o_mix Alex Earl added a comment -

            Hmmm, looks like the escaping fix didn't make it into Token Macro. I may need to do the fix differently anyhow.

            Show
            slide_o_mix Alex Earl added a comment - Hmmm, looks like the escaping fix didn't make it into Token Macro. I may need to do the fix differently anyhow.
            ndeloof Nicolas De Loof made changes -
            Resolution Fixed [ 1 ]
            Status Resolved [ 5 ] Reopened [ 4 ]
            ndeloof Nicolas De Loof made changes -
            Link This issue is related to JENKINS-12685 [ JENKINS-12685 ]
            Hide
            ndeloof Nicolas De Loof added a comment - - edited

            I can't find any way to get the negative lookbehind

             (?<!\) 

            to also consider an odd number of \.
            I've tried

             (?<!\(\\){0,1}) 

            - as Java don't allow infinite lookbehinds - but then
            ${FOO} match.

            Show
            ndeloof Nicolas De Loof added a comment - - edited I can't find any way to get the negative lookbehind (?<!\) to also consider an odd number of \. I've tried (?<!\(\\){0,1}) - as Java don't allow infinite lookbehinds - but then ${FOO} match.
            Hide
            scm_issue_link SCM/JIRA link daemon added a comment -

            Code changed in jenkins
            User: Nicolas De Loof
            Path:
            src/test/java/org/jenkinsci/plugins/tokenmacro/TokenMacroTest.java
            http://jenkins-ci.org/commit/token-macro-plugin/46b3d2c8fdd0ff845b6f66a0e4e54d81ac8c0290
            Log:
            JENKINS-18014 unit test to reproduce issue

            Show
            scm_issue_link SCM/JIRA link daemon added a comment - Code changed in jenkins User: Nicolas De Loof Path: src/test/java/org/jenkinsci/plugins/tokenmacro/TokenMacroTest.java http://jenkins-ci.org/commit/token-macro-plugin/46b3d2c8fdd0ff845b6f66a0e4e54d81ac8c0290 Log: JENKINS-18014 unit test to reproduce issue
            Hide
            slide_o_mix Alex Earl added a comment -

            I've been trying to play with this as well, I haven't come up with a good solution yet. I am wondering if a "real" parser might be necessary, but I don't want to go down that route if possible.

            Show
            slide_o_mix Alex Earl added a comment - I've been trying to play with this as well, I haven't come up with a good solution yet. I am wondering if a "real" parser might be necessary, but I don't want to go down that route if possible.
            Hide
            danielbeck Daniel Beck added a comment - - edited

            What works for me is ${VARNAME} or $VARNAME instead of ${ENV, var="VARNAME"}.

            Show
            danielbeck Daniel Beck added a comment - - edited What works for me is ${VARNAME} or $VARNAME instead of ${ENV, var="VARNAME"}.
            Hide
            slide_o_mix Alex Earl added a comment -

            That will only work for environment variables

            Show
            slide_o_mix Alex Earl added a comment - That will only work for environment variables
            Hide
            danielbeck Daniel Beck added a comment -

            True, but it's worth mentioning, since the comment by Ralf Rausch on 05/Jun/13 12:22 PM indicates it doesn't.

            Show
            danielbeck Daniel Beck added a comment - True, but it's worth mentioning, since the comment by Ralf Rausch on 05/Jun/13 12:22 PM indicates it doesn't.
            Hide
            ralf_rausch Ralf Rausch added a comment - - edited

            ${VARNAME}, $VARNAME and ${ENV, var="VARNAME"} works for me, too.
            Something like this \$VARNAME doesn´t work. It is the backslash(es) in front of the $. See comment by Alex Earl on 20/May/13 10:42 PM

            Show
            ralf_rausch Ralf Rausch added a comment - - edited ${VARNAME}, $VARNAME and ${ENV, var="VARNAME"} works for me, too. Something like this \$VARNAME doesn´t work. It is the backslash(es) in front of the $. See comment by Alex Earl on 20/May/13 10:42 PM
            Hide
            danielbeck Daniel Beck added a comment - - edited

            I understand that. To clarify:

            \${ENV, var="VARNAME"} does not work for me (prints '\${ENV, var="VARNAME"}'), but \$VARNAME does work for me (prints '\value').

            Show
            danielbeck Daniel Beck added a comment - - edited I understand that. To clarify: \${ENV, var="VARNAME"} does not work for me (prints '\${ENV, var="VARNAME"}'), but \$VARNAME does work for me (prints '\value').
            Hide
            slide_o_mix Alex Earl added a comment -

            The reason for that is the environment variables are actually replaced differently (through a mechanism in the Jenkins core, which doesn't support escaping). This replacement of environment variables is done before token macro does it's replacement.

            Show
            slide_o_mix Alex Earl added a comment - The reason for that is the environment variables are actually replaced differently (through a mechanism in the Jenkins core, which doesn't support escaping). This replacement of environment variables is done before token macro does it's replacement.
            Hide
            slide_o_mix Alex Earl added a comment -

            I have a pull request in for the Token Macro plugin that would change the way escapes for tokens work. This should allow using \${ENV...}

            Show
            slide_o_mix Alex Earl added a comment - I have a pull request in for the Token Macro plugin that would change the way escapes for tokens work. This should allow using \${ENV...}
            Hide
            scm_issue_link SCM/JIRA link daemon added a comment -

            Code changed in jenkins
            User: Alex Earl
            Path:
            src/main/java/org/jenkinsci/plugins/tokenmacro/TokenMacro.java
            src/main/java/org/jenkinsci/plugins/tokenmacro/Tokenizer.java
            src/test/java/org/jenkinsci/plugins/tokenmacro/TokenMacroTest.java
            http://jenkins-ci.org/commit/token-macro-plugin/e1523eca5fb78fad1112193829ee4782620d9ce5
            Log:
            Fix JENKINS-18014

            Changed the way that macros are escaped to using something similar to Groovy with two $'s. This required actually looking for the items that matched with two $'s and then handling that case special.

            Show
            scm_issue_link SCM/JIRA link daemon added a comment - Code changed in jenkins User: Alex Earl Path: src/main/java/org/jenkinsci/plugins/tokenmacro/TokenMacro.java src/main/java/org/jenkinsci/plugins/tokenmacro/Tokenizer.java src/test/java/org/jenkinsci/plugins/tokenmacro/TokenMacroTest.java http://jenkins-ci.org/commit/token-macro-plugin/e1523eca5fb78fad1112193829ee4782620d9ce5 Log: Fix JENKINS-18014 Changed the way that macros are escaped to using something similar to Groovy with two $'s. This required actually looking for the items that matched with two $'s and then handling that case special.
            Hide
            scm_issue_link SCM/JIRA link daemon added a comment -

            Code changed in jenkins
            User: Alex Earl
            Path:
            src/main/java/org/jenkinsci/plugins/tokenmacro/TokenMacro.java
            src/main/java/org/jenkinsci/plugins/tokenmacro/Tokenizer.java
            src/test/java/org/jenkinsci/plugins/tokenmacro/TokenMacroTest.java
            http://jenkins-ci.org/commit/token-macro-plugin/8c10736b54aac32f1590720fa2f843febaf31b32
            Log:
            Merge pull request #12 from slide/master

            Fix JENKINS-18014

            Compare: https://github.com/jenkinsci/token-macro-plugin/compare/766cdb04c67a...8c10736b54aa

            Show
            scm_issue_link SCM/JIRA link daemon added a comment - Code changed in jenkins User: Alex Earl Path: src/main/java/org/jenkinsci/plugins/tokenmacro/TokenMacro.java src/main/java/org/jenkinsci/plugins/tokenmacro/Tokenizer.java src/test/java/org/jenkinsci/plugins/tokenmacro/TokenMacroTest.java http://jenkins-ci.org/commit/token-macro-plugin/8c10736b54aac32f1590720fa2f843febaf31b32 Log: Merge pull request #12 from slide/master Fix JENKINS-18014 Compare: https://github.com/jenkinsci/token-macro-plugin/compare/766cdb04c67a...8c10736b54aa
            Hide
            slide_o_mix Alex Earl added a comment -

            This will be fixed in the token macro plugin in 1.8

            Show
            slide_o_mix Alex Earl added a comment - This will be fixed in the token macro plugin in 1.8
            slide_o_mix Alex Earl made changes -
            Status Reopened [ 4 ] Resolved [ 5 ]
            Resolution Fixed [ 1 ]
            slide_o_mix Alex Earl made changes -
            Component/s token-macro [ 15832 ]
            rtyler R. Tyler Croy made changes -
            Workflow JNJira [ 149311 ] JNJira + In-Review [ 193065 ]

              People

              • Assignee:
                slide_o_mix Alex Earl
                Reporter:
                ericthefree Eric Freeman
              • Votes:
                1 Vote for this issue
                Watchers:
                5 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved: