Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Add error checking to bash scripts
Fail early if the external commands encounter an error
  • Loading branch information
Nirmal4G committed Mar 28, 2021
commit 9b767ddc4c55ab143193543459ded96e526bdf39
20 changes: 18 additions & 2 deletions build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,22 @@ echo "Installing dotnet CLI"
mkdir -p cli
curl -o cli/dotnet-install.sh -L https://dot.net/v1/dotnet-install.sh

if (( $? )); then
echo "Could not download 'dotnet-install.sh' script. Please check your network and try again!"
exit 1
fi

# Run install.sh for cli
chmod +x cli/dotnet-install.sh

# v1 needed for some test and bootstrapping testing version
cli/dotnet-install.sh -i cli -c 1.0

if (( $? )); then
echo "The .NET CLI Install failed!!"
exit 1
fi

DOTNET="$(pwd)/cli/dotnet"

echo "$DOTNET msbuild build/config.props /v:m /nologo /t:GetCliBranchForTesting"
Expand All @@ -32,8 +42,13 @@ DOTNET_BRANCH="$($DOTNET msbuild build/config.props /v:m /nologo /t:GetCliBranch
echo $DOTNET_BRANCH
cli/dotnet-install.sh -i cli -c $DOTNET_BRANCH

# Display current version
$DOTNET --version
if (( $? )); then
echo "The .NET CLI Install failed!!"
exit 1
fi

# Display .NET CLI info
$DOTNET --info

echo "================="

Expand All @@ -54,6 +69,7 @@ fi
# restore packages
echo "$DOTNET msbuild build/build.proj /t:Restore /p:VisualStudioVersion=16.0 /p:Configuration=Release /p:BuildNumber=1 /p:ReleaseLabel=beta"
$DOTNET msbuild build/build.proj /t:Restore /p:VisualStudioVersion=16.0 /p:Configuration=Release /p:BuildNumber=1 /p:ReleaseLabel=beta

if [ $? -ne 0 ]; then
echo "Restore failed!!"
exit 1
Expand Down
20 changes: 16 additions & 4 deletions scripts/funcTests/runFuncTests.sh
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@ pushd $DIR/

mono --version

dotnet --info

# Download the CLI install script to cli
echo "Installing dotnet CLI"
mkdir -p cli
Expand All @@ -36,7 +38,12 @@ chmod +x scripts/funcTests/dotnet-install.sh

# Get recommended version for bootstrapping testing version
# Issue 8936 - DISABLED TEMPORARILY cli/dotnet-install.sh -i cli -c 2.2
scripts/funcTests/dotnet-install.sh -i cli -c 2.2 -NoPath
scripts/funcTests/dotnet-install.sh -i cli -c 2.2 -nopath

if (( $? )); then
echo "The .NET CLI Install failed!!"
exit 1
fi

DOTNET="$(pwd)/cli/dotnet"

Expand All @@ -60,11 +67,15 @@ do
echo "Version is: $Version"
scripts/funcTests/dotnet-install.sh -i cli -c $Channel -v $Version -nopath

# Display current version
$DOTNET --version
dotnet --info
if (( $? )); then
echo "The .NET CLI Install for $DOTNET_BRANCH failed!!"
exit 1
fi
done

# Display .NET CLI info
$DOTNET --info

echo "initial dotnet cli install finished at `date -u +"%Y-%m-%dT%H:%M:%S"`"

echo "================="
Expand Down Expand Up @@ -104,6 +115,7 @@ fi
# restore packages
echo "dotnet msbuild build/build.proj /t:Restore /p:VisualStudioVersion=16.0 /p:Configuration=Release /p:BuildNumber=1 /p:ReleaseLabel=beta"
dotnet msbuild build/build.proj /t:Restore /p:VisualStudioVersion=16.0 /p:Configuration=Release /p:BuildNumber=1 /p:ReleaseLabel=beta

if [ $? -ne 0 ]; then
echo "Restore failed!!"
exit 1
Expand Down