Send file path as a link in email body after Jenkins Scripted pipe line run

249 views
Skip to first unread message

Techno Park

unread,
Feb 6, 2023, 9:50:22 AM2/6/23
to Jenkins Users
Can anyone tell me how to add a link to a file location in the email body?
I have the below email body and I want to send the highlighted/bold bit( <a href=C:\\abc\\xyz\\>) as a link in  the email body after every run, so, that users can click on the link from email to be take to the location, but it doesn't work. .:-

emailext attachLog: true, attachmentsPattern: 'target',
                subject: "Jenkins Build Report  ${currentBuild.currentResult}: Job ${env.JOB_NAME} build ${env.BUILD_NUMBER}",
                body: "${currentBuild.currentResult}: Job ${env.JOB_NAME} \n Link: ${env.BUILD_URL} \n Drop folders can be found at
                <a href=C:\\abc\\xyz\\>",
                  mimeType: 'text/html',
                to: testEmailGroup

Ivan Fernandez Calvo

unread,
Feb 6, 2023, 11:05:50 AM2/6/23
to Jenkins Users
Two things here, one the whole body must be and HTML page to be sent as HTML, and you need the email ext plugin installed, check the documentation of the plugin for more details

Alex Earl

unread,
Feb 6, 2023, 11:11:21 AM2/6/23
to jenkins...@googlegroups.com
Also, you will need to use a file:// link, not just the path. Be aware though that unless everyone is running from the same C: drive mount, then your link won't work at all for people clicking on it from their account.

--
You received this message because you are subscribed to the Google Groups "Jenkins Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to jenkinsci-use...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/jenkinsci-users/9df81503-fa0b-4fff-a9bb-9f9d09cfe0b8n%40googlegroups.com.


--

Techno Park

unread,
Feb 7, 2023, 5:23:56 AM2/7/23
to Jenkins Users
Thanks for the replies. 
I have used HTML syntax and it worked:-

 <p> <a href='C:\\Other\\Data'>Imp List</a> </p>

However, I have one more question if I may. I need to grab a file name from the workspace. The first part of file is static and second part is dynamic. So, I need to find this file, get the full name
and pass it in the email body. 
Eg. File name - importlist_20030207 102020 (importlist is static and the rest is dynamic)
So, I need to get the above file name from workspace and send it in the path below:-
eg.   <p> <a href='C:\\Other\\Data'>Imp List\\importlist_20030207 102020.csv</a> </p>

Can someone tell me how to do it?
Reply all
Reply to author
Forward
0 new messages