Configure Jenkins

Configure Jenkins:

Jenkins system comprises of a Manager and Worker. The Manage instance will continue to be available, however, Workers will be spawned on demand basis.

Note: The CloudFormation has been updated recently to auto-configure Jenkins cloud, thus below configuration may not be needed, except for the Private IP address for the “Alternative Jenkins URL” and Jenkins cluster selection. However, please go through this checklist to ensure the configuration is up to date.

Step1: Configure the Jenkins Cloud and Jenkins workers:

First Click Manage Jenkins: dashboard

Select Managed Nodes and Clouds dashboard

Select Configure Clouds dashboard

Select the ECS Service as shown below: dashboard

Configure the ECS Cloud service to select jenkins-cluster as shown / circled below: dashboard

Now configure the two Build workers and use the exact same names / values that are shown below including the docker image to be used as cloudbees/jnlp-slave-with-java-build-tools: dashboard dashboard

Click Save

Once this is complete, please go through the buildjobs to make sure the label assigned for the build-worker-1 and build-worker-2 are correct. So you can go through individual build jobs named as testBuildx, as shown in the figure below: dashboard dashboard

Access the ECS Service for the Jenkins-Cluster as shown below: dashboard

Locate the ECS Instance hosting the Jenkins container as shown below: dashboard

Access that EC2 instance and find the private IP address of the instance. You will use this IP Address to configure the Cloud communication between the Jenkins Manager and the Jenkins workers spawned on the ECS infrastructure. Go to Configuration of Clouds as shown below: Manage Jenkins -> Managed Nodes and Clouds -> Configure Clouds -> Click on the Advanced Box as shown below: dashboard

Now populate the Private IP address as shown below along with the port 8080: dashboard

We will trigger builds in Jenkins, however, before that, let us initiate launching CDK to create the EKS infrastructure. We will do this in the next page.

Step2: Configure Environmental variables:
Configure the Global variables for the AWS Region as shown below: Select Manage Jenkins -> Configure System -> Global Properties -> Environment Variables -> Add: JENKINS_AWS_REGION with value us-east-2 (or region on which Jenkins is hosted) dashboard dashboard

Step3: OPTIONAL: Configure build-app build job with AWS Credentials:
Select the Build Job -> Configure -> Locate the "\" text and replace it with your AWS Credentials: dashboard

Note: Putting the credentials in the build job is not a good practice as it exposes your credentials in the logs as well as jobs across other users. In the latter portion of the workshop, we will learn how to configure AWS credentials on Jenkins and use it safely.