Reputation: 173
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.
Upvotes: 2
Views: 8108
Reputation: 144
You could make use of readFile()
emailext (
mimeType: 'text/html',
to: "[email protected]",
attachLog: true,
subject: 'Subject Line',
body: readFile("path/to/html/file")
)
readFile will read it as stream of strings and hands it over to emailext plugin, hence if you might have used any special variables such as
${BUILD_NUMBER}
${BUILD_LOG_REGEX}
will get compiled correctly and replaced with interpreted values.
Upvotes: 1
Reputation: 11
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.
Upvotes: 0
Reputation: 10395
You can use attachmentsPattern
parameter.
emailext (
subject: "some subject",
body: "${FILE,path="enteryPath/template.html"}",
to: "[email protected]"
attachmentsPattern: 'enteryPath/template.html'
)
Upvotes: 2
Reputation: 954
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?
Upvotes: 0