Last updated on August 31, 2022
I took a little bit of a detour from the Cloud Resume Challenge. I’m interviewing with a company I’d very much like to work with, and I’d noticed in the job description they’d mentioned Jenkins a few times. Jenkins has been on my radar to play with, so I thought I’d spend some time going through this walkthrough I’d found a few weeks ago.
It seemed pretty simple:
- Setup an EC2 instance, assign an EIP and set up the security group to allow ssh and http on 8080
- Connect and install Jenkins, Git, and Maven installed, then set Jenkins password
- Create an AMI template of the instance
- Create IAM role to allow master image the ability to spin up new instances
- Update the security group to allow the Jenkins master to connect to new images
- Within Jenkins, add and configure EC2 plugin
- Set up a workernode that uses the AMI created earlier
- Create a new project using the EC2 workernode and a test GitHub repository to build a Maven project on the new instance
- Build!
Of course, it’s never quite that simple. The first build attempt kept spawn new instances then terminating them. A look at the logs showed that by default, Jenkins was configured to connect as root, not the default ec2user. I stopped the build, updated the workernode configuration in Jenkins, and tried another build.
Second build was….better. Only one instance was created this time. The logs indicated a successful connection, the code was retrieved from GitHub, and all the required modules were downloaded. However, the build ultimately failed with this error:[ERROR] Failed to execute goal io.spring.javaformat:spring-javaformat-maven-plugin:0.0.31:validate (default) on project spring-petclinic: Execution default of goal io.spring.javaformat:spring-javaformat-maven-plugin:0.0.31:validate failed: An API incompatibility was encountered while executing io.spring.javaformat:spring-javaformat-maven-plugin:0.0.31:validate: java.lang.UnsupportedClassVersionError: io/spring/javaformat/eclipse/jdt/jdk11/internal/formatter/DefaultCodeFormatter has been compiled by a more recent version of the Java Runtime (class file version 55.0), this version of the Java Runtime only recognizes class file versions up to 52.0
It seems as though the walkthrough is old enough that the proscribed version of Java is now too old for the test project, so I needed to roll back some of the work. I went back to the Jenkins master image, updated Java to the latest version and set it to be the default. Then I created a new AMI, and updated the AMI ID in the workernode configuration on Jenkins.
Tried to build one more time, and…SUCCESS!!
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 04:01 min
[INFO] Finished at: 2022-02-12T17:50:10Z
[INFO] Final Memory: 51M/124M
[INFO] ------------------------------------------------------------------------
Finished: SUCCESS
This was a fun little project. I started to get an idea of how Jenkins orchestrates deploying new EC2 images, and I think I’ll try another project or two in the future. There’s something a little magical about automation when it works, and I get such a kick out of it.
Published February 12, 2022
Be First to Comment