From 7b5e2abe2a31340ce5268e4cf1f47165a3ea2356 Mon Sep 17 00:00:00 2001 From: Nicolas Arenas Date: Tue, 22 Oct 2024 20:17:08 +0200 Subject: [PATCH 01/12] Add first Jenkinsfile --- ogWebconsole/Jenkinsfile | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) create mode 100644 ogWebconsole/Jenkinsfile diff --git a/ogWebconsole/Jenkinsfile b/ogWebconsole/Jenkinsfile new file mode 100644 index 0000000..5c0b891 --- /dev/null +++ b/ogWebconsole/Jenkinsfile @@ -0,0 +1,28 @@ +pipeline { + agent { + jenkins-slave + } + environment { + DOCKER_REGISTRY = "opengnsys" + DOCKER_CREDENTIALS = credentials('DOCKER_HUB_TOKEN') + DOCKER_TAG = "${env.BUILD_NUMBER}" + DOCKER_IMAGE_NAME = "oggui" + } + stages { + stage ('Checkout') { + steps { + checkout scm + } + } + stage('Build') { + steps { + echo 'Building....' + script { + dir('ogWebconsole') { + docker.build("${DOCKER_IMAGE_NAME}:${DOCKER_TAG}", "-f Dockerfile .") + } + } + } + } + } +} From 9b6a5b487b36e50b7cacae778fcb75716ef834b7 Mon Sep 17 00:00:00 2001 From: Nicolas Arenas Date: Tue, 22 Oct 2024 20:18:52 +0200 Subject: [PATCH 02/12] Fix agent --- ogWebconsole/Jenkinsfile | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/ogWebconsole/Jenkinsfile b/ogWebconsole/Jenkinsfile index 5c0b891..a46369d 100644 --- a/ogWebconsole/Jenkinsfile +++ b/ogWebconsole/Jenkinsfile @@ -1,7 +1,5 @@ pipeline { - agent { - jenkins-slave - } + agent jenkins-slave environment { DOCKER_REGISTRY = "opengnsys" DOCKER_CREDENTIALS = credentials('DOCKER_HUB_TOKEN') From b2105a6fdb2fcd80d73ec3b7c11d53a51d928e1f Mon Sep 17 00:00:00 2001 From: Nicolas Arenas Date: Tue, 22 Oct 2024 20:20:02 +0200 Subject: [PATCH 03/12] Another fix --- ogWebconsole/Jenkinsfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ogWebconsole/Jenkinsfile b/ogWebconsole/Jenkinsfile index a46369d..b6a1b48 100644 --- a/ogWebconsole/Jenkinsfile +++ b/ogWebconsole/Jenkinsfile @@ -1,5 +1,5 @@ pipeline { - agent jenkins-slave + agent { "jenkins-slave" } environment { DOCKER_REGISTRY = "opengnsys" DOCKER_CREDENTIALS = credentials('DOCKER_HUB_TOKEN') From bba25ca3521945b68c52f7c6224fb9dbc80e5ac0 Mon Sep 17 00:00:00 2001 From: Nicolas Arenas Date: Tue, 22 Oct 2024 20:21:37 +0200 Subject: [PATCH 04/12] Fix --- ogWebconsole/Jenkinsfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ogWebconsole/Jenkinsfile b/ogWebconsole/Jenkinsfile index b6a1b48..fedf0b7 100644 --- a/ogWebconsole/Jenkinsfile +++ b/ogWebconsole/Jenkinsfile @@ -1,5 +1,5 @@ pipeline { - agent { "jenkins-slave" } + agent { label 'jenkins-slave' } environment { DOCKER_REGISTRY = "opengnsys" DOCKER_CREDENTIALS = credentials('DOCKER_HUB_TOKEN') From 2178e5d74006fef608bac73f957693570acb9c12 Mon Sep 17 00:00:00 2001 From: Nicolas Arenas Date: Tue, 22 Oct 2024 20:44:49 +0200 Subject: [PATCH 05/12] Improve tag --- ogWebconsole/Jenkinsfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ogWebconsole/Jenkinsfile b/ogWebconsole/Jenkinsfile index fedf0b7..1f5083e 100644 --- a/ogWebconsole/Jenkinsfile +++ b/ogWebconsole/Jenkinsfile @@ -17,7 +17,7 @@ pipeline { echo 'Building....' script { dir('ogWebconsole') { - docker.build("${DOCKER_IMAGE_NAME}:${DOCKER_TAG}", "-f Dockerfile .") + docker.build("${DOCKER_IMAGE_NAME}:${BRANCH_NAME}-${DOCKER_TAG}", "-f Dockerfile .") } } } From 016ed56b1cd30658b5ba88ef635b62026b7ca582 Mon Sep 17 00:00:00 2001 From: Nicolas Arenas Date: Tue, 22 Oct 2024 20:45:59 +0200 Subject: [PATCH 06/12] Pass branch to env --- ogWebconsole/Jenkinsfile | 1 + 1 file changed, 1 insertion(+) diff --git a/ogWebconsole/Jenkinsfile b/ogWebconsole/Jenkinsfile index 1f5083e..e2c1071 100644 --- a/ogWebconsole/Jenkinsfile +++ b/ogWebconsole/Jenkinsfile @@ -5,6 +5,7 @@ pipeline { DOCKER_CREDENTIALS = credentials('DOCKER_HUB_TOKEN') DOCKER_TAG = "${env.BUILD_NUMBER}" DOCKER_IMAGE_NAME = "oggui" + BRANCH_NAME = "${env.BRANCH_NAME}" } stages { stage ('Checkout') { From b8eeb86a9580493d2c802f8036a27a264f6111fd Mon Sep 17 00:00:00 2001 From: Nicolas Arenas Date: Tue, 22 Oct 2024 20:48:30 +0200 Subject: [PATCH 07/12] Use proper variable --- ogWebconsole/Jenkinsfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ogWebconsole/Jenkinsfile b/ogWebconsole/Jenkinsfile index e2c1071..95b29a2 100644 --- a/ogWebconsole/Jenkinsfile +++ b/ogWebconsole/Jenkinsfile @@ -5,7 +5,7 @@ pipeline { DOCKER_CREDENTIALS = credentials('DOCKER_HUB_TOKEN') DOCKER_TAG = "${env.BUILD_NUMBER}" DOCKER_IMAGE_NAME = "oggui" - BRANCH_NAME = "${env.BRANCH_NAME}" + BRANCH_NAME = "${env.GIT_BRANCH}" } stages { stage ('Checkout') { From 57e5e57059bd7c0a40a777330a19544131ee90ea Mon Sep 17 00:00:00 2001 From: Nicolas Arenas Date: Tue, 22 Oct 2024 20:51:06 +0200 Subject: [PATCH 08/12] Fix branch name --- ogWebconsole/Jenkinsfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ogWebconsole/Jenkinsfile b/ogWebconsole/Jenkinsfile index 95b29a2..dfa6430 100644 --- a/ogWebconsole/Jenkinsfile +++ b/ogWebconsole/Jenkinsfile @@ -5,7 +5,7 @@ pipeline { DOCKER_CREDENTIALS = credentials('DOCKER_HUB_TOKEN') DOCKER_TAG = "${env.BUILD_NUMBER}" DOCKER_IMAGE_NAME = "oggui" - BRANCH_NAME = "${env.GIT_BRANCH}" + BRANCH_NAME = "${GIT_BRANCH.split("/")[1]}" } stages { stage ('Checkout') { From d6231dbe0f483b25ee26edf06e08b2e07dadb3c7 Mon Sep 17 00:00:00 2001 From: Nicolas Arenas Date: Tue, 22 Oct 2024 20:53:21 +0200 Subject: [PATCH 09/12] Fixing some issues with naming --- ogWebconsole/Jenkinsfile | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/ogWebconsole/Jenkinsfile b/ogWebconsole/Jenkinsfile index dfa6430..e8262b5 100644 --- a/ogWebconsole/Jenkinsfile +++ b/ogWebconsole/Jenkinsfile @@ -1,7 +1,7 @@ pipeline { agent { label 'jenkins-slave' } environment { - DOCKER_REGISTRY = "opengnsys" + DOCKER_REPO = "opengnsys" DOCKER_CREDENTIALS = credentials('DOCKER_HUB_TOKEN') DOCKER_TAG = "${env.BUILD_NUMBER}" DOCKER_IMAGE_NAME = "oggui" @@ -18,7 +18,7 @@ pipeline { echo 'Building....' script { dir('ogWebconsole') { - docker.build("${DOCKER_IMAGE_NAME}:${BRANCH_NAME}-${DOCKER_TAG}", "-f Dockerfile .") + docker.build("${DOCKER_REPO}/${DOCKER_IMAGE_NAME}:${BRANCH_NAME}-${DOCKER_TAG}", "-f Dockerfile .") } } } From 564c592a130b3ca265a8106d680bde57e3ee5484 Mon Sep 17 00:00:00 2001 From: Nicolas Arenas Date: Tue, 22 Oct 2024 20:57:02 +0200 Subject: [PATCH 10/12] Add push step to docker --- ogWebconsole/Jenkinsfile | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/ogWebconsole/Jenkinsfile b/ogWebconsole/Jenkinsfile index e8262b5..f65c6cb 100644 --- a/ogWebconsole/Jenkinsfile +++ b/ogWebconsole/Jenkinsfile @@ -23,5 +23,17 @@ pipeline { } } } + stage('Push') { + steps { + echo 'Pushing....' + script { + docker.withRegistry('https://index.docker.io/v1/', "${DOCKER_CREDENTIALS}") { + dir('ogWebconsole') { + docker.image("${DOCKER_REPO}/${DOCKER_IMAGE_NAME}:${BRANCH_NAME}-${DOCKER_TAG}").push() + } + } + } + } + } } } From 11410146b2e94312411f2c4897fedf785839dff7 Mon Sep 17 00:00:00 2001 From: Nicolas Arenas Date: Tue, 22 Oct 2024 21:06:55 +0200 Subject: [PATCH 11/12] Update credentials --- ogWebconsole/Jenkinsfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ogWebconsole/Jenkinsfile b/ogWebconsole/Jenkinsfile index f65c6cb..368de3a 100644 --- a/ogWebconsole/Jenkinsfile +++ b/ogWebconsole/Jenkinsfile @@ -2,7 +2,7 @@ pipeline { agent { label 'jenkins-slave' } environment { DOCKER_REPO = "opengnsys" - DOCKER_CREDENTIALS = credentials('DOCKER_HUB_TOKEN') + DOCKER_CREDENTIALS = credentials('docker-hub-credentials') DOCKER_TAG = "${env.BUILD_NUMBER}" DOCKER_IMAGE_NAME = "oggui" BRANCH_NAME = "${GIT_BRANCH.split("/")[1]}" From 641c7cc668e197c7e836502d21a69caf3551129c Mon Sep 17 00:00:00 2001 From: Nicolas Arenas Date: Tue, 22 Oct 2024 21:16:03 +0200 Subject: [PATCH 12/12] change way to pass credentials --- ogWebconsole/Jenkinsfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ogWebconsole/Jenkinsfile b/ogWebconsole/Jenkinsfile index 368de3a..308ed3c 100644 --- a/ogWebconsole/Jenkinsfile +++ b/ogWebconsole/Jenkinsfile @@ -27,7 +27,7 @@ pipeline { steps { echo 'Pushing....' script { - docker.withRegistry('https://index.docker.io/v1/', "${DOCKER_CREDENTIALS}") { + docker.withRegistry('https://index.docker.io/v1/', 'docker-hub-credentials' ) { dir('ogWebconsole') { docker.image("${DOCKER_REPO}/${DOCKER_IMAGE_NAME}:${BRANCH_NAME}-${DOCKER_TAG}").push() }