Azure DevOps CI/CD — Creating CI for code hosted in Github

Create Docker Image from Dockerfile & push it to Azure Container Registry

Steps

  1. Signup for Azure DevOps portal
  2. Lets create a new CI pipeline
  3. Time to create container registry
  4. Resource group — Its mandatory
  5. Now back to our CI pipeline

Signup for Azure DevOps portal

Lets get started by creating an account in Azure DevOps site — https://azure.microsoft.com/en-in/services/devops/

Lets create a new pipeline

For this tutorial, I am gonna use my User-Management-With-JWT project maintained in GitHub

Choose Pipelines from list of menu
Click on Use the classic Editor link
I chose my repo User-Management-With-JWT & branch as master
Dockerfile available in root folder of Github repo
Choose Maven as template type
Maven template added few default steps in Pipeline
Click on + sign to add a task
Choose the Docker as Task
Container Registry is mandatory for the Docker image built in CI to be pushed

Time to create container registry

As you might aware, Docker images are built from Dockerfile & are pushed to container registry

Later during continuous deployment, we will be deploying the docker image from container registry

  • Go to https://portal.azure.com & search Container registries in search bar.
  • Click on Add button in Azure Container Registries portal
Add button can be seen in Top right side
Create new in Resource group can be used to create Resource group

Resource group — Its mandatory

  • Its mandatory to have a resource group to create container registry. Click on create create new in case you haven’t have one
Create Resource Group
  • Enter a new name for your Registry under Registry name & chose server Location near to your location
I created new container registry with name CiCdDemoRegistry
Deployment is Complete marks successful creation of Container Registry

Now back to our CI pipeline..

  • Click on New button next to Container Registry drop down & choose Azure Container registry as Registry type
  • Choose the Azure Container Registry you created few steps back & enter a new for service connection name & hit save
  • Enter Container repository name — E.g. CiCdDemoRepo
  • Choose the Dockerfile correctly by clicking on the three dots near the Textbox
  • Click on Save & Queue to run the pipeline
Our CI ran successfully

--

--

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store