1
votes

I need include email content from html file using email-ext plugin in jenkins pipeline (my jenkins is 2.24 version), i try this

emailext (
  subject: "some subject",
  body: "${FILE,path="enteryPath/template.html"}",
  to: "[email protected]"
)  

but dont work for me :( any suggestions or solution?? , thanks advance.

3

3 Answers

2
votes

You can use attachmentsPattern parameter.

emailext (
  subject: "some subject",
  body: "${FILE,path="enteryPath/template.html"}",
  to: "[email protected]"
  attachmentsPattern: 'enteryPath/template.html'
)  
0
votes

Can't you store the body in the workspace? And then just run:

emailext (
  subject: "some subject",
  body: readFileFromWS("enteryPath/template.html"),
  to: "[email protected]"
) 

But this would mean the body is static from job-creation and forward, guess you want it to be read when the mail should be sent?

0
votes
    stage ('email'){
    steps{
      script{
             echo "hello"
             emailext (subject: "some subject", body: '${FILE,path="template.html"}',to: "[email protected]")  

            }
        }       
  }

Install the email-ext plugin for Jenkins and you can have the above code to send emails as part of the stage and path here would be relative to Jenkins workspace.