I have a powershell script that runs fine in my local but it wont run on the Azure DevOps Pipeline by Committing the script in the repo. The script include multiple .psm1 Modules and it seems like devOps cant find the module. I tried committing the module files on the repo and Calling it via Import-Module but its still the same error
0
votes
1 Answers
3
votes
It's difficult for me to answer the questions. It would be nice to have more screenshots, paths, details and environment, but I can tell you how I would do it.
1) The example is based on ASP.NET project where I added ps1 script with psm1 module to the main project path. 2) I pushed everything to the Azure Devops repo. 3) I used Inline script to run the ps1 script:
- task: PowerShell@2
inputs:
targetType: 'inline'
script: '$(BUILD.REPOSITORY.LOCALPATH)\$(SYSTEM.TEAMPROJECT)\testScript.ps1'
4) In the script I used local path
Import-Module -Name ./testModule.psm1 -Verbose -ArgumentList 'Argument1'
And it worked.
PS.
You can use powershell inline script to look at your azure devops variables
- task: PowerShell@2
inputs:
targetType: 'inline'
script: 'get-childitem -path env:*'
Using this information you can use powershell inline script to look for your PS1/PSM1 files:
- task: PowerShell@2
inputs:
targetType: 'inline'
script: 'ls $(BUILD.REPOSITORY.LOCALPATH)\$(SYSTEM.TEAMPROJECT)'