Uploaded image for project: 'Bamboo Data Center'
  1. Bamboo Data Center
  2. BAM-21590

Support Windows PowerShell on Linux

    XMLWordPrintable

Details

    • Suggestion
    • Resolution: Unresolved
    • None
    • Tasks
    • None
    • 1
    • Our product teams collect and evaluate feedback from a number of different sources. To learn more about how we use customer feedback in the planning process, check out our new feature policy.

    Description

      Problem Definition

      At the moment the Bamboo Script task does not support running Windows Powershell commands on Linux.

      If you follow the Install PowerShell on Linux guide and attempt to add a Script task to Bamboo with the Interpreter set to Windows PowerShell to run on a Linux agent the task will fail because Bamboo adds /bin/sh to the command.

      Here's an example from a build that failed to run a Get-Help inline script with the Windows PowerShell interpreter on a Linux agent:

      atlassian-bamboo-agent.log
      simple	02-Feb-2022 14:31:38	Failing task since return code of [powershell -NonInteractive -ExecutionPolicy bypass -Command /bin/sh /var/atlassian/application-data/bamboo/temp/PROJ-PS-JOB1-4-ScriptBuildTask-2968191361645146443.ps1] was 1 while expected 0
      

      Since Bamboo doesn't support pwsh yet (BAM-20854) you might have to create a symbolic link from pwsh pointing to powershell to workaround this limitation:

      ln -s /usr/bin/pwsh /usr/bin/powershell
      

      Suggested Solution

      A couple of ideas:

      • Add a new interpreter to the Script task to account for the Linux version of Windows PowerShell.
      • Skip appending of the /bin/sh command when the interpreter is set to Windows PowerShell regardless of the environment detected by Bamboo/ agent.

      Workaround

      Use the Shell interpreter rather than Windows PowerShell and add the following shebang line to your script (whether inline or from a file):

      #!/usr/bin/env powershell
      
      #!/usr/bin/env pwsh
      

      Attachments

        Issue Links

          Activity

            People

              Unassigned Unassigned
              brosa Bruno Rosa
              Votes:
              8 Vote for this issue
              Watchers:
              5 Start watching this issue

              Dates

                Created:
                Updated: