How do I add a file name from my build to an email

How do I add a file name into the email that I send when the build is successful? The pipeline is a parameterized pipeline. So the file appears in the lastSuccessfulBuild/archive/Jenkins/Builds directly correctly for the pipeline I am building. But I want to use the same file for parameterized pipeline (which now does not show any lastSuccessfulBuilds).

The file increments by changeset number each time a build is done.

how do you send the email?

There’s a pipeline syntax generator link on the sidebar of your pipeline that can help you generate parameters for any pipeline step you have.

I have it in my post-build steps.
emailext (
body: ‘’’${SCRIPT, template=“email.groovy.template”}’’’,
subject: “Build Failed: Job ‘${env.JOB_NAME} [${env.BUILD_NUMBER}]’”,
to: ‘’,
recipientProviders: [[$class: ‘CulpritsRecipientProvider’], [$class: ‘DevelopersRecipientProvider’], [$class: ‘RequesterRecipientProvider’]]

Would a writeFile command work for the Body? And somehow put the name of the file in the Body of the email?

Right now the email.groovy.template has this for the body and loops through the artifacts from the first pipeline.

<a href="${rooturl}${build.url}artifact/${f}" ->${f}

I want the build artifacts to show for the 2nd pipeline (or parameterized pipeline). Which shows no artifacts on the view when complete. The artifacts show on the 1st pipeline under lastSuccessfulBuild when complete.