Files
QuizSystem/.workflow/01_dotnet_build.sh
T

34 lines
765 B
Bash

#!/bin/bash
echo "OK" > jenkins.result
# Check dotnet10 installed
! which dotnet || sudo apt-get install -y dotnet10
if ! which dotnet; then
echo "DOTNET NOT FOUND"
exit 1
fi
# Find all .csproj files and loop through them
find . -type f -name "*.csproj" | while read -r csproj; do
echo "Building $csproj..."
# Run dotnet build on the csproj file
dotnet build "$csproj"
# If dotnet build fails (non-zero exit code), exit the script with an error code
if [ $? -ne 0 ]; then
echo "Build failed for $csproj. Exiting with error."
echo "ERROR" > jenkins.result
fi
done
RESULT=$(cat jenkins.result)
echo "RESULT=$RESULT"
if [ "$RESULT" == "OK" ]; then
echo "All builds succeeded."
exit 0
else
echo "Errors were recorded"
exit 1
fi