首页 > 解决方案 > 在 Azure DevOps Pipeline 中运行 Azure CLI 脚本,但找不到 CLI 脚本

问题描述

param (

    $ProjectFilePath= $(Buildin.SourcesDirectory)\TESTREPO7\RuleConfig.json
    
    $ExecutableFilePath= $(Buildin.SourcesDirectory)\TESTREPO7\Studio.zip\Studio\UiPath.Studio.CommandLine.exe
    
    $OutputFilePath= $(Buildin.SourcesDirectory)\$(Get-Date -Format 'yyyy-MM-dd-HH-mm-ss')-Workflow-Analysis.json
    
    )

Write-Output "$(Get-Date -Format 'HH:mm:ss') - STARTED - Workflow Analyzer CLI Script"

$Command = "$ExecutableFilePath analyze -p $ProjectFilePath"
Invoke-Expression $Command | Out-File -FilePath $OutputFilePath

Write-Output "$(Get-Date -Format 'HH:mm:ss') - COMPLETED - Workflow Analyzer CLI Script"

XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

错误:

##[section]Starting: Azure CLI UiPathWorkFlow 
==============================================================================
Task         : Azure CLI
Description  : Run Azure CLI commands against an Azure subscription in a Shell script when running on Linux agent or Batch script when running on Windows agent.
Version      : 1.152.1
Author       : Microsoft Corporation
Help         : https://docs.microsoft.com/azure/devops/pipelines/tasks/deploy/azure-cli
==============================================================================
##[error]Script failed with error: Error: Unable to locate executable file: 'C:\agent1\_work\362\s\TESTREPO7\UiPathAnalyze.ps1'. Please verify either the file path exists or the file can be found within a directory specified by the PATH environment variable. Also verify the file has a valid extension for an executable file.
##[section]Finishing: Azure CLI UiPathWorkFlow 

XXXXXXXXXXXXXXXXXXXXX

非常重要 - 在本地计算机上时,uiath.studio.commandline.exe(工作流分析器)的规则存储在用户目录中(%LocalAppData%\UiPath\Rules = C:\Users\User1\AppData\Local\UiPath\Rules) . 我如何能够在上面提供的脚本中输入这些信息?

Azure CLI 最新版本安装在 azure DevOps 代理服务器上。

尝试添加环境参数,但不确定输入什么,但无论如何都会发生此错误。添加的环境没有修复错误。

添加了以下两种环境—</p>

路径 $(Buildin.SourcesDirectory)\TESTREPO7\UipathAnalyze.ps1

Build.SourcesDirectory $(Buildin.SourcesDirectory)\TESTREPO7\UipathAnalyze.ps1

标签: azure-devopscommand-line-interface

解决方案


检查此文档预定义变量,路径应$(Build.SourcesDirectory)$(Buildin.SourcesDirectory)

错误信息是:Unable to locate executable file: 'C:\agent1\_work\362\s\TESTREPO7\UiPathAnalyze.ps1'

UipathAnalyze.ps1 是您共享的代码,它是任务 Azure CLI 中的脚本路径,对吧?我们需要打开文件夹路径C:\agent1\_work\362\s\TESTREPO7来检查文件是否存在。

另外,你能在本地代理机器上成功运行 .ps1 文件吗?


推荐阅读