Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to place Email-Ext groovy script on the jenkins file system

I need to dynamically modify the notification e-mail recipients based on the build, so I'm using a groovy script. I want this script to be available to all jobs, so I want it to reside on the Jenkins file system and not within each project. It can be either in the recipients fields (using ${SCRIPT,...}) or in the pre-send script. A short (fixed) script that evaluates the master script is also good, as long it is the same for all projects.

like image 852
David Rabinowitz Avatar asked Sep 04 '25 16:09

David Rabinowitz


1 Answers

You should try Config File Provider plugin. It works together with the Credentials configuration of Jenkins.

  • Go to Manage Jenkins > Managed files
  • Click Add a new Config
  • Select Groovy file
  • Enter the contents of your script

Your script will now be saved centrally on Jenkins, available to master/slave nodes.

In your Job Configuration:

  • Under Build Environment
  • Check Provide Configuration file
  • Select your configured groovy File from dropdown
  • Set Variable with a name, for example: myscript

Now, anywhere in your job, you can say ${myscript} and it will refer to absolute location of the file on filesystem (it will be somewhere in Jenkins dir).

like image 128
Slav Avatar answered Sep 07 '25 18:09

Slav