Fix jenkinsfile
Some checks failed
Flare Microsystems Git/FlarePublic/gitea-themes/pipeline/pr-master There was a failure building this commit

This commit is contained in:
Vulpovile
2025-01-11 15:20:44 -08:00
parent b225f3d1e2
commit cdc63f6fcd

41
Jenkinsfile vendored
View File

@@ -7,25 +7,38 @@ pipeline {
script { script {
// Check for spaces or mixed indentation // Check for spaces or mixed indentation
sh ''' sh '''
FILE_EXTENSIONS="css json js java py ps1 cs cmd bat htm html cpp c h hpp" FILETYPES="css|json|js|java|py|ps1|cs|cmd|bat|htm|html|cpp|c|h|hpp"
# Convert FILE_EXTENSIONS to --include pattern # Convert FILE_EXTENSIONS to --include pattern
INCLUDE_PATTERNS=$(echo $FILE_EXTENSIONS | sed 's/ /,*./g; s/^/*./')
FILES=$(find . -regextype awk -regex '.*($FILETYPES)' -type f)
echo "Checking for lines starting with spaces in $FILE_EXTENSIONS files..." # Initialize the PROBLEMS variable
grep -nrP '^[ ]+' --include="$INCLUDE_PATTERNS" . | sed 's/\\([^:]*\\):\\([^:]*\\):\\([ ]*\\).*/File: \\1, Line: \\2, Found: \\3/' || echo "No lines with spaces found." PROBLEMS=""
echo "Checking for lines with mixed tabs and spaces in $FILE_EXTENSIONS files..." echo "$FILES" | while IFS= read -r file; do
grep -nrP '^\t+ +' --include="$INCLUDE_PATTERNS" . | sed 's/\\([^:]*\\):\\([^:]*\\):\\(\\t* +\\).*/File: \\1, Line: \\2, Found: \\3/' || echo "No lines with mixed indentation found." # Check for lines with spaces
GREP_RESULT=$(grep -nrP '^[ ]+' "$file" | sed 's/\([^:]*\):\([^:]*\):\([ ]*\).*/File: \1, Line: \2, Found: \3/')
if [ -n "$GREP_RESULT" ]; then
PROBLEMS="$PROBLEMS$GREP_RESULT"$'\n' # Append the result to PROBLEMS
fi
if grep -nrP '^[ ]+' --include="$INCLUDE_PATTERNS" . || \ # Check for lines with mixed tabs and spaces
grep -nrP '^\t+ +' --include="$INCLUDE_PATTERNS" .; then GREP_RESULT=$(grep -nrP '^\t+ +' "$file" | sed 's/\([^:]*\):\([^:]*\):\([ ]*\).*/File: \1, Line: \2, Found: \3/')
echo "Indentation issues detected. Please fix the above lines." if [ -n "$GREP_RESULT" ]; then
exit 1 PROBLEMS="$PROBLEMS$GREP_RESULT"$'\n' # Append the result to PROBLEMS
else fi
echo "No indentation issues detected." done
exit 0
fi # Check if there were any problems
if [ -n "$PROBLEMS" ]; then
echo "Indentation issues detected. Please fix the above lines."
echo "$PROBLEMS"
exit 1
else
echo "No indentation issues detected."
exit 0
fi
''' '''
} }
} }