84 lines
2.5 KiB
Groovy
84 lines
2.5 KiB
Groovy
pipeline {
|
|
agent {
|
|
label "docker-agent-dsrv02"
|
|
}
|
|
|
|
environment {
|
|
DOCKER_REGISTRY = 'gitea.postio.pl'
|
|
IMAGE_NAME = 'public/oxdr-swagger-ui'
|
|
}
|
|
|
|
parameters {
|
|
string(name: 'BUILD_ID', defaultValue: 'latest', description: 'Image tag / build identifier')
|
|
}
|
|
|
|
stages {
|
|
stage('Checkout') {
|
|
steps {
|
|
git branch: 'main', credentialsId: 'postio-bot-gitea', url: 'https://gitea.postio.pl/public/microservice-repository.git'
|
|
}
|
|
}
|
|
|
|
stage('Generate Swagger Docs') {
|
|
agent {
|
|
docker {
|
|
image 'bufbuild/buf:latest'
|
|
args '--entrypoint='
|
|
reuseNode true
|
|
}
|
|
}
|
|
environment {
|
|
BUF_CACHE_DIR="${env.WORKSPACE}/.cache"
|
|
}
|
|
steps {
|
|
dir("${env.WORKSPACE}") {
|
|
echo "Generating Swagger documentation..."
|
|
sh "buf generate"
|
|
}
|
|
}
|
|
}
|
|
stage('Convert OpenAPI to v3') {
|
|
agent {
|
|
docker {
|
|
image 'python:3-bookworm'
|
|
reuseNode true
|
|
}
|
|
}
|
|
steps {
|
|
dir("${env.WORKSPACE}") {
|
|
echo "Converting OpenAPI V2 to V3..."
|
|
sh "python3 scripts/process_openapiv2.py"
|
|
}
|
|
}
|
|
}
|
|
|
|
stage('Build Docker Image') {
|
|
steps {
|
|
echo "Building Docker image..."
|
|
sh "docker build -t ${DOCKER_REGISTRY}/${IMAGE_NAME}:${BUILD_ID} -f deployments/docker/Dockerfile deployments/docker/"
|
|
}
|
|
}
|
|
|
|
stage('Push Docker Image') {
|
|
steps {
|
|
withCredentials([usernamePassword(
|
|
credentialsId: 'postio-bot-gitea', // <-- Update to your Jenkins credentials ID
|
|
usernameVariable: 'DOCKER_USER',
|
|
passwordVariable: 'DOCKER_PASS'
|
|
)]) {
|
|
echo "Logging into Docker registry..."
|
|
sh "echo $DOCKER_PASS | docker login ${DOCKER_REGISTRY} -u $DOCKER_USER --password-stdin"
|
|
echo "Pushing Docker image..."
|
|
sh "docker push ${DOCKER_REGISTRY}/${IMAGE_NAME}:${BUILD_ID}"
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
post {
|
|
failure {
|
|
echo "Build failed. Check the console output for details."
|
|
}
|
|
}
|
|
}
|