bookmark_borderGlobal 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: "tim@gmail.com",
        Ellen: "Ellen@gmail.com"
    ]
}

Jenkins – New Item – Pipeline – Pipeline script

@Library(mail_list) _

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