1.2 KiB
1.2 KiB
Exercise 12
In this exercise, you'll create a declarative pipeline for a Go-based project. The Jenkinsfile will use some of the basic features of the pipeline DSL.
Writing a Basic Jenkinsfile
- Create a new GitHub repository named
go-on-jenkins. - Create a new
Jenkinsfilein the root directory of the repository as well as a simplemain.gofile. The main function just prints "Hello World!". The repository https://github.com/bmuschko/go-helloworld-template shows an example. - Commit the files and push them to the remote repository.
- Set up a new pipeline job for this repository in Jenkins.
- Install the Jenkins Go plugin.
- Configure the latest Go runtime as global tool. Use a name that reflects the Go version. Remember the name for the next step.
- Enhance the
Jenkinsfilebased on the following requirements. The Jenkinsfile should use the declarative syntax.- The job can run on all agents.
- The job sets the environment variable
GO111MODULES=on. - The job uses the Go runtime from the global tool definition (see previous step).
- The job specifies one build stage named "Build". The build stage executes the shell command
go build.