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

[Email plugin] Read parameters/variables used during build

    Details

    • Type: Improvement
    • Status: Closed (View Workflow)
    • Priority: Major
    • Resolution: Fixed
    • Component/s: email-ext-plugin
    • Labels:
      None
    • Environment:
      Platform: All, OS: All
    • Similar Issues:

      Description

      One of the parameters I want to set on some of the projects is "who to email
      results to". Unfortunately the email plugin:

      http://hudson.gotdns.com/wiki/display/JENKINS/Email-ext+plugin

      Cannot read environment variables or project parameters that were set by
      someone. Would be nice if it could.

        Attachments

          Issue Links

            Activity

            Hide
            pyrocks Mor L added a comment - - edited

            scott carlson I fail to see why you have problems with pipeline - since pipeline has env available to you - you don't need a special syntax.

            So this would be like:

            emailext body: 'A Test EMail', subject: 'Test', to: env.YOUR_PARAM

            Am I missing something?

            Show
            pyrocks Mor L added a comment - - edited scott carlson  I fail to see why you have problems with pipeline - since pipeline has env available to you - you don't need a special syntax. So this would be like: emailext body:  'A Test EMail' , subject:  'Test' , to:  env.YOUR_PARAM Am I missing something?
            Hide
            scarlson scott carlson added a comment -

            In all other instances in pipeline it works fine.. it is only with the "to:" section specifically there is an error.  every other instance in the body, subject, etc. it works fine.

            For sanity I have tried 

            • to: env.PARAM
            • to: ${build.environment['PARAM']}
            • to: "${env.PARAM}"
            • to: "${build.environment['PARAM']}

            none of them worked. 

            If you are able could you try to use it in the "to:" section?

             

            Show
            scarlson scott carlson added a comment - In all other instances in pipeline it works fine.. it is only with the "to:" section specifically there is an error.  every other instance in the body, subject, etc. it works fine. For sanity I have tried  to: env.PARAM to: ${build.environment ['PARAM'] } to: "${env.PARAM}" to: "${build.environment ['PARAM'] } none of them worked.  If you are able could you try to use it in the "to:" section?  
            Hide
            pyrocks Mor L added a comment -

            scott carlson

            Not sure what is wrong with your setup - but it works. Tested with the following code (job has a single parameter called PARAM1 with value someone@somewhere.com):

            node {
                echo env.PARAM1
                emailext body: "body",
                         subject: "subject",
                         to: env.PARAM1
            }
            

            output:

            Started by user myuser
            [Pipeline] node
            Running on somenode in F:\somefolder
            [Pipeline] {
            [Pipeline] echo
            someone@somewhere.com
            [Pipeline] emailext
            Sending email to: someone@somewhere.com
            [Pipeline] }
            [Pipeline] // node
            [Pipeline] End of Pipeline
            Finished: SUCCESS
            
            Show
            pyrocks Mor L added a comment - scott carlson Not sure what is wrong with your setup - but it works. Tested with the following code (job has a single parameter called PARAM1 with value someone@somewhere.com): node { echo env.PARAM1 emailext body: "body" , subject: "subject" , to: env.PARAM1 } output: Started by user myuser [Pipeline] node Running on somenode in F:\somefolder [Pipeline] { [Pipeline] echo someone@somewhere.com [Pipeline] emailext Sending email to: someone@somewhere.com [Pipeline] } [Pipeline] // node [Pipeline] End of Pipeline Finished: SUCCESS
            Hide
            stodorov Steve Todorov added a comment -

            It simply doesn't work as expected. Having this in the emailext body just doesn't work:

             

            <p>Build #$BUILD_NUMBER ran on ${env.NODE_NAME} ${build.environment['NODE_NAME']} and terminated with $BUILD_STATUS.</p>
            

            It prints to something like this in the sent email:

             

            Build #54 ran on ${env.NODE_NAME} ${build.environment['NODE_NAME']} and terminated with Still Failing.

            I've tried pretty much all combinations I've seen on the internet and the documentation. None of them work as expected - they will either print as empty or will print "as-is" without being replaced (like in the example above). 

            Mor L's  example works, though.

            Show
            stodorov Steve Todorov added a comment - It simply doesn't work as expected. Having this in the emailext body just doesn't work:   <p>Build #$BUILD_NUMBER ran on ${env.NODE_NAME} ${build.environment[ 'NODE_NAME' ]} and terminated with $BUILD_STATUS.</p> It prints to something like this in the sent email:   Build #54 ran on ${env.NODE_NAME} ${build.environment[ 'NODE_NAME' ]} and terminated with Still Failing. I've tried pretty much all combinations I've seen on the internet and the documentation. None of them work as expected - they will either print as empty or will print "as-is" without being replaced (like in the example above).  Mor L's  example works, though.
            Hide
            lsbwant lsb want added a comment -

            not work for me too

            Show
            lsbwant lsb want added a comment - not work for me too

              People

              • Assignee:
                asalicetti asalicetti
                Reporter:
                akshay_abd akshay_abd
              • Votes:
                3 Vote for this issue
                Watchers:
                9 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved: