I’m using Circle’s aws-s3 orb together with a windows build and it fails on the AWS Install step with this error:
#!powershell.exe -ExecutionPolicy Bypass
AWS_VER_REGEXP_2='aws-cli\/2.\d*.\d*'
AWS_VER_REGEXP_1='aws-cli\/1.\d*.\d*'
# initialize installed version to zero, to signify not installed (Or we want to ignore the installed version and re-install).
AWS_CLI_INSTALLED_VERSION="0"
AWS_CLI_VERSION_SELECTED="2"
if [[ $EUID == 0 ]]; then export SUDO=""; else export SUDO="sudo"; fi
if [ "false" == "false" ]; then
if ! command -v aws --version >/dev/null 2>&1 ; then
echo AWS is not installed
else
echo AWS is currently installed.
if aws --version 2>&1 | grep -q $AWS_VER_REGEXP_2; then
echo AWS CLI v2 is installed
AWS_CLI_INSTALLED_VERSION="2"
fi
if aws --version 2>&1 | grep -q $AWS_VER_REGEXP_1; then
echo AWS CLI v1 is installed
AWS_CLI_INSTALLED_VERSION="1"
fi
fi
else
echo "Skipping version check. Installing CLI"
fi
AWS_V2_UPDATE_PARAM=""
if aws --version 2>&1 | grep -q $AWS_VER_REGEXP_2; then
AWS_V2_UPDATE_PARAM="--update"
fi
#If the desired version of the CLI is not installed, install it.
if [[ $AWS_CLI_VERSION_SELECTED != $AWS_CLI_INSTALLED_VERSION ]]; then
#uninstall AWS CLI if it is installed.
if which aws; then
echo Uninstalling old CLI
$SUDO rm -rf $(which aws)
fi
case $AWS_CLI_VERSION_SELECTED in
"1")
if ! command -v python >/dev/null 2>&1 && ! command -v python3 >/dev/null 2>&1 ; then
echo "Your environment does not seem to have Python installed, a requirement of the AWS CLI."
echo "Please either utilize the AWS CLI v2, or select an envionment with Python installed."
echo "Recommended image: cimg:/python:3.8"
exit 1
fi
# install CLI v1
export PIP=$(which pip pip3 | head -1)
if [[ -n $PIP ]]; then
if which sudo > /dev/null; then
sudo $PIP install awscli --upgrade
else
# This installs the AWS CLI to ~/.local/bin. Make sure that ~/.local/bin is in your $PATH.
$PIP install awscli --upgrade --user
fi
elif [[ $(which unzip curl | wc -l) -eq 2 ]]; then
cd
curl "https://s3.amazonaws.com/aws-cli/awscli-bundle.zip" -o "awscli-bundle.zip"
unzip awscli-bundle.zip
if which sudo > /dev/null; then
sudo ~/awscli-bundle/install -i /usr/local/aws -b /usr/local/bin/aws
else
# This installs the AWS CLI to the default location (~/.local/lib/aws) and create a symbolic link (symlink) at ~/bin/aws. Make sure that ~/bin is in your $PATH.
awscli-bundle/install -b ~/bin/aws
fi
rm -rf awscli-bundle*
cd -
else
echo "Unable to install AWS CLI. Please install pip."
exit 1
fi
# Installation check
if aws --version &> grep -q "aws-cli/1"; then
echo "AWS CLI V1 has been installed successfully"
exit 0
else
echo "There was an issue installing the AWS CLI V1. Exiting."
exit 1
fi
;;
"2")
# install CLI v2
cd /tmp || exit
# PLATFORM CHECK: mac vs. alpine vs. other linux
if uname -a | grep Darwin; then
SYS_ENV_PLATFORM=darwin
elif uname -a | grep Linux; then
SYS_ENV_PLATFORM=linux
else
echo "This platform appears to be unsupported."
uname -a
exit 1
fi
case $SYS_ENV_PLATFORM in
linux)
curl -sSL "https://awscli.amazonaws.com/awscli-exe-linux-x86_64.zip" -o "awscliv2.zip"
unzip awscliv2.zip
$SUDO ./aws/install $AWS_V2_UPDATE_PARAM
rm awscliv2.zip
;;
darwin)
curl -sSL "https://awscli.amazonaws.com/AWSCLIV2.pkg" -o "AWSCLIV2.pkg"
$SUDO installer -pkg AWSCLIV2.pkg -target /
rm AWSCLIV2.pkg
;;
*)
echo "This orb does not currently support your platform. If you believe it should, please consider opening an issue on the GitHub repository:"
echo "https://github.com/CircleCI-Public/aws-cli-orb/issues/new"
exit 1
;;
esac
# Installation check
if aws --version &> grep -q "aws-cli/2"; then
echo "AWS CLI V2 has been installed successfully"
exit 0
else
echo "There was an issue installing the AWS CLI V2. Exiting."
exit 1
fi
;;
esac
else
echo "The v${AWS_CLI_VERSION_SELECTED} AWS CLI is already installed."
exit 0
fi
At line:7 char:3
+ if [[ $EUID == 0 ]]; then export SUDO=""; else export SUDO="sudo"; fi
+ ~
Missing '(' after 'if' in if statement.
At line:7 char:5
+ if [[ $EUID == 0 ]]; then export SUDO=""; else export SUDO="sudo"; fi
+ ~
Missing type name after '['.
At line:9 char:3
+ if [ "false" == "false" ]; then
+ ~
Missing '(' after 'if' in if statement.
At line:9 char:5
+ if [ "false" == "false" ]; then
+ ~
Missing type name after '['.
At line:10 char:7
+ if ! command -v aws --version >/dev/null 2>&1 ; then
+ ~
Missing '(' after 'if' in if statement.
At line:10 char:9
+ if ! command -v aws --version >/dev/null 2>&1 ; then
+ ~
Missing expression after unary operator '!'.
At line:10 char:10
+ if ! command -v aws --version >/dev/null 2>&1 ; then
+ ~~~~~~~
Unexpected token 'command' in expression or statement.
At line:14 char:11
+ if aws --version 2>&1 | grep -q $AWS_VER_REGEXP_2; then
+ ~
Missing '(' after 'if' in if statement.
At line:18 char:11
+ if aws --version 2>&1 | grep -q $AWS_VER_REGEXP_1; then
+ ~
Missing '(' after 'if' in if statement.
At line:28 char:3
+ if aws --version 2>&1 | grep -q $AWS_VER_REGEXP_2; then
+ ~
Missing '(' after 'if' in if statement.
Not all parse errors were reported. Correct the reported errors and try again.
+ CategoryInfo : ParserError: (:) [], ParentContainsErrorRecordException
+ FullyQualifiedErrorId : MissingOpenParenthesisInIfStatement
Exited with code exit status 1
So basically powershell is not happy with the orb’s syntax. Anyone has encountered that? any workaround or fix? Thanks in advance!