From c80485cd80467fd4644babaf1f5544ca090c5f01 Mon Sep 17 00:00:00 2001 From: DavidAlkobi <136454939+DavidAlkobi@users.noreply.github.com> Date: Tue, 8 Aug 2023 12:54:17 +0300 Subject: [PATCH 01/14] Create Jenkinsfile --- Jenkinsfile | 38 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) create mode 100644 Jenkinsfile diff --git a/Jenkinsfile b/Jenkinsfile new file mode 100644 index 0000000..2f70983 --- /dev/null +++ b/Jenkinsfile @@ -0,0 +1,38 @@ +pipeline { + // Run on an agent where we want to use Go + agent any + + // Ensure the desired Go version is installed for all stages, + // using the name defined in the Global Tool Configuration + tools { go 'go 1.20.7' } + + + stages { + + stage('Go init') { + steps{ + sh 'cd helloworld/' + sh 'go mod init helloworld' + } + } + stage('Build') { + steps { + sh 'cd helloworld/ && go build -buildmode=pie -buildvcs=false' + } + } + + stage('Test') { + steps { + sh 'cd helloworld/ && go test' + } + } + } + + post { + always { + dir('helloworld') { + archiveArtifacts artifacts: 'helloworld', onlyIfSuccessful: true + } + } + } +} From ab7caddfbf44fc3a04b234492e33c0fbf54feb0b Mon Sep 17 00:00:00 2001 From: DavidAlkobi <136454939+DavidAlkobi@users.noreply.github.com> Date: Tue, 8 Aug 2023 13:41:12 +0300 Subject: [PATCH 02/14] Update Jenkinsfile --- Jenkinsfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Jenkinsfile b/Jenkinsfile index 2f70983..22a06e3 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -17,7 +17,7 @@ pipeline { } stage('Build') { steps { - sh 'cd helloworld/ && go build -buildmode=pie -buildvcs=false' + sh 'cd helloworld/ && rm -rf build && go build -buildmode=pie -buildvcs=false' } } From 014331d632f9a1c95406f90abf98fa7dbc979e09 Mon Sep 17 00:00:00 2001 From: DavidAlkobi <136454939+DavidAlkobi@users.noreply.github.com> Date: Tue, 8 Aug 2023 13:43:48 +0300 Subject: [PATCH 03/14] Update Jenkinsfile --- Jenkinsfile | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/Jenkinsfile b/Jenkinsfile index 22a06e3..1d34e43 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -10,11 +10,15 @@ pipeline { stages { stage('Go init') { - steps{ - sh 'cd helloworld/' - sh 'go mod init helloworld' - } - } + steps { + script { + def goModExists = fileExists('helloworld/go.mod') + if (!goModExists) { + sh 'cd helloworld/ && go mod init helloworld' + } + } + } +} stage('Build') { steps { sh 'cd helloworld/ && rm -rf build && go build -buildmode=pie -buildvcs=false' From f7a51f6bdc597985ccced4c2d4101a84c568e479 Mon Sep 17 00:00:00 2001 From: DavidAlkobi <136454939+DavidAlkobi@users.noreply.github.com> Date: Tue, 8 Aug 2023 13:46:15 +0300 Subject: [PATCH 04/14] Update Jenkinsfile --- Jenkinsfile | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Jenkinsfile b/Jenkinsfile index 1d34e43..1cdda96 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -21,7 +21,8 @@ pipeline { } stage('Build') { steps { - sh 'cd helloworld/ && rm -rf build && go build -buildmode=pie -buildvcs=false' + sh 'cd helloworld/ && rm -rf build' + sh 'cd helloworld/ && go build -buildmode=pie -buildvcs=false' } } From 0b9853d1bf4b9d8cfe0c03c4b098da2184f9cd80 Mon Sep 17 00:00:00 2001 From: DavidAlkobi <136454939+DavidAlkobi@users.noreply.github.com> Date: Tue, 8 Aug 2023 13:49:38 +0300 Subject: [PATCH 05/14] Update Jenkinsfile --- Jenkinsfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Jenkinsfile b/Jenkinsfile index 1cdda96..9934fb7 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -22,7 +22,7 @@ pipeline { stage('Build') { steps { sh 'cd helloworld/ && rm -rf build' - sh 'cd helloworld/ && go build -buildmode=pie -buildvcs=false' + sh 'cd helloworld/ && go build' } } From 986b758c9ab159fc0c19f09feddb42e42d07e98c Mon Sep 17 00:00:00 2001 From: DavidAlkobi <136454939+DavidAlkobi@users.noreply.github.com> Date: Tue, 8 Aug 2023 14:07:29 +0300 Subject: [PATCH 06/14] Update Jenkinsfile --- Jenkinsfile | 12 +----------- 1 file changed, 1 insertion(+), 11 deletions(-) diff --git a/Jenkinsfile b/Jenkinsfile index 9934fb7..3cfcf37 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -8,17 +8,7 @@ pipeline { stages { - - stage('Go init') { - steps { - script { - def goModExists = fileExists('helloworld/go.mod') - if (!goModExists) { - sh 'cd helloworld/ && go mod init helloworld' - } - } - } -} + stage('Build') { steps { sh 'cd helloworld/ && rm -rf build' From cc039b1677b3198eb84c12985d1a3ebd6412feb0 Mon Sep 17 00:00:00 2001 From: DavidAlkobi <136454939+DavidAlkobi@users.noreply.github.com> Date: Tue, 8 Aug 2023 14:08:53 +0300 Subject: [PATCH 07/14] Update Jenkinsfile --- Jenkinsfile | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/Jenkinsfile b/Jenkinsfile index 3cfcf37..e1919e2 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -11,8 +11,7 @@ pipeline { stage('Build') { steps { - sh 'cd helloworld/ && rm -rf build' - sh 'cd helloworld/ && go build' + sh 'go build' } } From 90c86fc8b1e253c287302d142d98975013fac9d6 Mon Sep 17 00:00:00 2001 From: DavidAlkobi <136454939+DavidAlkobi@users.noreply.github.com> Date: Tue, 8 Aug 2023 14:10:34 +0300 Subject: [PATCH 08/14] Update Jenkinsfile --- Jenkinsfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Jenkinsfile b/Jenkinsfile index e1919e2..bccf16d 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -11,7 +11,7 @@ pipeline { stage('Build') { steps { - sh 'go build' + sh 'rm -rf build && go build' } } From ac55a630b065572bde789d48a8afdc5f340c7e79 Mon Sep 17 00:00:00 2001 From: DavidAlkobi <136454939+DavidAlkobi@users.noreply.github.com> Date: Tue, 8 Aug 2023 14:17:06 +0300 Subject: [PATCH 09/14] Update Jenkinsfile --- Jenkinsfile | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Jenkinsfile b/Jenkinsfile index bccf16d..b91439e 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -11,13 +11,13 @@ pipeline { stage('Build') { steps { - sh 'rm -rf build && go build' + sh 'rm -rf build && go build -o myprogram' } } stage('Test') { steps { - sh 'cd helloworld/ && go test' + sh 'go test' } } } @@ -25,7 +25,7 @@ pipeline { post { always { dir('helloworld') { - archiveArtifacts artifacts: 'helloworld', onlyIfSuccessful: true + archiveArtifacts artifacts: 'myprogram', onlyIfSuccessful: true } } } From a3b97cec29fc36b931bb5ea3355ea95ef2cd2748 Mon Sep 17 00:00:00 2001 From: DavidAlkobi <136454939+DavidAlkobi@users.noreply.github.com> Date: Tue, 8 Aug 2023 14:21:14 +0300 Subject: [PATCH 10/14] Update Jenkinsfile --- Jenkinsfile | 1 - 1 file changed, 1 deletion(-) diff --git a/Jenkinsfile b/Jenkinsfile index b91439e..10391b4 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -24,7 +24,6 @@ pipeline { post { always { - dir('helloworld') { archiveArtifacts artifacts: 'myprogram', onlyIfSuccessful: true } } From 5b064198bef196c977c2116ee2ebddd272d92f55 Mon Sep 17 00:00:00 2001 From: DavidAlkobi <136454939+DavidAlkobi@users.noreply.github.com> Date: Tue, 8 Aug 2023 14:22:07 +0300 Subject: [PATCH 11/14] Update Jenkinsfile --- Jenkinsfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Jenkinsfile b/Jenkinsfile index 10391b4..9c11056 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -28,4 +28,4 @@ pipeline { } } } -} + From 59602e3c87e74f694d994e1aa54cda933a253747 Mon Sep 17 00:00:00 2001 From: DavidAlkobi <136454939+DavidAlkobi@users.noreply.github.com> Date: Tue, 8 Aug 2023 14:23:00 +0300 Subject: [PATCH 12/14] Update Jenkinsfile --- Jenkinsfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Jenkinsfile b/Jenkinsfile index 9c11056..78ac48a 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -11,7 +11,7 @@ pipeline { stage('Build') { steps { - sh 'rm -rf build && go build -o myprogram' + sh 'go build -o myprogram' } } From 8448ba20d81e0d3d2338524f010c7940a66eb08d Mon Sep 17 00:00:00 2001 From: DavidAlkobi <136454939+DavidAlkobi@users.noreply.github.com> Date: Wed, 9 Aug 2023 15:04:45 +0300 Subject: [PATCH 13/14] Update Jenkinsfile --- Jenkinsfile | 1 + 1 file changed, 1 insertion(+) diff --git a/Jenkinsfile b/Jenkinsfile index 78ac48a..54ec253 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -11,6 +11,7 @@ pipeline { stage('Build') { steps { + sh 'go mod init' sh 'go build -o myprogram' } } From fa96c78a28e4b1a55016436431de5e7891218364 Mon Sep 17 00:00:00 2001 From: DavidAlkobi <136454939+DavidAlkobi@users.noreply.github.com> Date: Wed, 9 Aug 2023 15:23:30 +0300 Subject: [PATCH 14/14] Update Jenkinsfile --- Jenkinsfile | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/Jenkinsfile b/Jenkinsfile index 54ec253..c6b3dfc 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -8,10 +8,17 @@ pipeline { stages { + + stage('for dev branch') { + when { + branch 'dev' + } + steps { + echo 'this is only for brunch dev' + } stage('Build') { steps { - sh 'go mod init' sh 'go build -o myprogram' } }