Azure DevOps发布管道Azure CLI Powershell任务找不到powershell

问题描述 投票:0回答:1

使用:Pool: Azure Pipelines · Agent: Hosted Agent

第一版仅包含2个任务:

  1. 编写“ Hello world”的Powershell内联脚本
  2. Powershell on Azure订阅内联脚本,其中写有“ Hello world”enter image description here

效果很好。

添加其他任务后:

  1. 执行我们的PowerShell脚本

  2. 。4部署到Kubernetes任务。enter image description here

使用system.debug创建的发行版,并且在执行第一个任务时失败,并显示错误:

2020-05-20T06:57:10.3710666Z ##[error]The term 'powershell.exe' 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.
Executing with system.debug gave this output:

2020-05-20T07:15:13.9833585Z ##[debug]Evaluating condition for step: 'Hello World'
2020-05-20T07:15:13.9843565Z ##[debug]Evaluating: succeeded()
2020-05-20T07:15:13.9844512Z ##[debug]Evaluating succeeded:
2020-05-20T07:15:13.9845838Z ##[debug]=> True
2020-05-20T07:15:13.9846542Z ##[debug]Result: True
2020-05-20T07:15:13.9847415Z ##[section]Starting: Hello World
2020-05-20T07:15:14.0314856Z ==============================================================================
2020-05-20T07:15:14.0315650Z Task         : PowerShell
2020-05-20T07:15:14.0317519Z Description  : Run a PowerShell script on Linux, macOS, or Windows
2020-05-20T07:15:14.0317953Z Version      : 2.169.0
2020-05-20T07:15:14.0318548Z Author       : Microsoft Corporation
2020-05-20T07:15:14.0319259Z Help         : https://docs.microsoft.com/azure/devops/pipelines/tasks/utility/powershell
2020-05-20T07:15:14.0319792Z ==============================================================================
2020-05-20T07:15:15.8622679Z ##[debug]VstsTaskSdk 0.11.0 commit 7ff27a3e0bdd6f7b06690ae5f5b63cb84d0f23f4
2020-05-20T07:15:16.0680294Z ##[debug]Entering D:\a\_tasks\PowerShell_e213ff0f-5d5c-4791-802d-52ea3e7be1f1\2.169.0\powershell.ps1.
2020-05-20T07:15:16.0782094Z ##[debug]Loading resource strings from: D:\a\_tasks\PowerShell_e213ff0f-5d5c-4791-802d-52ea3e7be1f1\2.169.0\task.json
2020-05-20T07:15:16.1340432Z ##[debug]Loaded 11 strings.
2020-05-20T07:15:16.1343861Z ##[debug]SYSTEM_CULTURE: 'en-US'
2020-05-20T07:15:16.1345219Z ##[debug]Loading resource strings from: D:\a\_tasks\PowerShell_e213ff0f-5d5c-4791-802d-52ea3e7be1f1\2.169.0\Strings\resources.resjson\en-US\resources.resjson
2020-05-20T07:15:16.1597086Z ##[debug]Loaded 11 strings.
2020-05-20T07:15:16.1959084Z ##[debug]INPUT_ERRORACTIONPREFERENCE: 'stop'
2020-05-20T07:15:16.2027000Z ##[debug]INPUT_FAILONSTDERR: 'false'
2020-05-20T07:15:16.2028272Z ##[debug] Converted to bool: False
2020-05-20T07:15:16.2041964Z ##[debug]INPUT_IGNORELASTEXITCODE: 'false'
2020-05-20T07:15:16.2056755Z ##[debug] Converted to bool: False
2020-05-20T07:15:16.2081737Z ##[debug]INPUT_PWSH: 'false'
2020-05-20T07:15:16.2100091Z ##[debug] Converted to bool: False
2020-05-20T07:15:16.2122826Z ##[debug]INPUT_WORKINGDIRECTORY: 'D:\a\r1\a'
2020-05-20T07:15:16.2247526Z ##[debug]Asserting container path exists: 'D:\a\r1\a'
2020-05-20T07:15:16.2273044Z ##[debug]INPUT_TARGETTYPE: 'inline'
2020-05-20T07:15:16.2307533Z ##[debug]INPUT_SCRIPT: '# Write your PowerShell commands here.
2020-05-20T07:15:16.2320023Z ##[debug]
2020-05-20T07:15:16.2331579Z ##[debug]Write-Host "Hello World"'
2020-05-20T07:15:16.2375904Z Generating script.
2020-05-20T07:15:16.2515233Z ##[debug]AGENT_VERSION: '2.168.2'
2020-05-20T07:15:16.2594226Z ##[debug]AGENT_TEMPDIRECTORY: 'D:\a\_temp'
2020-05-20T07:15:16.2614777Z ##[debug]Asserting container path exists: 'D:\a\_temp'
2020-05-20T07:15:27.6754436Z ##[debug]Leaving D:\a\_tasks\PowerShell_e213ff0f-5d5c-4791-802d-52ea3e7be1f1\2.169.0\powershell.ps1.
2020-05-20T07:15:27.9496049Z ##[debug]Caught exception from task script.
2020-05-20T07:15:27.9529115Z ##[debug]Error record:
2020-05-20T07:15:28.0379597Z ##[debug]The term 'powershell.exe' 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.
2020-05-20T07:15:28.0395647Z ##[debug]    + CategoryInfo          : ObjectNotFound: (powershell.exe:String) [], CommandNotFoundException
2020-05-20T07:15:28.0402331Z ##[debug]    + FullyQualifiedErrorId : CommandNotFoundException
2020-05-20T07:15:28.0412871Z ##[debug] 
2020-05-20T07:15:28.0433105Z ##[debug]Script stack trace:
2020-05-20T07:15:28.0479363Z ##[debug]
2020-05-20T07:15:28.1031586Z ##[debug]Exception:
2020-05-20T07:15:28.1168338Z ##[debug]System.Management.Automation.CommandNotFoundException: The term 'powershell.exe' 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.
2020-05-20T07:15:28.1325804Z ##[error]The term 'powershell.exe' 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.
2020-05-20T07:15:28.1338779Z ##[debug]Processed: ##vso[task.logissue type=error]The term 'powershell.exe' 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.
2020-05-20T07:15:28.1347561Z ##[debug]Processed: ##vso[task.complete result=Failed]
2020-05-20T07:15:28.2164053Z ##[section]Finishing: Hello World
azure azure-devops azure-pipelines-release-pipeline
1个回答
0
投票

注意。

不要在Azure DevOps管道中命名您的变量path,因为它将重写环境变量PATH。重命名我的变量后,它又可以工作了,并且能够找到所有工具。在MS文档中没有提到它,因此我为他们创建了一张票。

© www.soinside.com 2019 - 2024. All rights reserved.