Coming from other continuous integration (CI) solutions, Travis CI, GitLab, and Azure DevOps Service, I was surprised when I found it difficult to learn Jenkins. The good news, however, is that in the end, I found Jenkins relatively easy to use and a pleasure to work with.

Looking back, I attribute my difficulty in learning Jenkins to the multitude of ways of accomplishing the same thing in it. This seems to be due to Jenkins’ layered approach, likely for backward compatibility, to adding features.

The Code

The code (written in Go) is purposefully simple:

  • A package, sum, that exports a function, _Sum_and a test for that function
  • main package consisting of a main function that calls the Sum function and outputs the result
  • A module, github.com/hello-jenkins-larkintuckerllc/hello-jenkins, containing the main and sum packages
  • A multi-stage build Dockerfile that builds a Docker image that executes the Go module, i.e., calls the main function

The supporting infrastructure consists of:

For the purposes of this article, there are four operations we can perform with the code:

  • Build Go module; i.e., go build
  • Test each Go package; i.e., go test ./…
  • Build tagged Docker image; e.g., docker build -t sckmkny/hello-jenkins:0.1.1 .
  • Push (to repository) tagged Docker image, e.g.,., docker push sckmkny/hello-jenkins:0.1.1

#continuous-integration #jenkins #azure devops #travis ci #gitlab

Jenkins by Example
1.40 GEEK