1.0 KiB
1.0 KiB
Exercise 14
In this exercise, you'll take the existing pipeline definition from the previous exercise and turn it into a reusable shared library.
Writing and Using a Shared Library
- Set up a new GitHub repository named
jenkins-standard-go-pipeline. It will define a standard pipeline definition for Go projects implemented as shared library. - Add the file
vars/standard.groovythat defines the declarative pipeline as global variable. Make the Go tool name and golang-ci version configurable with the help of parameters. - Push the changes to the
masterbranch and configure the shared library in Jenkins. - Configure the shared library for consumption in Jenkins with the name
go-pipeline. - Set up a new GitHub repository named
go-project-by-template. Initialize a new Go project by runninggo mod init github.com/bmuschko/hello-worldand adding a simplemain.gofile. - Add a new
Jenkinsfile. Consume the shared library and call the global variable. - Trigger a build and visualize the pipeline in Jenkins.