Apisero is now part of NTT DATA - Learn more.

Search
Close this search box.

Azure CI/CD: Build Pipeline

Author: Kishori Patil

Content: 

  • CI/CD stands for continuous integration and continuous deployment / delivery.
  • CI/CD pipeline is a best practice for DevOps teams. 
  • It enables developers to deliver code changes frequently and reliably without error.
  • In CI/CD we can create build pipeline and release pipeline.
  • Build pipeline is the tool chain which collects the latest changes from the repository and the branch and creates a package to a location which can later pick up the release pipeline.
Creating build pipeline:

SETUP:

1. In azure go to  project> pipelines >new pipeline.

2. Select Use the classic editor to create a pipeline without the YAML option at the bottom.

3. Then select the repo for which you want to create a pipeline. Also select the Default branch for manual and scheduled builds.

4. Search for maven and click on apply to add it to your pipeline.

5. First change the name of the pipeline as follows. (from  to) also select the agent specification as per your choice.

6. Before changing any other configuration, you will need to download your settings.xml file.

7. For this click on add a task to agent job 1 + symbol, type Download secure file and add it to pipeline.

8. You need to place it at top as before running your maven goal you will need that settings.xml file.

9. In Download secure file you have 2 options. You can either select a file from the secure files which you have already added in your library or you can browse a file from your system.

  1. 10. To how to configure and add settings.xml file in your library you can check this blog: Connected App For Azure CI/CD
  1. 11. As we have already added settings.xml in the library, we will select it from there.

12. In the output variables option of download secure file add reference name to your settings.xml file.

13. Every time you run this pipeline, it will download all the dependencies again. To avoid that, add a step Cache. This will cache dependencies which act as Maven local repo.

14. Key is nothing but  your pom.xml file location and path is stored in a variable called MAVEN_CACHE_FOLDER.

15. You have already defined this variable in a common variable group.

16. Then move to Maven pom.xml task. Here you will add your maven goal and options.

17. For maven goal I am adding a clean package goal and options are as you can see in the below screenshot.

18. Next is Copy jar Files to: $(build.artifactstagingdirectory) task. Here you need to add pom.xml in the content section and other configuration as it is.

19. No need to change anything in Publish Artifact: drop task.

20. Now go to the variables section and link the variables group to the respective environment using scopes. You can also add some variables for this pipeline in pipeline variables.

21. Move to triggers and select continuous integration. Select branches for which you want this pipeline to trigger.

22. Save the pipeline. If you want to test the created pipeline, you can click save and queue. This will start the pipeline. We will run the pipeline once the release pipeline for this is completed.

23. Now your build pipeline is ready. If you commit change to any (dev,qa,main) branch, this pipeline will be triggered automatically and executed to create a jar file for this application.

24 This jar file will be used in the release pipeline for deployment.

We use cookies on this site to enhance your user experience. For a complete overview of how we use cookies, please see our privacy policy.