My Yaml Azure Devops pipeline failed when running a script.
Situation
I have this script in the Tuto-BuildDeploy repository:
trigger:
- none
pool:
vmImage: windows-latest
resources:
repositories:
- repository: TutoDeploy
ref: main
type: git
name: Tuto-Deploy
jobs:
- job: checkout
steps:
- checkout: self
- checkout: TutoDeploy
- job: Deploy
dependsOn:
- checkout
steps:
- task: AzurePowerShell@5
inputs:
azureSubscription: 'ToAzureCnx'
ScriptType: 'FilePath'
ScriptPath: .\Tuto-Deploy\build.ps1
azurePowerShellVersion: 'LatestVersion'
This is my build.ps1 file:
param
(
)
$resourceGroup = "RG2"
$location = "westeurope"
New-AzResourceGroup -Name $resourceGroup -Location $location -Force
What happend
I get this error message:
##[error]The term 'D:\a\1\s\Tuto-Deploy\build.ps1' is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spelling of the name, or if a path was included, verify that the path is correct and try again.
what I tested
I added :
- script: dir $(Build.SourcesDirectory)\Tuto-Deploy
To check build.ps1 if is downloaded.
I also tried to run it from a pipeline in the project Tuto-Deploy:
trigger:
- main
pool:
vmImage: windows-latest
steps:
- task: AzurePowerShell@5
inputs:
azureSubscription: 'ToAzureCnx'
ScriptType: 'FilePath'
ScriptPath: '$(System.DefaultWorkingDirectory)/build.ps1'
azurePowerShellVersion: 'LatestVersion'
It works fine.
So I don't think I have a problem with the script.
What I need
I don't understand why it is not working. What ca I do?
thanks