From 3c30af009948c35b1903484384807cbae187b1c8 Mon Sep 17 00:00:00 2001 From: Tom Ruff Date: Sat, 25 Jan 2025 17:49:15 +0200 Subject: [PATCH 1/5] Add Jenkinsfile-prod --- Jenkinsfile-prod | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) create mode 100644 Jenkinsfile-prod diff --git a/Jenkinsfile-prod b/Jenkinsfile-prod new file mode 100644 index 0000000..bb99871 --- /dev/null +++ b/Jenkinsfile-prod @@ -0,0 +1,31 @@ +pipeline { + agent { + label 'prod' // Runs on a node labeled 'prod' + } + stages { + stage('Clean Old Container') { + steps { + script { + catchError(buildResult: 'SUCCESS', message: 'Container doesn\'t exist on host, skipping...', stageResult: 'ABORTED') { + sh 'docker stop game-pod1' + sh 'docker rm game-pod1' + } + } + } + } + stage('Run new container in Production') { + 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 and run container in prod environment + docker.withRegistry('https://git.ruff.co.il', registryCredentialsId) { + docker.image(imageName).run('-p 22443:80 --name game-pod1') + } + } + } + } + } +} \ No newline at end of file From 41d47fd6bd5117678b9ca4c8baf9a0d02b2839ac Mon Sep 17 00:00:00 2001 From: Tom Ruff Date: Sat, 25 Jan 2025 17:51:20 +0200 Subject: [PATCH 2/5] Update Jenkinsfile --- Jenkinsfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Jenkinsfile b/Jenkinsfile index cf4384a..bbe9435 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -73,7 +73,7 @@ pipeline { // Login to registry docker.withRegistry('https://git.ruff.co.il', registryCredentialsId) { - // Run container + // Run container on build docker.image(imageName).run('-p 10002:80 --name otomai') } } From c69e1e7a29774f5ce09c0d81188b5c57a86d6f69 Mon Sep 17 00:00:00 2001 From: Tom Ruff Date: Sat, 25 Jan 2025 17:54:13 +0200 Subject: [PATCH 3/5] Update Dockerfile --- Dockerfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Dockerfile b/Dockerfile index 0ae1a8c..b11074b 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,2 +1,2 @@ FROM httpd:latest -COPY ./game-data/ /usr/local/apache2/htdocs +COPY ./game-data/ /usr/local/apache2/htdocs \ No newline at end of file From bde4926c5f7378d9b923e7d3f8cb4c5a5c6dbf8c Mon Sep 17 00:00:00 2001 From: Tom Ruff Date: Sat, 25 Jan 2025 18:22:29 +0200 Subject: [PATCH 4/5] Update Jenkinsfile --- Jenkinsfile | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/Jenkinsfile b/Jenkinsfile index bbe9435..38304e6 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -57,7 +57,7 @@ pipeline { } stage('Clean Old Container') { steps { - catchError(buildResult: 'SUCCESS',message: 'Container doesn\'t exist on host, skipping...', stageResult: 'ABORTED') { + catchError(buildResult: 'SUCCESS', message: 'Container doesn\'t exist on host, skipping...', stageResult: 'ABORTED') { sh 'docker stop otomai' sh 'docker rm otomai' } @@ -73,11 +73,21 @@ pipeline { // Login to registry docker.withRegistry('https://git.ruff.co.il', registryCredentialsId) { - // Run container on build + // Run container docker.image(imageName).run('-p 10002:80 --name otomai') } } } } } + post { + success { + // Trigger the deploy-prod-job on success of the build + build job: 'deploy-prod-job', wait: false + } + failure { + // Optionally, you can handle failure scenarios (e.g., notify team, etc.) + echo "Build failed, deployment not triggered." + } + } } From e033fd148823bd6675106ccf8ef7502546b1aa9d Mon Sep 17 00:00:00 2001 From: Tom Ruff Date: Sat, 25 Jan 2025 18:23:20 +0200 Subject: [PATCH 5/5] Update Jenkinsfile --- Jenkinsfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Jenkinsfile b/Jenkinsfile index 38304e6..cb9a07e 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -83,7 +83,7 @@ pipeline { post { success { // Trigger the deploy-prod-job on success of the build - build job: 'deploy-prod-job', wait: false + build job: 'otomai-prod', wait: false } failure { // Optionally, you can handle failure scenarios (e.g., notify team, etc.)