如何为Azure Pipeline Yaml中的所有步骤设置PATH



我只想为整个管道定义一次PATH

这可能吗?

我已经这样做了,但它不起作用:

trigger:
- master
jobs:
- job: Application
pool:
vmImage: ubuntu-latest
steps:
- task: CmdLine@2
displayName: "Install flutter"
inputs:
workingDirectory: $(Agent.ToolsDirectory)
script: |
git clone https://github.com/flutter/flutter.git -b stable --depth 1
export PATH="$PATH:`pwd`/flutter/bin"
echo "##vso[task.setvariable variable=path;isOutput=true]$PATH"
flutter config --no-analytics
yes | flutter doctor --android-licenses
- task: CmdLine@2
displayName: "flutter get"
inputs:
script: |
flutter pub get

我认为这基本上是一个Linux问题。

请参阅Ubuntu官方文档:

https://help.ubuntu.com/community/EnvironmentVariables#System-宽环境变量

进程局部性:环境变量的值是局部的意味着它们是特定于正在运行的进程的已设置。这意味着,如果我们打开两个终端窗口(这意味着我们有两个独立的bash进程在运行(,并更改某个窗口中的环境变量,该更改将不会由shell在其他窗口或当前任何其他程序中看到在桌面上。

这就是为什么变量没有被传递,它只存在于第一个终端中。

请检查文档中的系统范围环境变量。我认为你需要更改机器中的某些内容(编辑一些文件或添加一些文件(。

解决方案是添加BASH_ENV: "~/.profile"变量并将路径放入~/.profile中。

trigger:
- master
variables:
BASH_ENV: "~/.profile"
jobs:
- job: Application
pool:
vmImage: ubuntu-latest
steps:
- task: CmdLine@2
inputs:
workingDirectory: $(Agent.ToolsDirectory)
script: |
git clone https://github.com/flutter/flutter.git -b stable --depth 1
echo "export PATH=$PATH:`pwd`/flutter/bin" >> ~/.profile
source ~/.profile
- task: CmdLine@2
inputs:
script: |
flutter config --no-analytics

最新更新