Share via

##[error]PowerShell exited with code '1'. getting this error in my devops pipeline run

Amuktha Rao 0 Reputation points
2026-07-02T02:17:50.2066667+00:00

I am getting below error while running teh pipeline for sandbox in azure devops for salesfoece

2026-07-02T01:25:56.3263679Z ##[section]Starting: ResolveEnvironment
2026-07-02T01:25:56.3271729Z ==============================================================================
2026-07-02T01:25:56.3271936Z Task         : PowerShell
2026-07-02T01:25:56.3272022Z Description  : Run a PowerShell script on Linux, macOS, or Windows
2026-07-02T01:25:56.3272154Z Version      : 2.276.0
2026-07-02T01:25:56.3272249Z Author       : Microsoft Corporation
2026-07-02T01:25:56.3272355Z Help         : https://docs.microsoft.com/azure/devops/pipelines/tasks/utility/powershell
2026-07-02T01:25:56.3272500Z ==============================================================================
2026-07-02T01:25:56.4467709Z Generating script.
2026-07-02T01:25:56.4483043Z ========================== Starting Command Output ===========================
2026-07-02T01:25:56.4489560Z [command]/usr/bin/pwsh -NoLogo -NoProfile -NonInteractive -Command . '/home/vsts/work/_temp/3857d4cf-b5ce-45d0-b72b-1ca2eb0f86fe.ps1'
2026-07-02T01:25:57.3896674Z 
2026-07-02T01:25:57.3898830Z Id     Name            PSJobTypeName   State         HasMoreData     Location
2026-07-02T01:25:57.3900578Z --     ----            -------------   -----         -----------     --------  
2026-07-02T01:25:57.3901448Z 1      ce1b2c25-364a-…                 NotStarted    False                     
2026-07-02T01:25:58.6830431Z Select Environment - Inputs:
2026-07-02T01:25:58.6851447Z 
2026-07-02T01:25:58.6855346Z 
2026-07-02T01:25:58.6915163Z VariableNamePrefix         : Target.
2026-07-02T01:25:58.6918316Z EnvironmentConfigPath      : /home/vsts/work/1/tools/resources/environments
2026-07-02T01:25:58.6922063Z EnvironmentConfigSource    : YamlFile
2026-07-02T01:25:58.6922782Z UnknownEnvironmentAction   : None
2026-07-02T01:25:58.6923460Z SourceBranchName           : environment/revsit
2026-07-02T01:25:58.6924111Z OverrideIgnoreValuePattern : ^--.*--$|^<.*>$
2026-07-02T01:25:58.6924770Z PrototypeEnvironment       : __n/a__
2026-07-02T01:25:58.6925437Z OverrideVariablePrefix     : Override.
2026-07-02T01:25:58.6926074Z EnvironmentId              : 
2026-07-02T01:25:58.6926421Z 
2026-07-02T01:25:58.6926901Z Configured Environments:
2026-07-02T01:25:59.8251691Z Get-YamlDocuments: Exception calling "Load" with "1" argument(s): "(Line: 57, Col: 2, Idx: 1891) -
2026-07-02T01:25:59.8255984Z (Line: 57, Col: 2, Idx: 1891): While parsing a block mapping, did not find
2026-07-02T01:25:59.8256850Z expected key."
2026-07-02T01:25:59.8920913Z 
2026-07-02T01:25:59.8971653Z ##[error]PowerShell exited with code '1'.
2026-07-02T01:25:59.9024113Z ##[section]Finishing: ResolveEnvironment
Azure DevOps
0 comments No comments

1 answer

Sort by: Most helpful
  1. Marcin Policht 94,615 Reputation points MVP Volunteer Moderator
    2026-07-02T03:32:36.7533333+00:00

    It looks like the pipeline is failing because there is a syntax error in one of your YAML environment configuration files (the error is: “While parsing a block mapping, did not find expected key.”)

    This might mean the YAML parser found invalid formatting near line 57 of the file being loaded from /home/vsts/work/1/tools/resources/environments

    This might be as simple as a missing colon, incorrect indentation, tabs instead of spaces, misplaced hyphen, or unclosed quote invalid list or mapping structure.

    Check the YAML file associated with the branch “environment/revsit” and carefully inspect around line 57.

    Also verify that all indentation uses spaces only, every key ends with a colon, list items use consistent hyphen formatting, quotes are properly closed, and there are no accidental extra characters

    You can validate the YAML using VS Code with the YAML extension, Azure DevOps YAML validation, or an online YAML linter.


    If the above response helps answer your question, remember to "Accept Answer" so that others in the community facing similar issues can easily find the solution. Your contribution is highly appreciated.

    hth

    Marcin

    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.