PowerShell commands fail on Linux Agents with "The application to execute does not exist"
プラットフォームについて: Server および Data Center のみ。この記事は、Server および Data Center プラットフォームのアトラシアン製品にのみ適用されます。
Support for Server* products ended on February 15th 2024. If you are running a Server product, you can visit the Atlassian Server end of support announcement to review your migration options.
*Fisheye および Crucible は除く
要約
A Script Task calls PowerShell but fails to execute with a "The application to execute does not exist" error.
環境
- Remote agent running on a Linux machine.
- Script Task running PowerShell commands.
診断
The build throws the following error:
21-Nov-2022 15:11:03 The application to execute does not exist: '/var/atlassian/application-data/bamboo/temp/pwsh.dll'.
原因
The Script Task does not support running Windows Powershell commands on Linux. In addition to that, the most recent versions of Powershell use pwsh as executables, while the older ones used powerhsell. This is related to the following feature requests:
BAM-21590 - Getting issue details... STATUS BAM-20854 - Getting issue details... STATUS
ソリューション
We can force the Script Task to use PowerShell through the steps below:
- On your Script Task, make sure the Interpreter is set as Shell.
Replace the shebang from your inline/file script with the following:
#!/usr/bin/env pwsh
以上です!