Azure DevOps
-
Azure DevOps offers services to
- Plan work
- Source Code Management
- Build and Deploy application
-
Visual Studio Team Services is now Azure DevOps
-
Azure DevOps has two modes
- Azure DevOps Services:
- This is a hosted service.
- On Azure Cloud Azure DevOps is hosted
- Azure DevOps Server
- You need to install the Server
- Generally used for On-Premise builds and deployments
- Azure DevOps Services:
-
Azure Services
- Azure Repos:
- Git or Team Foundation Version Control
- Azure Pipelines
- provides build and release pipelines for delivery of application
- Azure Boards
- set of Agile tools to support planning, tracking work using kanban and Scrum
- Azure Test Plans
- Tools to test apps
- Azure Artifacts
- Like artifactory a binary repository with Maven, npm, nuget etc capabilities.
- Azure Repos:
-
Azure DevOps Services:
- Option 1: Using Azure Login
- Option 2: Create an azure DevOps Services signin using GitHub from here
-
Create an Organization and Project in Azure DevOps Services
Azure DevOps Interfaces
- UI : https://dev.azure.com/<yourorganization>
- Azure DevOps CLI Refer Here
- Azure DevOps Services Rest API Refer Here
Azure DevOps Pipelines
- Note: This whole series is assuming you know Jenkins and Jenkins Pipelines
- Lets do the basic comparision
Jenkinsfile vs azure-pipelines.yml
- In Jenkins the pipleines are configured in Jenkinsfile and in azure-devops we create the pipeline in azure-pipelines.yml
- Example Jenkinsfile
pipeline {
agent any
stages {
stage('build') {
steps {
git 'https://github.com/mycode.git'
sh 'mvn package'
}
}
}
}
- Same in azure-pipelines.yml
jobs:
- job: build
steps:
- script: git clone 'https://github.com/mycode.git'
- script: mvn package
-
Jenkins Pipeline Structure
-
Azure Pipeline Structure
-
note: Agent is exactly like Jenkins Node
-
Agents: Agents are of three types
- Microsoft Azure Agents:
- These agents are created/managed By DevOps pipeline in Azure
- Need to know the names of the image/label Refer Here
- Self-Hosted
- Container
- Microsoft Azure Agents:
-
Agents are grouped as Agent pools and Each agent will have capabilities.
-
In Jenkins We Use Parameters to pass inputs to the Job, Same in Azure DevOps.
-
In Jenkins we use pipeline steps reference Refer Here and in the case of Azure DevOps we use tasks for actual activities Refer Here
Scenario: Build a Java Project on Microsoft Hosted Agent
-
Open the project in visual studio code (gameoflife) and ensure azure devops extensionis installed
-
Lets write a pipeline
---
trigger:
- master
- develop
pool:
name: KhajaLearning
stages:
- stage: Build
jobs:
- job: 'BuildJob'
steps:
- task: Maven@3
inputs:
goals: deploy
mavenPomFile: 'pom.xml'
publishJUnitResults: true
testResultsFiles: '**/surefire-reports/TEST-*.xml'
javaHomeOption: 'JDKVersion'
mavenVersionOption: 'Default'
mavenAuthenticateFeed: false
effectivePomSkip: false
sonarQubeRunAnalysis: false
- job: 'Deploy'
steps:
- task: Bash@3
inputs:
targetType: inline
script: 'terraform init ./deployment/ && terraform apply -auto-approve ./deployment/'
- Parameters Configuration
- Like Jenkins Environmental Variables we have Azure DevOPs Predefined Varaibles Refer Here
Summary
-
Configure Git Repos
-
Add azure-pipelines.yaml
-
Configure Artifacts and create feed (if required)
-
Maintain the structure and look at YAML task definitions Refer Here
-
Exercise: Create a azure devops pipeline for spring pet clinic