Global Libraries in Jenkins

Global Libraries / Shared libraries

If you have a mailing list of people on the project, this mailing list is mutable. Some people want to add/update/remove the list. This mailing list need to share across the projects. You need the central place to store the mailing list.

Create Shared libraries

Jenkins – New Item – Folder – Pipeline Libraries

  • name: team-mails
  • Default version: master
  • Add GitHub repository URL
class emails {
    def mails = [
        Tim: "",
        Ellen: ""

Jenkins – New Item – Pipeline – Pipeline script

@Library(mail_list) _

    agent any
        stage ("build"){
                    mail = new emails()
                    mail.mails.each { println "name: $it.key", email: $it.value"}

Leave a Reply

Your email address will not be published.