Jenkinsfile 업데이트
This commit is contained in:
Vendored
-78
@@ -1,10 +1,6 @@
|
||||
pipeline {
|
||||
agent { label 'djb-vm' }
|
||||
|
||||
triggers {
|
||||
cron('H/10 * * * *')
|
||||
}
|
||||
|
||||
options {
|
||||
timestamps()
|
||||
disableConcurrentBuilds()
|
||||
@@ -23,8 +19,6 @@ pipeline {
|
||||
CATALINA_HOME = '/prod/eapim/apache-tomcat-9.0.116'
|
||||
CATALINA_PID = '/prod/eapim/apigw/logs/catalina.pid'
|
||||
DEPLOY_HTTP_PORT = '39110'
|
||||
REVISION_STATE_FILE = '.jenkins-last-deploy-revisions'
|
||||
SHOULD_DEPLOY = 'true'
|
||||
}
|
||||
|
||||
stages {
|
||||
@@ -55,53 +49,7 @@ pipeline {
|
||||
}
|
||||
}
|
||||
|
||||
stage('Detect changes') {
|
||||
steps {
|
||||
script {
|
||||
int status = sh(
|
||||
returnStatus: true,
|
||||
script: '''
|
||||
set -eu
|
||||
current_file="$(mktemp)"
|
||||
{
|
||||
printf 'eapim-online %s\\n' "$(git rev-parse HEAD)"
|
||||
for REPO in elink-online-core elink-online-transformer elink-online-common elink-online-emsclient elink-online-core-jpa; do
|
||||
printf '%s %s\\n' "$REPO" "$(git -C "$REPO" rev-parse HEAD)"
|
||||
done
|
||||
} | sort > "$current_file"
|
||||
|
||||
if [ -f "$REVISION_STATE_FILE" ] && cmp -s "$current_file" "$REVISION_STATE_FILE"; then
|
||||
echo "No repository changes detected. Skipping build and deploy."
|
||||
echo "--- current revisions ---"
|
||||
cat "$current_file"
|
||||
rm -f "$current_file"
|
||||
exit 10
|
||||
fi
|
||||
|
||||
echo "Repository changes detected. Build and deploy will run."
|
||||
echo "--- previous revisions ---"
|
||||
[ -f "$REVISION_STATE_FILE" ] && cat "$REVISION_STATE_FILE" || echo "(none)"
|
||||
echo "--- current revisions ---"
|
||||
cat "$current_file"
|
||||
mv "$current_file" .jenkins-current-deploy-revisions
|
||||
'''
|
||||
)
|
||||
if (status == 10) {
|
||||
env.SHOULD_DEPLOY = 'false'
|
||||
currentBuild.description = 'No repo changes'
|
||||
} else if (status != 0) {
|
||||
error "Revision change detection failed with status ${status}"
|
||||
} else {
|
||||
env.SHOULD_DEPLOY = 'true'
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
stage('Verify toolchain') {
|
||||
when {
|
||||
expression { env.SHOULD_DEPLOY == 'true' }
|
||||
}
|
||||
steps {
|
||||
sh '''
|
||||
set -eu
|
||||
@@ -112,9 +60,6 @@ pipeline {
|
||||
}
|
||||
|
||||
stage('Build WAR') {
|
||||
when {
|
||||
expression { env.SHOULD_DEPLOY == 'true' }
|
||||
}
|
||||
steps {
|
||||
sh 'gradle clean build -x test --no-daemon'
|
||||
}
|
||||
@@ -132,9 +77,6 @@ pipeline {
|
||||
}
|
||||
|
||||
stage('Stop Tomcat') {
|
||||
when {
|
||||
expression { env.SHOULD_DEPLOY == 'true' }
|
||||
}
|
||||
steps {
|
||||
sh '''
|
||||
set +e
|
||||
@@ -153,9 +95,6 @@ pipeline {
|
||||
}
|
||||
|
||||
stage('Deploy ROOT.war') {
|
||||
when {
|
||||
expression { env.SHOULD_DEPLOY == 'true' }
|
||||
}
|
||||
steps {
|
||||
sh '''
|
||||
set -eu
|
||||
@@ -168,9 +107,6 @@ pipeline {
|
||||
}
|
||||
|
||||
stage('Start Tomcat and readiness') {
|
||||
when {
|
||||
expression { env.SHOULD_DEPLOY == 'true' }
|
||||
}
|
||||
steps {
|
||||
sh '''
|
||||
set -eu
|
||||
@@ -223,18 +159,4 @@ pipeline {
|
||||
}
|
||||
}
|
||||
|
||||
post {
|
||||
success {
|
||||
script {
|
||||
if (env.SHOULD_DEPLOY == 'true') {
|
||||
sh '''
|
||||
set -eu
|
||||
if [ -f .jenkins-current-deploy-revisions ]; then
|
||||
mv .jenkins-current-deploy-revisions "$REVISION_STATE_FILE"
|
||||
fi
|
||||
'''
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user