Cygwin Scripts fail with an error on Bamboo Data Center Windows Agents

Platform Notice: Data Center Only - This article only applies to Atlassian apps on the Data Center platform.

Note that this KB was created for the Data Center version of the product. Data Center KBs for non-Data-Center-specific features may also work for Server versions of the product, however they have not been tested. 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.

*Except Fisheye and Crucible

Summary

Bamboo supports running script tasks using the Shell interpreter in build and deployments, relying on the script’s shebang line to determine how it is executed. On Windows agents, Shell script tasks that use Cygwin in the shebang can fail because Bamboo automatically generates scripts with Windows-style line endings (CRLF), while Cygwin expects Unix-style line endings (LF). This knowledge base article provides guidance on how to successfully run Cygwin-based shell scripts on Bamboo Windows agents despite the line-ending mismatch.

The solution has been validated in Bamboo 12.1.2 but may be applicable to other versions.

Diagnosis

The Bamboo build logs show the error: '$‘\r’: command not found'. Here is the exact error output from the logs for a sample script.

C:\.....TP-TP-JOB1-60-ScriptBuildTask-15713061732518354093.bat: line 3: $'date\r': command not found C:\....\TP-TP-JOB1-60-ScriptBuildTask-15713061732518354093.bat: line 4: $'pwd\r': command not found

Sample script

#!C:/cygwin64/bin/bash.exe PATH=$PATH:/bin:/usr/bin date pwd ls -lrt .

Cause

When a script task is configured in Bamboo, it generates a temporary executable file in the agent’s temp directory based on the script configuration. During this process, Bamboo automatically applies line endings according to the agent’s operating system. On Windows agents, the generated script uses Windows-style line endings (CRLF), but Cygwin expects Unix-style line endings (LF), which causes the mismatch.

Solution

As part of the Script task configuration, add the following environment variable in the Environment variables field of the Script task configuration, not as an inline environment variable.

SHELLOPTS="$SHELLOPTS:igncr"

There is an open feature request BAM-26350: Add Cygwin support for Script tasks on Windows agents in Bamboo to support execution of Cygwin-based scripts on Bamboo Windows agents.

Updated on April 8, 2026

Still need help?

The Atlassian Community is here for you.