DevOps Classroom notes 25/Nov/2023

Configuring Maven in Jenkins

  • To install maven in jenkins there are two approaches
    • Using Jenkins: Avoid this approach
    • installing maven and configuring in jenkins: This is better approach
  • To install softwares we need sudo permissions. Lets give sudo permissions to the jenkins user as we are installing maven on jenkins master node
  • Execute sudo visudo or visudo from root user
  • Lets install Maven 3.9.5
cd /tmp
wget https://dlcdn.apache.org/maven/maven-3/3.9.5/binaries/apache-maven-3.9.5-bin.tar.gz
tar -xvzf apache-maven-3.9.5-bin.tar.gz
sudo mkdir /opt/maven
sudo mv apache-maven-3.9.5 /opt/maven
  • Lets configure Maven: Navigate to Manage Jenkins => Tools
    • Lets Add JDK
    • Now lets add Maven 3.9.5
    • Now lets add Maven 3.8.8
  • Tools section in jenkins help in finding tool locations like jdk,maven etc..
  • The advantage is we can configure multiple versions

Lets create a job to run a maven project

  • Lets configure spring petclinic
  • Lets configure openmrs
  • Note: For screenshots refer video.

Lets try to show the test results for maven

  • We know that the test results will be stored in target/surefire-reports/TEST-*.xml
  • Jenkins has support for patterns **/TEST-*.xml which means in any filder if there any file matching TEST-*.xml find it
  • Lets configure this

  • Now lets build the project and see the test results

Lets archive the artifact

  • This activity allows users to download the artifacts directly from jenkins


When to trigger project builds

  • To do this effectively we need to understand
    • Day build: Building the code using CI/CD during the effective working hours of team (CI)
      • Get executed whenver developer pushes code
    • Nightly build: Building the code using CI/CD post working hours with effective testing (CD)
      • Gets executed once in a day

Lets configure day build and night build for spring petclinic

  • Build Triggers
    • Poll SCM: This will poll scm (git) for any new change. we need to configure how frequently should jenkins poll
    • Build Periodically: This will trigger build based on schedule defined
  • To configure this jenkins uses crontab syntax Refer Here
  • We have forked from spring petclinic into Refer Here
  • Day build: Poll SCM
  • Nightly build: Build every weekday at 8:35 PM
  • Note: From now onwards day builds execute on a branch called as sprint-dev and nightly builds on a branch called as sprint-release
  • Create an account in mailtrap Refer Here
Published
Categorized as Uncategorized Tagged

By continuous learner

devops & cloud enthusiastic learner

Leave a comment

Turn on JavaScript to leave a comment.

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Please turn AdBlock off
Social Media Icons Powered by Acurax Web Design Company
Exit mobile version
%%footer%%