Files
otomai/Jenkinsfile
2025-01-25 17:51:20 +02:00

84 lines
2.9 KiB
Groovy

pipeline {
agent {
label 'docker'
}
stages {
stage("Clean workspace") {
steps {
script {
sh "ls"
deleteDir()
sh "ls"
}
}
}
stage('Checkout SCM') {
steps {
git branch: 'main', url: 'https://git.ruff.co.il/amai.ig/otomai.git'
}
}
stage('Download Latest release') {
steps {
sh 'curl -LO https://git.ruff.co.il/amai.ig/otomai/releases/download/latest/Otomai-web.zip'
}
}
stage('Create web game directory') {
steps {
sh 'mkdir ./game-data'
}
}
stage('Unzip File') {
steps {
sh 'unzip -d game-data/ Otomai-web.zip'
}
}
stage('Build Docker Image') {
steps {
dir('./') {
script {
// Define image name and registry details
def imageNameId = "git.ruff.co.il/amai.ig/otomai:1.${env.BUILD_ID}"
def imageNameLatest = "git.ruff.co.il/amai.ig/otomai:latest"
def registryCredentialsId = '7e506860-ca64-47bd-92a8-1a591dd12cba'
// Login to the Docker registry with credentials
docker.withRegistry('https://git.ruff.co.il', registryCredentialsId) {
// Build and push images using docker.build()
def customImageId = docker.build(imageNameId)
def customImageLatest = docker.build(imageNameLatest)
// Push image to registry
customImageId.push()
customImageLatest.push()
}
}
}
}
}
stage('Clean Old Container') {
steps {
catchError(buildResult: 'SUCCESS',message: 'Container doesn\'t exist on host, skipping...', stageResult: 'ABORTED') {
sh 'docker stop otomai'
sh 'docker rm otomai'
}
}
}
stage('Run new container') {
steps {
script {
// Define registry credentials and image name
def registryCredentialsId = '7e506860-ca64-47bd-92a8-1a591dd12cba'
def imageName = 'git.ruff.co.il/amai.ig/otomai:latest'
// Login to registry
docker.withRegistry('https://git.ruff.co.il', registryCredentialsId) {
// Run container on build
docker.image(imageName).run('-p 10002:80 --name otomai')
}
}
}
}
}
}