Azure DevOps CI for Spring Boot Application hosted in Github
This is first among series of articles on how to build & deploy a SpringBoot Application into Azure App service using Azure DevOps CI & CD
Steps
- Signup for Azure DevOps portal
- Lets create a new CI pipeline
- Time to create container registry
- Resource group — Its mandatory
- 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/
I used my Github login to signup. Once signup is done, create a new organisation in Azure DevOps portal
Once organisation is created, create a new project.
For detailed step, visit here https://docs.microsoft.com/en-us/azure/devops/organizations/projects/create-project?view=azure-devops&tabs=preview-page
Lets create a new pipeline
For this tutorial, I am gonna use my User-Management-With-JWT project maintained in GitHub
Click on Pipelines -> Pipelines -> New Pipeline
Click the hyperlink Use the classic Editor to create a pipeline without YAML
Select the source as Github. Choose the repo & branch details (remember you have to Authorise Azure to pull repos from your Github repo)
Next step is to select a template
For my User-Management-With-JWT project to work, first we need to package the application as Jar file & then build Docker Image based on it
Since my repo is a maven project, I chose the maven template to generate the Jar file
Now you can see, few steps added in default by maven
Maven pom.xml step is enough for generating the jar file.
So let’s remove the other steps such as “Copy files to ${build.artifactstagingdirectory}” & “publish Artifact drop”.
Remove them by right click on the steps & choose Remove selected task(s)
Once Jar file is generated, we need to build the Docker image. In order to do it, we need to add the Docker task next to maven task
Now click on + symbol next to Agent Job 1& choose the Docker task
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
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
- Enter a new name for your Registry under Registry name & chose server Location near to your location
Click on create & you should see Deployment is complete message like below
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
Thats all folks !
Continue reading on next article — Azure DevOps CI/CD — Creating CD to deploy Docker Image in App Service
https://medium.com/@iamvickyav/azure-devops-ci-cd-creating-cd-to-deploy-docker-image-64bb24f6ac1d