0

I want to define the PATH only once for the whole pipeline.

Is this possible?

I've done this, but it doesn't work:

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
Cosmin
  • 2,365
  • 2
  • 23
  • 29
lsaudon
  • 1,263
  • 11
  • 24

2 Answers2

1

I think this is basically a Linux issue.

See the Ubuntu official document:

https://help.ubuntu.com/community/EnvironmentVariables#System-wide_environment_variables

Process locality: The values of environment variables are local, which means they are specific to the running process in or for which they were set. This means that if we open two terminal windows (which means we have two separate bash processes running), and change a value of an environment variable in one of the windows, that change will not be seen by the shell in the other window or any other program currently on the desktop.

This is why the variable not been passed, it only lives in the first terminal.

Please check the system wide environment variables in the documents. I think you need to change something in the machine (edit some files or add some files).

Bowman Zhu-MSFT
  • 4,776
  • 1
  • 9
  • 10
1

The solution is to add the BASH_ENV: "~/.profile" variable and put path in ~/.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
lsaudon
  • 1,263
  • 11
  • 24