Sunday, May 29, 2022

Azure DevOps - Integrate Jenkins with Azure Repos

 Jenkins is a CI/CD Pipeline tool.

Jenkins - Overview

Jenkins Installation on Ubuntu

The below steps are used to integrate Azure Repos with Jenkins.(Below example is java maven based project)

Once Jenkins is installed and the service is running then you can access the Jenkins on port number 8080.

Install maven on the ubuntu machine apt install maven command.

Create a sample maven project using mvn archetype:generate command. Provide the options as default options except below two values.


artifactid: myproj

Create a Repo in the Azure DevOps portal and push the myproj into the repo 

  • cd myproj
  • git init
  • git add .
  • git commit -m "Initial setup"
  • git remote add origin <URL of AzureRepo>
  • git push origin master

Check on the Azure Repos MyProj repo should be created.

Click on Clone Repo and copy the URL. Generate a username and password and use these credentials in the Jenkins job.

Goto Jenkins portal and Select Manage Jenkins --> Manage plugins

In the Available Tab select Maven Integration and click on Install without restart Jenkins button.

Create a new job in Jenkins with Maven Project

In the configuration Map Git URL as Azure Repo url and the add credentials as created for Azure repos.

In the Goals and options write the command clean package 

Generate a token in Jenkins to integrate with Azure Repos. On Jenkins select People-->admin user-->Configure-->API Token-->Generate Token

Save the token because this token is only visible during creation time only

On Azure DevOps, Goto Project Settings --> Service hooks-->New Subscription -->Jenkins---> Add Trigger

Type of Event Code Pushed and select your repository.

Now change the code in the Azure Repo and You will find that the Jenkins job is triggered.


Post a Comment