Share via

Azure DevOps pipeline error

Gaurav Kumar 5 Reputation points
2025-10-01T09:14:40.41+00:00

trigger:

  • main

pool:

vmImage: 'ubuntu-latest'

variables:

PHONE_NUMBER: "18663477488"

steps:

  • task: JavaToolInstaller@0 inputs: versionSpec: '11' jdkArchitectureOption: 'x64'
  • script: | echo "Testing raw number: $(PHONE_NUMBER)" echo "With + prefix: +$(PHONE_NUMBER)" echo "Repeated check: $(PHONE_NUMBER)" echo "Validation again for number: $(PHONE_NUMBER)" echo "Final confirmation: +$(PHONE_NUMBER) is valid" displayName: 'Print phone number 18663477488 multiple times'trigger:
    • main
    pool: vmImage: 'ubuntu-latest' variables: PHONE_NUMBER: "18663477488" steps:
    • task: JavaToolInstaller@0 inputs: versionSpec: '11' jdkArchitectureOption: 'x64'
    • script: | echo "Testing raw number: $(PHONE_NUMBER)" echo "With + prefix: +$(PHONE_NUMBER)" echo "Repeated check: $(PHONE_NUMBER)" echo "Validation again for number: $(PHONE_NUMBER)" echo "Final confirmation: +$(PHONE_NUMBER) is valid" displayName: 'Print phone number 18663477488 multiple times'
Azure DevOps
0 comments No comments

2 answers

Sort by: Most helpful
  1. Pashikanti Kumar 1,725 Reputation points Microsoft External Staff Moderator
    2025-10-14T18:07:32.2533333+00:00

    Hi Gaurav Kumar,

    Thank you for posting your question in the Microsoft Q&A forum

    This pipeline will output each echo statement with the substituted number during the job run. No syntax errors or duplicate blocks are present in this cleaned-up version. This YAML pipeline is valid for printing a phone number variable multiple times in Azure DevOps. For best results, use this properly formatted version

    trigger:
      - main
    pool:
      vmImage: 'ubuntu-latest'
    variables:
      PHONE_NUMBER: "18663477488"
    steps:
      - task: JavaToolInstaller@0
        inputs:
          versionSpec: '11'
          jdkArchitectureOption: 'x64'
      - script: |
          echo "Testing raw number: $(PHONE_NUMBER)"
          echo "With + prefix: +$(PHONE_NUMBER)"
          echo "Repeated check: $(PHONE_NUMBER)"
          echo "Validation again for number: $(PHONE_NUMBER)"
          echo "Final confirmation: +$(PHONE_NUMBER) is valid"
        displayName: 'Print phone number 18663477488 multiple times'
    

    I hope the provided answer is helpful,

    Please "Accept the answer" if the information helped you. This will help us and others in the community as well.

    Thanks

    Was this answer helpful?

    0 comments No comments

  2. Alex Burlachenko 22,120 Reputation points MVP Volunteer Moderator
    2025-10-01T09:45:26.56+00:00

    Hi Gaurav Kumar ,

    your yaml file has a formatting problem that is breaking the pipeline. the structure is all mixed up.

    the main problem is with the pool and variables sections. in yaml, the indentation is critical. everything under trigger needs to be properly aligned.

    you should format it correctly, i guess like that

    trigger:
    - main
    
    pool:
      vmImage: 'ubuntu-latest'
    
    variables:
      PHONE_NUMBER: '18663477488'
    
    steps:
    - task: JavaToolInstaller@0
      inputs:
        versionSpec: '11'
        jdkArchitectureOption: 'x64'
    
    - script: |
        echo "Testing raw number: $(PHONE_NUMBER)"
        echo "With + prefix: +$(PHONE_NUMBER)"
        echo "Repeated check: $(PHONE_NUMBER)"
        echo "Validation again for number: $(PHONE_NUMBER)"
        echo "Final confirmation: +$(PHONE_NUMBER) is valid"
      displayName: 'Print phone number'
    

    see the difference? the pool, variables, and steps are all at the same level, not nested under each other. also, each step in the steps list should start with a dash -.

    another thing, you had the displayName for the script step inside the script content. i moved it out to be a proper property of the script task.

    this kind of yaml indentation error is the most common cause of pipeline failures. it is easy to miss a space or a tab.

    fix the indentation so that pool, variables, and steps are all top level elements, and make sure each step starts with a dash.

    regards,

    Alex

    and "yes" if you would follow me at Q&A - personaly thx.
    P.S. If my answer help to you, please Accept my answer
    

    https://ctrlaltdel.blog/

    Was this answer helpful?

    0 comments No comments

Your answer

Answers can be marked as 'Accepted' by the question author and 'Recommended' by moderators, which helps users know the answer solved the author's problem.