I have the following simple pipeline that I'd like to run a bicep file with param file:
name: "BRCi.HMRC.Scaffolding"
trigger: none
pool:
vmImage: "ubuntu-latest"
stages:
- stage: DeployTest
variables:
env: Test
jobs:
- deployment: deploy
environment: Test
strategy:
runOnce:
deploy:
steps:
- checkout: self
- task: CmdLine@2
displayName: List files2
inputs:
script: |
echo "Structure of work folder of this pipeline:"
tree $(Pipeline.Workspace)
- task: AzureCLI@2
displayName: Deploy Template
inputs:
azureSubscription: brci-devops-sc-tst-BRCi.HMRC
scriptType: pscore
scriptLocation: inlineScript
inlineScript: az deployment group create `
--resource-group brci-hmrc2-rg-tst
--template-file $(Pipeline.Workspace)/Bicep/Main.bicep `
--parameters $(Pipeline.Workspace)/Bicep/Hmrc.Parameters.Test.json
The output from the List files2 job looks good:
/home/vsts/work/1
├── TestResults
├── a
├── b
└── s
├── Bicep
│ ├── Hmrc.Parameters.Test.json
│ ├── Main.bicep
│ └── giftaidLogicApp.bicep
├── README.md
└── azure-pipelines.yml
But, the line that tries to run az deployment group create fails with the following error:
ERROR: An error occurred reading file. Could not find a part of the path '/home/vsts/work/1/Bicep/Main.bicep'.
CodePudding user response:
Please set workingDirectory as $(Pipeline.Workspace)
for your task: AzureCLI@2
I ran this:
- deployment: DeployWeb
displayName: deploy Web App
environment: 'Dev'
strategy:
runOnce:
deploy:
steps:
- checkout: self
- script: |
pwd
echo "$(Pipeline.Workspace)"
and got
/home/vsts/work/1/s
/home/vsts/work/1
So your task is executed in /home/vsts/work/1/s
and this is why you need to switch workingDirectory.