This repository hosts shared code for use in Jenkinsfile
s of our projects here on github.
Code in this repository is public domain. We do not claim copyright. Where legally required, you may opt for MIT license.
In a Jenkinsfile
, write:
// Get the 'melt' variable in scope:
library "github.com/melt-umn/jenkins-lib"
From there, you may call/access the functions/variables you find in vars/melt.groovy
. The above imports a melt
object, and so variables and methods you see in that file will be on that object. For example:
melt.notify(job: 'silver')
This will call the notify
method in vars/melt.groovy
.
- Branch, make changes.
- Test them out with this repository's own
Jenkinsfile
. Jenkins has a "Replay" feature that can help you figure out what syntax tweak will work. - After fixing all your bugs, rewrite the history of your branch to be clean and comprehensible. (Try
git rebase -i master
and usingfixup
on everything but your first commit. When you force push, make sure it's only your branch, always spell it out to be safe:git push -f origin MY_BRANCH
) - You can test a script in another repo by making it use a particular branch: (
library 'github.com/melt-umn/jenkins-lib@MY_BRANCH'
). Do this in a branch, and then just delete it later. - Pull request / merge.
- Sigh, test to make sure you didn't break anything. Probably by triggering a rebuild of Silver in Jenkins.
- Delete branch.
A bit annoying, but better than duplicating code all over, eh?
Examples and useful documentation: