azure-pipelinesazure-pipelines-yamlazure-pipelines-release-task

How to set PATH for all steps in Azure Pipeline Yaml?


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

Solution

  • 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