DevOps Classroom notes 27/Oct/2023

Azure DevOps Contd

Azure DevOps YAML Schema

  • Generally the pipeline as a code is represented in a file called as azure-pipelines.yaml.
  • The name of the file is not fixed but azure-pipelines.yaml is most widely used.
  • Refer Here for official docs
  • Azure Pipelines is collection of
    • Stages: Each Stage is collection of Jobs
    • Job: Each job is collection steps
    • Step: A unit of activity
      Preview
  • If we have only one stage then Azure Pipeline is collection of Jobs and if Azure pipeline has only one stage and one one job then Azure pipeline can be considered as set of steps

Lets create a pipeline for java project

  • Refer Here for manual steps
  • What would be the pipelines yaml look like
  • First Version (Stage,job and steps)
pool: default
stages:
  - stage: 'buildstage'
    displayName: Build and Package using Maven
    jobs:
      - job: 'buildjob'
        displayName: 'Build the application using Maven'
        steps:
          - bash: 'mvn pacakage'
---
  • Second Version (Job and steps)
---
pool: default
jobs:
  - job: 'buildjob'
    displayName: 'Build the application using Maven'
    steps:
        - bash: 'mvn package'
---

  • Third version (steps)
---
pool: default
steps:
  - bash: 'mvn package'

Azure DevOps Steps

  • Types of Steps

    • task: reusable build/deploy/utility steps
    • script: Runs a script using cmd.exe on Windows and Bash on other platforms.
    • powershell: Runs a script in a powershell
    • pwsh: Runs a script in a powershell core
    • bash: Runs a script in a bash shell
    • download
    • downloadBuild
    • getPackage
    • publish
    • template
    • reviewApp
  • Azure DevOps allows us to create reusable steps where we fill the yaml and it does the rest. This is done by Task.
  • Refer Here for tasks.
  • If you want to develop a reusable task Refer Here
  • Install Azure Pipelines Extension into Visual Studio Code
    Preview
  • We have started using Maven Task
pool: default

steps:
  - task: Maven@4
    inputs:
      mavenPOMFile: pom.xml
      goals: package
      publishJUnitResults: true
      testResultsFiles: '**/TEST-*.xml'
      javaHomeOption: Path
      jdkVersionOption: '1.17'
      jdkDirectory: '/usr/lib/jvm/java-17-openjdk-amd64'
      mavenVersionOption: Path
      mavenDirectory: '/usr/share/maven'

Preview
Preview

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.

About continuous learner

devops & cloud enthusiastic learner