mirror of
https://git.v0id.ovh/n3wt-innov/n3wt-school.git
synced 2026-04-03 16:51:26 +00:00
chore: modification de la ci
This commit is contained in:
91
ci/build.Jenkinsfile
Normal file
91
ci/build.Jenkinsfile
Normal file
@ -0,0 +1,91 @@
|
||||
pipeline {
|
||||
|
||||
agent {
|
||||
label "SLAVE-N3WT"
|
||||
}
|
||||
|
||||
options {
|
||||
disableConcurrentBuilds()
|
||||
timestamps()
|
||||
}
|
||||
|
||||
environment {
|
||||
DOCKER_REGISTRY = "git.v0id.ovh"
|
||||
ORG_NAME = "n3wt-innov"
|
||||
APP_NAME = "n3wt-school"
|
||||
|
||||
IMAGE_FRONT = "${DOCKER_REGISTRY}/${ORG_NAME}/${APP_NAME}/frontend"
|
||||
IMAGE_BACK = "${DOCKER_REGISTRY}/${ORG_NAME}/${APP_NAME}/backend"
|
||||
}
|
||||
|
||||
stages {
|
||||
|
||||
stage("Clean Workspace") {
|
||||
steps {
|
||||
cleanWs()
|
||||
}
|
||||
}
|
||||
|
||||
stage("Only Tags Build") {
|
||||
when {
|
||||
buildingTag()
|
||||
}
|
||||
steps {
|
||||
echo "Build déclenché par tag : ${TAG_NAME}"
|
||||
}
|
||||
}
|
||||
|
||||
stage("Build Docker Images") {
|
||||
when {
|
||||
buildingTag()
|
||||
}
|
||||
steps {
|
||||
sh """
|
||||
chmod +x ./ci/scripts/makeDocker.sh
|
||||
./ci/scripts/makeDocker.sh ${TAG_NAME}
|
||||
"""
|
||||
}
|
||||
}
|
||||
|
||||
stage("Push Images to Registry") {
|
||||
when {
|
||||
buildingTag()
|
||||
}
|
||||
steps {
|
||||
withCredentials([usernamePassword(
|
||||
credentialsId: "gitea-jenkins",
|
||||
usernameVariable: "REGISTRY_USER",
|
||||
passwordVariable: "REGISTRY_PASS"
|
||||
)]) {
|
||||
|
||||
sh """
|
||||
echo "Login registry..."
|
||||
docker login ${DOCKER_REGISTRY} \
|
||||
-u ${REGISTRY_USER} \
|
||||
-p ${REGISTRY_PASS}
|
||||
|
||||
echo "Push version images..."
|
||||
docker push ${IMAGE_FRONT}:${TAG_NAME}
|
||||
docker push ${IMAGE_BACK}:${TAG_NAME}
|
||||
|
||||
echo "Tag latest..."
|
||||
docker tag ${IMAGE_FRONT}:${TAG_NAME} ${IMAGE_FRONT}:latest
|
||||
docker tag ${IMAGE_BACK}:${TAG_NAME} ${IMAGE_BACK}:latest
|
||||
|
||||
docker push ${IMAGE_FRONT}:latest
|
||||
docker push ${IMAGE_BACK}:latest
|
||||
"""
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
post {
|
||||
always {
|
||||
sh """
|
||||
docker builder prune -f
|
||||
docker image prune -f
|
||||
"""
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user