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
-
Hi, How is your issue progressing?Is Kamil's answer helpful to you ?Hugh Lin– Hugh Lin2019-10-21 11:23:38 +00:00Commented Oct 21, 2019 at 11:23
-
yes it was very helpful ThanksMar– Mar2019-11-06 07:25:57 +00:00Commented Nov 6, 2019 at 7:25
-
If the answer resolve your question, you could Accept it as an Answer. This can be beneficial to other community members reading this thread.Hugh Lin– Hugh Lin2019-11-06 07:30:38 +00:00Commented Nov 6, 2019 at 7:30
1 Answer
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)'