Jenkins - Shared Libraries

Create Shared Library

your-library
    |
    vars/
        // this is where your steps go
        buildExecutable.groovy
        runTests.groovy
        deployExecutable.groovy
    src/
        // 

Register the Library in Jenkins

Use the Library in a Pipeline

@Library('your-library')_

stage ('Build')
{
    buildExecutable ('foo-bear')
}
#!/usr/bin/env groovy
// vars/YourStepName.groovy


// you must implement the call() method
def call()
{
    // ...
}
#!/usr/bin/env groovy
package your.package.name

class Foo
{
    static String bar = "foo-bar!"
}
// 

def call()
{
    // ...
}

Acknowledgements