Update Jenkinsfile
This commit is contained in:
parent
7604562d80
commit
83a78ce336
1 changed files with 58 additions and 0 deletions
58
Jenkinsfile
vendored
58
Jenkinsfile
vendored
|
|
@ -1,5 +1,11 @@
|
||||||
pipeline {
|
pipeline {
|
||||||
agent any
|
agent any
|
||||||
|
|
||||||
|
environment {
|
||||||
|
APP_PORT = 6767
|
||||||
|
PID_FILE = "${WORKSPACE}/app.pid"
|
||||||
|
}
|
||||||
|
|
||||||
stages {
|
stages {
|
||||||
stage('Echo Version') {
|
stage('Echo Version') {
|
||||||
steps {
|
steps {
|
||||||
|
|
@ -24,7 +30,59 @@ pipeline {
|
||||||
junit(testResults: 'target/surefire-reports/TEST-*.xml', keepProperties: true, keepTestNames: true)
|
junit(testResults: 'target/surefire-reports/TEST-*.xml', keepProperties: true, keepTestNames: true)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
stage('Start App') {
|
||||||
|
steps {
|
||||||
|
sh '''
|
||||||
|
set -e
|
||||||
|
|
||||||
|
if [ -f "$PID_FILE" ]; then
|
||||||
|
kill "$(cat "$PID_FILE")" || true
|
||||||
|
rm -f "$PID_FILE"
|
||||||
|
fi
|
||||||
|
|
||||||
|
echo "Starting JAR..."
|
||||||
|
nohup java -jar target/hello-demo-*.jar \
|
||||||
|
> app.log 2>&1 &
|
||||||
|
|
||||||
|
echo $! > "$PID_FILE"
|
||||||
|
echo "App started (PID: $(cat "$PID_FILE"))"
|
||||||
|
'''
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
stage('Integration Test') {
|
||||||
|
steps {
|
||||||
|
sh '''
|
||||||
|
set -e
|
||||||
|
|
||||||
|
echo "Waiting for app..."
|
||||||
|
for i in {1..15}; do
|
||||||
|
if curl -fs http://localhost:$APP_PORT/hello >/dev/null; then
|
||||||
|
echo "Integration test passed"
|
||||||
|
curl -s http://localhost:$APP_PORT/hello
|
||||||
|
exit 0
|
||||||
|
fi
|
||||||
|
sleep 1
|
||||||
|
done
|
||||||
|
|
||||||
|
echo "Integration test failed"
|
||||||
|
cat app.log || true
|
||||||
|
exit 1
|
||||||
|
'''
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
post {
|
||||||
|
always {
|
||||||
|
sh '''
|
||||||
|
if [ -f "$PID_FILE" ]; then
|
||||||
|
echo "Stopping application"
|
||||||
|
kill "$(cat "$PID_FILE")" || true
|
||||||
|
rm -f "$PID_FILE"
|
||||||
|
fi
|
||||||
|
'''
|
||||||
|
}
|
||||||
}
|
}
|
||||||
tools {
|
tools {
|
||||||
maven 'M398'
|
maven 'M398'
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue