Jenkinsfile consisting of functions

50 views
Skip to first unread message

Tomasz Szandała

unread,
Feb 3, 2017, 9:26:22 AM2/3/17
to Jenkins Developers
Greetings,
I am working on simplification of pipeline flow in my team.
In Git I have 2 files: Jenkinsfile and steps.groovy.
In steps I have defined my pipeline steps in form of functions, e.g.:



def build(system){
    return {
        node ("BUILDER"){
            deleteDir()
            scm checkout
            env.BUILD_TARGET = architecture
            sh "builder/builder.sh"

            archive "*.zip"
            stash name: "build_artifacts", includes: "*.zip"

        }
    }
}

return this

In Jenkins I am checkouting Git repo, specific branch and run Jenkinsfile.
How can I make Jenkinsfile to consist only of functions calling like this:
    def steps = load "ci/steps.groovy"

    steps.build("linux")

    steps.build("linux2")





Jesse Glick

unread,
Feb 3, 2017, 3:19:47 PM2/3/17
to Jenkins Dev
This is a question for the user list, or simply reading the documentation which covers this topic already I think.
Reply all
Reply to author
Forward
0 new messages