Compare commits
24 Commits
jenkins-pi
...
jenkins-fl
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
33fc7f66f9 | ||
|
|
1426c8aff2 | ||
|
|
7a26738ec7 | ||
|
|
9168be6c3d | ||
|
|
a8ab29d019 | ||
|
|
40aba0972c | ||
|
|
7735b0e283 | ||
|
|
253b6c54a0 | ||
|
|
1cc42b18b7 | ||
|
|
54699d67f9 | ||
|
|
8c0a55838e | ||
|
|
e4d390a096 | ||
|
|
0543580669 | ||
|
|
453914a73b | ||
|
|
640dae99f9 | ||
|
|
5e4f750a42 | ||
|
|
496c353ca1 | ||
|
|
d060b629cf | ||
|
|
858eacdc3f | ||
|
|
f5398c1a9c | ||
|
|
d855e795e2 | ||
|
|
2f0ab04997 | ||
|
|
c37d92a4cf | ||
|
|
d8617d01eb |
43
.jenkins/Jenkinsfile
vendored
43
.jenkins/Jenkinsfile
vendored
@@ -59,32 +59,31 @@ pipeline {
|
|||||||
git config --global user.email "jenkins@marcin00.pl"
|
git config --global user.email "jenkins@marcin00.pl"
|
||||||
'''
|
'''
|
||||||
sshagent(['gitea-deploy-key']) {
|
sshagent(['gitea-deploy-key']) {
|
||||||
sh 'git clone ${DEPLOY_REPO} --branch jenkins-kubernetes'
|
sh 'git clone ${DEPLOY_REPO} --branch fluxcd'
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
sh '''
|
||||||
dir('user-microservice-deploy') {
|
cd user-microservice-deploy/apps/user-microservice
|
||||||
sh '''
|
# Podmień tag obrazu w pliku deploy.yaml
|
||||||
# Podmień tag obrazu w pliku deploy.yaml
|
awk -v commit="$GIT_COMMIT" '
|
||||||
awk -v commit="$GIT_COMMIT" '
|
$0 ~ /name:[[:space:]]*api/ { in_api_container = 1; print; next }
|
||||||
$0 ~ /name:[[:space:]]*api/ { in_api_container = 1; print; next }
|
in_api_container && $0 ~ /^[[:space:]]*image:[[:space:]]*/ {
|
||||||
in_api_container && $0 ~ /^[[:space:]]*image:[[:space:]]*/ {
|
sub(/:[^:[:space:]]+$/, ":" commit)
|
||||||
sub(/:[^:[:space:]]+$/, ":" commit)
|
in_api_container = 0
|
||||||
in_api_container = 0
|
print
|
||||||
print
|
next
|
||||||
next
|
}
|
||||||
}
|
{ print }
|
||||||
{ print }
|
' deploy.yaml > deploy.tmp && mv deploy.tmp deploy.yaml
|
||||||
' deploy.yaml > deploy.tmp && mv deploy.tmp deploy.yaml
|
|
||||||
'''
|
'''
|
||||||
|
|
||||||
sshagent(['gitea-deploy-key']) {
|
sshagent(['gitea-deploy-key']) {
|
||||||
sh '''
|
sh '''
|
||||||
git add deploy.yaml
|
cd user-microservice-deploy/apps/user-microservice
|
||||||
git diff-index --quiet HEAD || git commit -m "JENKINS: Changed deployed version to $GIT_COMMIT"
|
git add deploy.yaml
|
||||||
git push origin jenkins-kubernetes
|
git diff-index --quiet HEAD || git commit -m "JENKINS: Changed deployed version to $GIT_COMMIT"
|
||||||
'''
|
git push origin fluxcd
|
||||||
}
|
'''
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -36,19 +36,30 @@ fi
|
|||||||
echo "[INFO] Oczekiwanie na wdrożenie nowej wersji..."
|
echo "[INFO] Oczekiwanie na wdrożenie nowej wersji..."
|
||||||
|
|
||||||
# === Odpytywanie endpointa /version ===
|
# === Odpytywanie endpointa /version ===
|
||||||
|
WAITED=0
|
||||||
|
echo "[WAIT] Oczekiwanie na nową wersję..."
|
||||||
|
|
||||||
while true; do
|
while true; do
|
||||||
sleep $CHECK_INTERVAL
|
sleep $CHECK_INTERVAL
|
||||||
|
WAITED=$((WAITED + CHECK_INTERVAL))
|
||||||
|
|
||||||
NEW_VERSION=$(curl -s "$APP_URL" | jq -r '.version')
|
NEW_VERSION=$(curl -s "$APP_URL" | jq -r '.version')
|
||||||
|
|
||||||
if [[ "$NEW_VERSION" != "$OLD_VERSION" ]]; then
|
if [[ "$NEW_VERSION" != "$OLD_VERSION" ]]; then
|
||||||
END_TIME=$(date +%s)
|
END_TIME=$(date +%s)
|
||||||
DURATION=$((END_TIME - START_TIME))
|
DURATION=$((END_TIME - START_TIME))
|
||||||
echo "[INFO] Nowa wersja wdrożona: $NEW_VERSION"
|
|
||||||
|
# Nadpisujemy linię z licznikiem
|
||||||
|
printf "\r[INFO] Nowa wersja wdrożona po %ds: %s\n" "$WAITED" "$NEW_VERSION"
|
||||||
echo "[INFO] Czas wdrożenia: $DURATION sekund"
|
echo "[INFO] Czas wdrożenia: $DURATION sekund"
|
||||||
|
|
||||||
echo "$START_TIME,$END_TIME,$DURATION,$OLD_VERSION,$NEW_VERSION" >> "$OUTPUT_FILE"
|
echo "$START_TIME,$END_TIME,$DURATION,$OLD_VERSION,$NEW_VERSION" >> "$OUTPUT_FILE"
|
||||||
break
|
break
|
||||||
else
|
else
|
||||||
echo "[WAIT] Czekam... ($NEW_VERSION)"
|
# Nadpisujemy TYLKO linię z licznikiem
|
||||||
|
printf "\r[WAIT] Czekam... %ds" "$WAITED"
|
||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
|
|
||||||
|
# Żeby kursor przeszedł do nowej linii po zakończeniu
|
||||||
|
echo ""
|
||||||
|
|||||||
@@ -1 +1 @@
|
|||||||
1752168984
|
1752257920
|
||||||
|
|||||||
Reference in New Issue
Block a user