My Question:
I want to send email if an enduser ever wants to receive emails on a regular basis with the attached csv file, we can change the pipeline to set the "isSendEmail" to "true" and populate the default value with that user's email address and the job will automatically send emails from that point on.
but while configuring the jenkisnfile, job runs fine but there is no email notification received? what is the correct way to configure parameter for Email Id's in jenkinsfile to send email so that doing it this way also allows me to easily run the job manually and sends the email to other people on an adhoc basis.
Jenkinsfile
pipeline {
agent any
options {
buildDiscarder logRotator(artifactDaysToKeepStr: '', artifactNumToKeepStr: '', daysToKeepStr: '', numToKeepStr: '5')
}
stages {
stage('Use AWS CLI to detect untagged resources') { steps {
script {
def awsUtil = new AwsUtil()
sh """#!/bin/bash
set
aws resourcegroupstaggingapi get-resources --tags-per-page 100 --tag-filters Key=SysName,Values=KickMe --tag-filters Key="SysName in ServiceNow",Values=False > tag-filter.json
jq '.ResourceTagMappingList[].Tags |= map(select(.Key|IN("ManagedBy","SysName","Owner","SysName in ServiceNow","Name","TSM")))' tag-filter.json > untagged-resources.json
ls
echo "un tag resource.json file data"
cat untagged-resources.json
echo "--------------"
cat tag-filter.json
python untag_resources_convert_csv.py
ls
"""
}}}
stage('Setup parameters') { steps {
script {
properties([
parameters([
booleanParam(
defaultValue: true,
description: '',
name: 'isSendEmail'
),
string(
defaultValue: '',
description: '',
name: 'def@xxx.com,abc@xxx.com,ghi@xxx.com',
trim: true
)
])
])
}}}
}
post {
always {
archiveArtifacts artifacts: 'unTagResources_Details.csv', onlyIfSuccessful: true
emailext (
attachmentsPattern: 'unTagResources_Details.csv', body: '''${SCRIPT, template="groovy-html.template"}''',
subject: '$DEFAULT_SUBJECT',
mimeType: 'text/html',to: "email id"
);
}
}
}