DevOps Classroomnotes 11/Feb/2023

Azure DevOps Pipelines Contd…

Expressions

  • Refer Here for official docs
  • Compile time vs runtime
#syntax ${{}} for compile time and $[] for runtime expressions.
variables:
  a: ${{ <expression> }}
  b: $[ <expression> ]
  • Functions in expressions Refer Here
  • Lets use expressions to print the BuildId and Parameter
# Starter pipeline
# Start with a minimal pipeline that you can customize to build and deploy your code.
# Add steps that build, run tests, deploy, and more:
# https://aka.ms/yaml

trigger:
- main

pool:
  vmImage: ubuntu-latest


parameters:
  - name: version
    displayName: version
    type: string
    default: v1.0
variables:
  runtimetag: ${{format('{0}-{1}', 'v1.0', '$(Build.BuildId)')}}

steps:
- script: "echo ${{ parameters.version }}-$(Build.BuildId)"
  displayName: Say hello
- script: "echo ${{ variables.runtimetag }}"
  displayName: "Say hello again"
# Starter pipeline
# Start with a minimal pipeline that you can customize to build and deploy your code.
# Add steps that build, run tests, deploy, and more:
# https://aka.ms/yaml

trigger:
- main

pool:
  vmImage: ubuntu-latest

variables:
  color: red


steps:
  - ${{ if eq(variables.color, 'red') }}:
      - script: echo red
        displayName: red
  - ${{ if eq(variables.color, 'blue') }}:
      - script: echo blue
        displayName: blue
  • repeating the steps
# Starter pipeline
# Start with a minimal pipeline that you can customize to build and deploy your code.
# Add steps that build, run tests, deploy, and more:
# https://aka.ms/yaml

trigger:
- main

pool:
  vmImage: ubuntu-latest

variables:
  color: red

parameters:
  - name: listofbuilds
    type: object
    default:
      - mac
      - windows
      - linux



steps:
  - ${{ if eq(variables.color, 'red') }}:
      - script: echo red
        displayName: red
  - ${{ if eq(variables.color, 'blue') }}:
      - script: echo blue
        displayName: blue
  - ${{ each value in parameters.listofbuilds }}:
      - script: echo  ${{ value }}
        displayName: ${{ value }}

Preview

Service Connections

  • Refer Here for Azure DevOps Service Pipeline connections.
  • Service Connection Types Refer Here
  • Refer Here for Azure Devops Toolkit for AWS
  • Refer Here to create a service connection from Azure Devops to GCP
  • Note: Refer Here for a document which speaks from code to kubernetes

Leave a Reply

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

About continuous learner

devops & cloud enthusiastic learner