Writing CI pipeline code
Our source code project contains a Jenkinsfile
containing our CI pipeline code. It defines a Jenkins pipeline that can handle CI for our Hello World web application with both frontend and backend components. The pipeline integrates with Kubernetes, SonarQube, and Artifactory. Let’s look at the file section by section in detail.
Configuring Jenkins agent settings
In the context of declarative CI pipeline code, the agent { kubernetes {…} }
section is pivotal. It designates that the Jenkins job should run within a Kubernetes environment. The agent
section is responsible for defining where and how the entire pipeline or specific stages will be executed. By specifying kubernetes
, we’re informing Jenkins to provision a fresh Kubernetes Pod for the job. This is particularly beneficial for scalability, as Pods are ephemeral and can be dynamically created and destroyed. It ensures that our CI tasks run in an isolated, consistent, and resource...