3
votes

I have an existing Yaml pipeline which I am trying to understand and fix certain things. Since I am new to this, there are few things I am unable to understand in this existing pipeline. I would like to know what below task is doing. I don't see any inline PowerShell script here, then why it is created as PowerShell. The task is to add POMLXX dll in ABC_x64-$(osSuffix)\bin folder, but how the below script is even doing it

- powershell: |
            Set-Variable -Name PATH -Value "$env:PATH;$(IppRoot)\redist\intel64_win\ipp;$(Build.SourcesDirectory)\ABC_x64-$(osSuffix)\bin;$(Build.BinariesDirectory);$(PuLib)/imports/Pulib67/dll/amd64;$(POMLXX)/runtimes/win-x64/native"
            Write-Host "##vso[task.setvariable variable=PATH]$PATH"
          displayName:  'Add AbcRoot, IPP binaries, Pulib67 and POMLXX to PATH on Win'
          condition:    eq(variables['Agent.OS'], 'Windows_NT')

- bash: |
            export LD_LIBRARY_PATH="$(IppRoot)/redist/intel64_win/ipp:$(Build.SourcesDirectory)/MyProject_x64-$(osSuffix)/lib"
            echo "##vso[task.setvariable variable=LD_LIBRARY_PATH]$LD_LIBRARY_PATH"
            echo "##vso[task.setvariable variable=DYLD_LIBRARY_PATH]$LD_LIBRARY_PATH"
          displayName:  'Add OrzRoot, IPP binaries and LibFT4222 to (DY)LD_LIBRARY_PATH on Linux and Mac'
          condition:    in(variables['Agent.OS'], 'Darwin', 'Linux')
2
"I don't see any inline PowerShell script here" - Set-Variable and Write-Host are both PowerShell cmdlets, looks like a PowerShell script to me - Mathias R. Jessen

2 Answers

2
votes

This piece is the powershell:

Set-Variable -Name PATH -Value "$env:PATH;$(IppRoot)\redist\intel64_win\ipp;$(Build.SourcesDirectory)\ABC_x64-$(osSuffix)\bin;$(Build.BinariesDirectory);$(PuLib)/imports/Pulib67/dll/amd64;$(POMLXX)/runtimes/win-x64/native"
Write-Host "##vso[task.setvariable variable=PATH]$PATH"

It adds a bunch of paths to the PATH powershell variable (set-variable -Name PATH) including the path environment variable that came down from the agent, and then exports that back to the agent (Write-Host with a special command string) by re-setting the Azure Pipelines PATH variable. That variable will be set in the context of subsequent tasks so that they can find the tools.

It is a bit of a hack to preserve changes to the environment to a new task in the same job context.

See also:

The | after powershell: instructs the YAML parser to interpret the next indented block as a multi-line string.

See also:

A better solution

There is a better solution, it looks pretty similar:

powershell: |
  write-host "##vso[task.prependpath]$(IppRoot)\redist\intel64_win\ipp"
  write-host "##vso[task.prependpath]$(Build.SourcesDirectory)\ABC_x64-$(osSuffix)\bin"
  ... etc

This command is specifically created to add paths to the PATH environment and will work even if other Tool Installer tasks run after your script section.

See also:

1
votes

To the first part of your question ("I don't see any inline PowerShell script"), the syntax

- powershell: |

is shorthand for an inline script. To the second part of the question, it appears that the task tries to first add the directory to the PATH environment variable within the task, then "export" (via task.setvariable) the value as a release variable to other tasks/jobs/stages.

More than that I can't say without additional clarification of your question, and/or output from the job run.