2

I'm trying to debug a pipeline script in Azure to see what the variables are, but I'm not sure of the syntax.

I have looked through the documentation

What I have tried so far

parameters:
  deploymentName: ""
  dependsOn: ""
  env: ""
  dockerfilePath: ""
  buildContext: ""
  repository: ""
  envGroup: ""
  dockerRegistryServiceConnection: ""
  tag: ""
  token: ""
  runTests: ""

jobs:
  - deployment: ${{ parameters.deploymentName }}
    dependsOn: ${{ parameters.dependsOn }}
    pool: "Private Docker"
    environment: "${{ parameters.envGroup }}"
    strategy:
      runOnce:
        deploy:
          steps:
            - checkout: self
            - task: Docker@2
              displayName: "ACR Login"
              inputs:
                command: login
                containerRegistry: "${{ parameters.dockerRegistryServiceConnection }}"
            ##[debug]Debug!!!!!1 $runTests
            ##[debug]Debug!!!!!2 $parameters.runTests
            ##[debug]Debug!!!!!3 ${{parameters.runTests}}
            - script: echo runTests in dockerbuild.yml ${{parameters.runTests}}
            - script: echo runTests in dockerbuild.yml $parameters.runTests
            - script: echo runTests in dockerbuild.yml $runTests
            - task: Docker@2
              displayName: Build
              inputs:
                command: build
                repository: "${{ parameters.repository }}"
                buildContext: "${{ parameters.buildContext }}"
                dockerfile: "${{ parameters.dockerfilePath }}"
                arguments: "--build-arg TOKEN=${{ parameters.token }} --build-arg RUNTESTS=${{ parameters.runTests }}"
                tags: |
                  $(Build.BuildId)
                  latest

Problem

The debug and echo do not print anything in the azure pipeline build:

##[debug]Debug!!!!!1 $runTests
            ##[debug]Debug!!!!!2 $parameters.runTests
            ##[debug]Debug!!!!!3 ${{parameters.runTests}}
            - script: echo runTests in dockerbuild.yml ${{parameters.runTests}}
            - script: echo runTests in dockerbuild.yml $parameters.runTests
            - script: echo runTests in dockerbuild.yml $runTests

Question

Is this the correct syntax for printing to the azure bash when running the yaml file?

0

2 Answers 2

1

Debugging yaml pipeline script

It seems that you did not define the parameters correctly. We need provide the name, displayName, type, default, values like following (Not every attribute is required):

parameters:
  - name: deploymentName
    type: string
    default: Product

Then we could use the ${{ parameters.deploymentName }} to get the value.

Please check this document Runtime parameters for some more details.

My test YAML file:

parameters:
  - name: deploymentName
    type: string
    default: Product
  - name: dependsOn
    type: string
    default: Test
  - name: envGroup
    type: string
    default: test
  - name: runTests
    type: number
    default: 123



stages:
- stage: Build
  jobs:
  - job: Build
    displayName: Build
    pool:
     name: MyPrivateAgent
    steps:
    - script: echo This is for Build


- stage: Dev
  jobs:
    - job: Test
      displayName: Test
      pool:
        name: MyPrivateAgent
      steps:
      - script: echo This is for test
    

    - deployment: ${{ parameters.deploymentName }}
      dependsOn: ${{ parameters.dependsOn }}
      pool:
        name: MyPrivateAgent
      environment: "${{ parameters.envGroup }}"
      strategy:
        runOnce:
          deploy:
            steps:
              - checkout: self
              - script: echo runTests in dockerbuild.yml ${{parameters.runTests}}

The test result:

enter image description here

Sign up to request clarification or add additional context in comments.

Comments

0

Try this:

${{ parameters.runTests}}

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.