From f3c55bf7e37d7fdba70ceb23f467e1b41411b7b5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Karol=20G=C3=B3rzy=C5=84ski?= Date: Wed, 2 Dec 2020 18:52:16 +0100 Subject: [PATCH 1/9] SES-79 Try configs for Dockerfile and Jenkinsfile --- SessionCompanion/Dockerfile | 8 ++++++++ SessionCompanion/Jenkinsfile | 11 +++++++++++ 2 files changed, 19 insertions(+) create mode 100644 SessionCompanion/Dockerfile create mode 100644 SessionCompanion/Jenkinsfile diff --git a/SessionCompanion/Dockerfile b/SessionCompanion/Dockerfile new file mode 100644 index 0000000..d34dc0f --- /dev/null +++ b/SessionCompanion/Dockerfile @@ -0,0 +1,8 @@ +FROM mcr.microsoft.com/dotnet/sdk:5.0 + +ADD . /App +WORKDIR /App + +EXPOSE 5001 + +CMD 'dotnet' 'build' diff --git a/SessionCompanion/Jenkinsfile b/SessionCompanion/Jenkinsfile new file mode 100644 index 0000000..2e1c547 --- /dev/null +++ b/SessionCompanion/Jenkinsfile @@ -0,0 +1,11 @@ +pipeline { + def app + + stage('Build image') { + checkout scm + app = docker.build("session-companion:${env.BUILD_ID}") + } + stage('Build app') { + docker.image("session-companion:${env.BUILD_ID}").withRun(-p 8080:8080) + } +} From e183f7e161fd401c5ea91886b45ec0654a753725 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Karol=20G=C3=B3rzy=C5=84ski?= Date: Wed, 2 Dec 2020 19:17:49 +0100 Subject: [PATCH 2/9] SES-79 Check with Jenkinsfile --- SessionCompanion/Jenkinsfile => Jenkinsfile | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) rename SessionCompanion/Jenkinsfile => Jenkinsfile (63%) diff --git a/SessionCompanion/Jenkinsfile b/Jenkinsfile similarity index 63% rename from SessionCompanion/Jenkinsfile rename to Jenkinsfile index 2e1c547..9723b8e 100644 --- a/SessionCompanion/Jenkinsfile +++ b/Jenkinsfile @@ -3,7 +3,9 @@ pipeline { stage('Build image') { checkout scm - app = docker.build("session-companion:${env.BUILD_ID}") + dir('SessionCompanion') { + app = docker.build("session-companion:${env.BUILD_ID}") + } } stage('Build app') { docker.image("session-companion:${env.BUILD_ID}").withRun(-p 8080:8080) From c4b5bf689b4525b7dc626ec5cf8596d44723d61c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Karol=20G=C3=B3rzy=C5=84ski?= Date: Wed, 2 Dec 2020 19:20:18 +0100 Subject: [PATCH 3/9] Bug in jenkinsfile fixed --- Jenkinsfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Jenkinsfile b/Jenkinsfile index 9723b8e..aee988b 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -8,6 +8,6 @@ pipeline { } } stage('Build app') { - docker.image("session-companion:${env.BUILD_ID}").withRun(-p 8080:8080) + docker.image("session-companion:${env.BUILD_ID}").withRun('-p 5050:5050') } } From 1f5344f3c8340c1c1686cb732ffa56e3dc0e337d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Karol=20G=C3=B3rzy=C5=84ski?= Date: Wed, 2 Dec 2020 19:21:48 +0100 Subject: [PATCH 4/9] Bug in jenkinsfile fixed another --- Jenkinsfile | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/Jenkinsfile b/Jenkinsfile index aee988b..b19fbd7 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -1,10 +1,9 @@ pipeline { - def app stage('Build image') { checkout scm dir('SessionCompanion') { - app = docker.build("session-companion:${env.BUILD_ID}") + docker.build("session-companion:${env.BUILD_ID}") } } stage('Build app') { From e72f038c215eb57d5a3445c53168fa042e39305c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Karol=20G=C3=B3rzy=C5=84ski?= Date: Wed, 2 Dec 2020 19:28:44 +0100 Subject: [PATCH 5/9] SES-79 More fighting with Jenkinsfile --- Jenkinsfile | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/Jenkinsfile b/Jenkinsfile index b19fbd7..f48da41 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -1,12 +1,13 @@ pipeline { - - stage('Build image') { - checkout scm - dir('SessionCompanion') { - docker.build("session-companion:${env.BUILD_ID}") + stages { + stage('Build image') { + checkout scm + dir('SessionCompanion') { + docker.build("session-companion:${env.BUILD_ID}") + } + } + stage('Build app') { + docker.image("session-companion:${env.BUILD_ID}").withRun('-p 5050:5050') } } - stage('Build app') { - docker.image("session-companion:${env.BUILD_ID}").withRun('-p 5050:5050') - } } From ddfb2bad7c5bf70084065aadb51430ad4bd99440 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Karol=20G=C3=B3rzy=C5=84ski?= Date: Wed, 2 Dec 2020 19:41:09 +0100 Subject: [PATCH 6/9] SES-79 Try different approach with Jenkinsfile --- Jenkinsfile | 33 ++++++++++++++++++++++++++------- 1 file changed, 26 insertions(+), 7 deletions(-) diff --git a/Jenkinsfile b/Jenkinsfile index f48da41..4959acd 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -1,13 +1,32 @@ +//pipeline { +// stages { +// stage('Build image') { +// checkout scm +// dir('SessionCompanion') { +// docker.build("session-companion:${env.BUILD_ID}") +// } +// } +// stage('Build app') { +// docker.image("session-companion:${env.BUILD_ID}").withRun('-p 5050:5050') +// } +// } +//} pipeline { - stages { + agent any + stages { stage('Build image') { - checkout scm - dir('SessionCompanion') { - docker.build("session-companion:${env.BUILD_ID}") - } + steps { + echo "Building docker image" + script { + def customImage = docker.build("session-companion:${env.BUILD_ID}") + customImage.withRun('-p 5050:5050') + } + } } - stage('Build app') { - docker.image("session-companion:${env.BUILD_ID}").withRun('-p 5050:5050') + stage('Delete image') { + steps { + sh "docker rmi session-companion:${env.BUILD_ID}" + } } } } From 23cc8a8df2381ca421f59f358c23cd78c5d78059 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Karol=20G=C3=B3rzy=C5=84ski?= Date: Wed, 2 Dec 2020 19:43:47 +0100 Subject: [PATCH 7/9] Add Small fix to Jenkinsfile --- Jenkinsfile | 2 ++ 1 file changed, 2 insertions(+) diff --git a/Jenkinsfile b/Jenkinsfile index 4959acd..a19005b 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -18,8 +18,10 @@ pipeline { steps { echo "Building docker image" script { + dir('SessionCompanion'){ def customImage = docker.build("session-companion:${env.BUILD_ID}") customImage.withRun('-p 5050:5050') + } } } } From f1d906c1b19b74f976783739f1f4156f46fe6241 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Karol=20G=C3=B3rzy=C5=84ski?= Date: Wed, 2 Dec 2020 20:01:33 +0100 Subject: [PATCH 8/9] SES-79 Small fix to Jenkinsfile --- Jenkinsfile | 4 ++-- SessionCompanion/{ => SessionCompanion}/Dockerfile | 1 - 2 files changed, 2 insertions(+), 3 deletions(-) rename SessionCompanion/{ => SessionCompanion}/Dockerfile (98%) diff --git a/Jenkinsfile b/Jenkinsfile index a19005b..171baaa 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -18,9 +18,9 @@ pipeline { steps { echo "Building docker image" script { - dir('SessionCompanion'){ + dir('SessionCompanion/SessionCompanion'){ def customImage = docker.build("session-companion:${env.BUILD_ID}") - customImage.withRun('-p 5050:5050') + //customImage.withRun('-p 5050:5050') } } } diff --git a/SessionCompanion/Dockerfile b/SessionCompanion/SessionCompanion/Dockerfile similarity index 98% rename from SessionCompanion/Dockerfile rename to SessionCompanion/SessionCompanion/Dockerfile index d34dc0f..9868635 100644 --- a/SessionCompanion/Dockerfile +++ b/SessionCompanion/SessionCompanion/Dockerfile @@ -4,5 +4,4 @@ ADD . /App WORKDIR /App EXPOSE 5001 - CMD 'dotnet' 'build' From 8293935bff25cb8a966d76b0ca37a5003063c511 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Karol=20G=C3=B3rzy=C5=84ski?= Date: Wed, 2 Dec 2020 20:35:22 +0100 Subject: [PATCH 9/9] SES-79 Delete unnecessary code --- Jenkinsfile | 13 ------------- 1 file changed, 13 deletions(-) diff --git a/Jenkinsfile b/Jenkinsfile index 171baaa..e8bae64 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -1,16 +1,3 @@ -//pipeline { -// stages { -// stage('Build image') { -// checkout scm -// dir('SessionCompanion') { -// docker.build("session-companion:${env.BUILD_ID}") -// } -// } -// stage('Build app') { -// docker.image("session-companion:${env.BUILD_ID}").withRun('-p 5050:5050') -// } -// } -//} pipeline { agent any stages {