Creating a project

At this stage, we are all set to create a new project for our pipeline. Choose New Item from the main Jenkins dashboard, give it an appropriate name, and select Freestyle Project. This type allows us to set up our own workflow. The name is important as it will be the project binary that is built. After this, set up the Git (GitHub) URL of the sample project:

In this example, Jenkins is running on a laptop and the code is in GitHub, so we will be using build triggers rather than triggering the pipeline manually. You can leave the Build Triggers section empty.

We need to set up the Go version:

With this set, the workflow will download and you can install that version of Go prior to the builds.

Next, we configure the actual build. We can do this in discrete steps. In this example, we use just two steps—one to fetch Go and the other to do the build, as shown in the following screenshot:

Note that the GOOS=linux GOARCH=38 prefix is needed as my Jenkins server is on macOS, and I am going to the binary in Ubuntu in the container.

After setting up the Build, we need to set up the Post-build Actions. Here, we copy over the binary (built on the Jenkins build server) and then execute it on the target container:

Finally our project is created.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset