I am running a Jenkins pipline which is calling a script In following example, running a script which is generating output file with issue_{datetime}.txt I want to send this file as attachment. However, as file name is generated every time with separate date time stamps not able to find a way to attach file. e.g.
pipeline {
agent any
stages{
stage('Start Build'){
steps{
python run.py
}
}
}
post {
always {
echo ("${email_id}")
emailext from: 'xyz@yahoo.com', attachmentsPattern: 'resources/*.xlsx',
to: "${email_id}",
}
}
}
OUTPUT_FILE = sh(script: 'ls -t resources/issue*.xlsx | head -1', returnStdout: true) emailext from: 'test@yahoo.com', attachmentsPattern:"${OUTPUT_FILE}"