-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathfix-syntax.sh
More file actions
executable file
·37 lines (30 loc) · 1 KB
/
fix-syntax.sh
File metadata and controls
executable file
·37 lines (30 loc) · 1 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
#!/bin/bash
cd ~/Documents/devops/Task\ Manager
echo "🔧 Fixing Jenkinsfile syntax..."
# Backup
cp Jenkinsfile Jenkinsfile.bak.$(date +%s)
# Check for common issues
echo "1. Checking for unclosed quotes..."
if grep -q '"""$' Jenkinsfile; then
echo "❌ Found unclosed triple quotes"
sed -i 's/"""$/"""/' Jenkinsfile
fi
echo "2. Adding missing closing brace if needed..."
LAST_CHAR=$(tail -c 1 Jenkinsfile | od -An -t x1 | tr -d ' \n')
if [ "$LAST_CHAR" != "7d" ]; then # 7d = } in hex
echo "❌ Missing closing brace at end, adding..."
echo "}" >> Jenkinsfile
fi
echo "3. Checking stage closures..."
# Count stages
STAGES=$(grep -c "^[[:space:]]*stage" Jenkinsfile)
echo "Found $STAGES stages"
echo "4. Validating syntax..."
if python3 -c "with open('Jenkinsfile', 'r') as f: content = f.read(); print('Lines:', len(content.split(chr(10))))" 2>/dev/null; then
echo "✅ Basic file structure OK"
else
echo "❌ File reading error"
fi
echo ""
echo "📝 Fixed file tail:"
tail -5 Jenkinsfile