gpt4 book ai didi

azure-pipelines - Azure Pipelines AzurePowerShell@4 任务尝试运行一个奇怪的命令并失败

转载 作者:行者123 更新时间:2023-12-02 03:11:02 31 4
gpt4 key购买 nike

根据此处的文档运行 Azure PowerShell 任务时,我在 Azure DevOps Pipelines 中看到此错误:

https://learn.microsoft.com/en-us/azure/devops/pipelines/tasks/deploy/azure-powershell?view=azure-devops

错误

The term 'd:\a\1\s' 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.

我的管道 YAML 看起来像这样。

  - task: AzurePowerShell@4
inputs:
azureSubscription: $(azureSub)
inline: 'New-AzResourceGroupDeployment -ResourceGroupName $(azureBroadsideResourceGroup) -TemplateFile .\build\arm-template_broadside-resources.json'
errorActionPreference: 'stop'
failOnStandardError: true
azurePowerShellVersion: 'latestVersion'
#scriptType: 'inlineScript' # Optional. Options: filePath, inlineScript
#scriptArguments: # Optional
#scriptPath: # Optional
#preferredAzurePowerShellVersion: # Required when azurePowerShellVersion == OtherVersion

任务的完整输出如下所示。

##[section]Starting: AzurePowerShell
==============================================================================
Task : Azure PowerShell
Description : Run a PowerShell script within an Azure environment
Version : 4.154.5
Author : Microsoft Corporation
Help : [Learn more about this task](https://go.microsoft.com/fwlink/?LinkID=613749)
==============================================================================
##[command]Import-Module -Name C:\Modules\az_2.3.2\Az.Accounts\1.6.0\Az.Accounts.psd1 -Global
##[warning]Both Az and AzureRM modules were detected on this machine. Az and AzureRM modules cannot be imported in the same session or used in the same script or runbook. If you are running PowerShell in an environment you control you can use the 'Uninstall-AzureRm' cmdlet to remove all AzureRm modules from your machine. If you are running in Azure Automation, take care that none of your runbooks import both Az and AzureRM modules. More information can be found here: https://aka.ms/azps-migration-guide
##[command]Clear-AzContext -Scope Process
##[command]Clear-AzContext -Scope CurrentUser -Force -ErrorAction SilentlyContinue
##[command]Connect-AzAccount -ServicePrincipal -Tenant *** -Credential System.Management.Automation.PSCredential -Environment AzureCloud
##[command] Set-AzContext -SubscriptionId 33b17345-7dc8-4a49-81ae-4f29230e33b0 -TenantId ***
##[command]& 'd:\a\1\s'
##[command]Disconnect-AzAccount -Scope Process -ErrorAction Stop
##[command]Clear-AzContext -Scope Process -ErrorAction Stop
##[error]The term 'd:\a\1\s' 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.
##[section]Finishing: AzurePowerShell

有趣的是它正在运行 & 'd:\a\1\s' 因为在我看来这与 YAML 中的任何内容都不对应。有点臭。

最佳答案

设置脚本类型:inlineScript

当未设置 scriptType 时,它可能默认为 filePath 并且未设置,因此它可能正在创建一个连接现有良好路径的运行路径,并且null 导致尝试运行文件夹名称。

关于azure-pipelines - Azure Pipelines AzurePowerShell@4 任务尝试运行一个奇怪的命令并失败,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/57560639/

31 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com