From 8aa7d5ceed241920bc874a0da0930af4e7470977 Mon Sep 17 00:00:00 2001 From: "Vazquez,Brais (IT EDP)" Date: Wed, 21 Aug 2024 15:22:40 +0200 Subject: [PATCH 01/12] Lower cpu and memory resources --- jenkins/ocp-config/deploy/jenkins-webhook-proxy.yml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/jenkins/ocp-config/deploy/jenkins-webhook-proxy.yml b/jenkins/ocp-config/deploy/jenkins-webhook-proxy.yml index 5eed693a7..5bf6fde34 100644 --- a/jenkins/ocp-config/deploy/jenkins-webhook-proxy.yml +++ b/jenkins/ocp-config/deploy/jenkins-webhook-proxy.yml @@ -21,13 +21,13 @@ parameters: - name: ODS_BITBUCKET_PROJECT required: true - name: WEBHOOK_PROXY_CPU_REQUEST - value: 50m + value: 25m - name: WEBHOOK_PROXY_CPU_LIMIT - value: 200m + value: 50m - name: WEBHOOK_PROXY_MEMORY_REQUEST - value: 128Mi + value: 30Mi - name: WEBHOOK_PROXY_MEMORY_LIMIT - value: 128Mi + value: 40Mi objects: - apiVersion: route.openshift.io/v1 kind: Route From 15cf2948c60ec09fce0a4556f7a99b58fa64e163 Mon Sep 17 00:00:00 2001 From: "Vazquez,Brais (IT EDP)" Date: Wed, 21 Aug 2024 15:25:27 +0200 Subject: [PATCH 02/12] Update to go 1.23 --- .github/workflows/continuous-integration-workflow.yml | 6 +++--- jenkins/webhook-proxy/Dockerfile | 2 +- jenkins/webhook-proxy/Makefile | 2 +- jenkins/webhook-proxy/go.mod | 2 +- 4 files changed, 6 insertions(+), 6 deletions(-) diff --git a/.github/workflows/continuous-integration-workflow.yml b/.github/workflows/continuous-integration-workflow.yml index b5c9176ea..0fda74f71 100644 --- a/.github/workflows/continuous-integration-workflow.yml +++ b/.github/workflows/continuous-integration-workflow.yml @@ -90,10 +90,10 @@ jobs: name: Checkout repository uses: actions/checkout@v4.1.7 - - name: Setup Go 1.18 + name: Setup Go 1.23 uses: actions/setup-go@v5 with: - go-version: 1.18 + go-version: 1.23 - name: Download goimports run: | @@ -102,7 +102,7 @@ jobs: name: Download golangci-lint run: | curl -sSfL --output /tmp/golangci-lint.sh https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh - cat /tmp/golangci-lint.sh | sh -s -- -b $(go env GOPATH)/bin v1.49.0 + cat /tmp/golangci-lint.sh | sh -s -- -b $(go env GOPATH)/bin v1.60.1 - name: Run linter working-directory: jenkins/webhook-proxy diff --git a/jenkins/webhook-proxy/Dockerfile b/jenkins/webhook-proxy/Dockerfile index 8dd80316a..482824f06 100644 --- a/jenkins/webhook-proxy/Dockerfile +++ b/jenkins/webhook-proxy/Dockerfile @@ -1,7 +1,7 @@ # Ideally we would us a very small image like plain alpine and just copy the # pre-built binary into it, but due to e.g. multistage builds not available in # OpenShift yet, for now the easiest is to build the binary in this image. -FROM golang:1.18-alpine +FROM golang:1.23-alpine # Set default ALLOWED_EXTERNAL_PROJECTS env var ARG allowedExternalProjects=opendevstack diff --git a/jenkins/webhook-proxy/Makefile b/jenkins/webhook-proxy/Makefile index dca27bcb7..bb3c62991 100644 --- a/jenkins/webhook-proxy/Makefile +++ b/jenkins/webhook-proxy/Makefile @@ -8,7 +8,7 @@ fmt: lint: golangci-lint --version - golangci-lint run --go=1.18 + golangci-lint run --go=1.23 build: build-linux build-darwin build-windows diff --git a/jenkins/webhook-proxy/go.mod b/jenkins/webhook-proxy/go.mod index 281b2e28e..3a9f0f8d5 100644 --- a/jenkins/webhook-proxy/go.mod +++ b/jenkins/webhook-proxy/go.mod @@ -1,3 +1,3 @@ module github.com/opendevstack/ods-core/jenkins/webhook-proxy -go 1.18 +go 1.23 From b79964c809a6465ce422787b619ae44f9710917f Mon Sep 17 00:00:00 2001 From: "Vazquez,Brais (IT EDP)" Date: Wed, 21 Aug 2024 15:25:41 +0200 Subject: [PATCH 03/12] Re-order template --- jenkins/webhook-proxy/pipeline.json.tmpl | 39 ++++++++++++------------ 1 file changed, 19 insertions(+), 20 deletions(-) diff --git a/jenkins/webhook-proxy/pipeline.json.tmpl b/jenkins/webhook-proxy/pipeline.json.tmpl index e1097b581..dbc48902e 100644 --- a/jenkins/webhook-proxy/pipeline.json.tmpl +++ b/jenkins/webhook-proxy/pipeline.json.tmpl @@ -7,16 +7,16 @@ "resourceVersion": "{{.ResourceVersion}}" }, "spec": { - "triggers": [ - { - "type": "Generic", - "generic": { - "secret": "{{.TriggerSecret}}", - "allowEnv": true - } + "output": {}, + "resources": {}, + "strategy": { + "type": "JenkinsPipeline", + "jenkinsPipelineStrategy": { + "jenkinsfilePath": "{{.JenkinsfilePath}}", + "env": {{.Env}} } - ], - "runPolicy": "Serial", + }, + "postCommit": {}, "source": { "type": "Git", "git": { @@ -27,16 +27,15 @@ "name": "cd-user-with-password" } }, - "strategy": { - "type": "JenkinsPipeline", - "jenkinsPipelineStrategy": { - "jenkinsfilePath": "{{.JenkinsfilePath}}", - "env": {{.Env}} + "triggers": [ + { + "type": "Generic", + "generic": { + "secret": "{{.TriggerSecret}}", + "allowEnv": true + } } - }, - "output": {}, - "resources": {}, - "postCommit": {}, - "nodeSelector": {} + ], + "runPolicy": "Serial" } -} +} \ No newline at end of file From 8038fb6c062037183753f84efcaaffac8a4cd071 Mon Sep 17 00:00:00 2001 From: "Vazquez,Brais (IT EDP)" Date: Wed, 21 Aug 2024 17:45:03 +0200 Subject: [PATCH 04/12] Remove availability checks from forward event --- jenkins/webhook-proxy/main.go | 3 --- 1 file changed, 3 deletions(-) diff --git a/jenkins/webhook-proxy/main.go b/jenkins/webhook-proxy/main.go index 132fcceab..9af54380f 100644 --- a/jenkins/webhook-proxy/main.go +++ b/jenkins/webhook-proxy/main.go @@ -595,9 +595,6 @@ func (c *ocClient) Forward(e *Event, triggerSecret string) (int, []byte, error) ) log.Println(e.RequestID, "Forwarding to", url) - c.CheckJenkinsAvailability(e) - c.CheckDocGenAvailability(e) - p := struct { Env []EnvPair `json:"env"` }{ From 5ee4db2a291c46e2f6a82b069da38594a69b2d84 Mon Sep 17 00:00:00 2001 From: "Vazquez,Brais (IT EDP)" Date: Thu, 22 Aug 2024 08:57:35 +0200 Subject: [PATCH 05/12] fix test files for reordering of the template --- jenkins/webhook-proxy/pipeline.json.tmpl | 2 +- .../golden/build-component-pipeline.json | 37 +++++++++--------- .../golden/build-pipeline-branch.json | 37 +++++++++--------- .../build-pipeline-jenkinsfilepath.json | 37 +++++++++--------- .../testdata/golden/build-pipeline.json | 39 +++++++++---------- .../testdata/golden/foo-cd-pipeline.json | 37 +++++++++--------- .../testdata/golden/pipeline.json | 37 +++++++++--------- .../testdata/golden/prov-app-pipeline.json | 37 +++++++++--------- 8 files changed, 128 insertions(+), 135 deletions(-) diff --git a/jenkins/webhook-proxy/pipeline.json.tmpl b/jenkins/webhook-proxy/pipeline.json.tmpl index dbc48902e..03d111e98 100644 --- a/jenkins/webhook-proxy/pipeline.json.tmpl +++ b/jenkins/webhook-proxy/pipeline.json.tmpl @@ -38,4 +38,4 @@ ], "runPolicy": "Serial" } -} \ No newline at end of file +} diff --git a/jenkins/webhook-proxy/testdata/golden/build-component-pipeline.json b/jenkins/webhook-proxy/testdata/golden/build-component-pipeline.json index e762edb3b..d8ecfff8b 100644 --- a/jenkins/webhook-proxy/testdata/golden/build-component-pipeline.json +++ b/jenkins/webhook-proxy/testdata/golden/build-component-pipeline.json @@ -7,16 +7,16 @@ "resourceVersion": "0" }, "spec": { - "triggers": [ - { - "type": "Generic", - "generic": { - "secret": "s3cr3t", - "allowEnv": true - } + "output": {}, + "resources": {}, + "strategy": { + "type": "JenkinsPipeline", + "jenkinsPipelineStrategy": { + "jenkinsfilePath": "Jenkinsfile", + "env": [{"name":"FOO_BAR","value":"baz"}] } - ], - "runPolicy": "Serial", + }, + "postCommit": {}, "source": { "type": "Git", "git": { @@ -27,16 +27,15 @@ "name": "cd-user-with-password" } }, - "strategy": { - "type": "JenkinsPipeline", - "jenkinsPipelineStrategy": { - "jenkinsfilePath": "Jenkinsfile", - "env": [{"name":"FOO_BAR","value":"baz"}] + "triggers": [ + { + "type": "Generic", + "generic": { + "secret": "s3cr3t", + "allowEnv": true + } } - }, - "output": {}, - "resources": {}, - "postCommit": {}, - "nodeSelector": {} + ], + "runPolicy": "Serial" } } diff --git a/jenkins/webhook-proxy/testdata/golden/build-pipeline-branch.json b/jenkins/webhook-proxy/testdata/golden/build-pipeline-branch.json index 9795b5c0f..99140315d 100644 --- a/jenkins/webhook-proxy/testdata/golden/build-pipeline-branch.json +++ b/jenkins/webhook-proxy/testdata/golden/build-pipeline-branch.json @@ -7,16 +7,16 @@ "resourceVersion": "42" }, "spec": { - "triggers": [ - { - "type": "Generic", - "generic": { - "secret": "s3cr3t", - "allowEnv": true - } + "output": {}, + "resources": {}, + "strategy": { + "type": "JenkinsPipeline", + "jenkinsPipelineStrategy": { + "jenkinsfilePath": "Jenkinsfile", + "env": [{"name":"FOO_BAR","value":"baz"}] } - ], - "runPolicy": "Serial", + }, + "postCommit": {}, "source": { "type": "Git", "git": { @@ -27,16 +27,15 @@ "name": "cd-user-with-password" } }, - "strategy": { - "type": "JenkinsPipeline", - "jenkinsPipelineStrategy": { - "jenkinsfilePath": "Jenkinsfile", - "env": [{"name":"FOO_BAR","value":"baz"}] + "triggers": [ + { + "type": "Generic", + "generic": { + "secret": "s3cr3t", + "allowEnv": true + } } - }, - "output": {}, - "resources": {}, - "postCommit": {}, - "nodeSelector": {} + ], + "runPolicy": "Serial" } } diff --git a/jenkins/webhook-proxy/testdata/golden/build-pipeline-jenkinsfilepath.json b/jenkins/webhook-proxy/testdata/golden/build-pipeline-jenkinsfilepath.json index 1a6ca3805..3cb7c4299 100644 --- a/jenkins/webhook-proxy/testdata/golden/build-pipeline-jenkinsfilepath.json +++ b/jenkins/webhook-proxy/testdata/golden/build-pipeline-jenkinsfilepath.json @@ -7,16 +7,16 @@ "resourceVersion": "42" }, "spec": { - "triggers": [ - { - "type": "Generic", - "generic": { - "secret": "s3cr3t", - "allowEnv": true - } + "output": {}, + "resources": {}, + "strategy": { + "type": "JenkinsPipeline", + "jenkinsPipelineStrategy": { + "jenkinsfilePath": "bar/Jenkinsfile", + "env": [{"name":"FOO_BAR","value":"baz"}] } - ], - "runPolicy": "Serial", + }, + "postCommit": {}, "source": { "type": "Git", "git": { @@ -27,16 +27,15 @@ "name": "cd-user-with-password" } }, - "strategy": { - "type": "JenkinsPipeline", - "jenkinsPipelineStrategy": { - "jenkinsfilePath": "bar/Jenkinsfile", - "env": [{"name":"FOO_BAR","value":"baz"}] + "triggers": [ + { + "type": "Generic", + "generic": { + "secret": "s3cr3t", + "allowEnv": true + } } - }, - "output": {}, - "resources": {}, - "postCommit": {}, - "nodeSelector": {} + ], + "runPolicy": "Serial" } } diff --git a/jenkins/webhook-proxy/testdata/golden/build-pipeline.json b/jenkins/webhook-proxy/testdata/golden/build-pipeline.json index e7b5c78de..33f5a4e0f 100644 --- a/jenkins/webhook-proxy/testdata/golden/build-pipeline.json +++ b/jenkins/webhook-proxy/testdata/golden/build-pipeline.json @@ -7,16 +7,16 @@ "resourceVersion": "0" }, "spec": { - "triggers": [ - { - "type": "Generic", - "generic": { - "secret": "s3cr3t", - "allowEnv": true - } + "output": {}, + "resources": {}, + "strategy": { + "type": "JenkinsPipeline", + "jenkinsPipelineStrategy": { + "jenkinsfilePath": "Jenkinsfile", + "env": [{"name":"FOO_BAR","value":"baz"}] } - ], - "runPolicy": "Serial", + }, + "postCommit": {}, "source": { "type": "Git", "git": { @@ -26,17 +26,16 @@ "sourceSecret": { "name": "cd-user-with-password" } - }, - "strategy": { - "type": "JenkinsPipeline", - "jenkinsPipelineStrategy": { - "jenkinsfilePath": "Jenkinsfile", - "env": [{"name":"FOO_BAR","value":"baz"}] + }, + "triggers": [ + { + "type": "Generic", + "generic": { + "secret": "s3cr3t", + "allowEnv": true + } } - }, - "output": {}, - "resources": {}, - "postCommit": {}, - "nodeSelector": {} + ], + "runPolicy": "Serial" } } diff --git a/jenkins/webhook-proxy/testdata/golden/foo-cd-pipeline.json b/jenkins/webhook-proxy/testdata/golden/foo-cd-pipeline.json index 6cdeb48be..8359cf265 100644 --- a/jenkins/webhook-proxy/testdata/golden/foo-cd-pipeline.json +++ b/jenkins/webhook-proxy/testdata/golden/foo-cd-pipeline.json @@ -7,16 +7,16 @@ "resourceVersion": "0" }, "spec": { - "triggers": [ - { - "type": "Generic", - "generic": { - "secret": "s3cr3t", - "allowEnv": true - } + "output": {}, + "resources": {}, + "strategy": { + "type": "JenkinsPipeline", + "jenkinsPipelineStrategy": { + "jenkinsfilePath": "Jenkinsfile", + "env": null } - ], - "runPolicy": "Serial", + }, + "postCommit": {}, "source": { "type": "Git", "git": { @@ -27,16 +27,15 @@ "name": "cd-user-with-password" } }, - "strategy": { - "type": "JenkinsPipeline", - "jenkinsPipelineStrategy": { - "jenkinsfilePath": "Jenkinsfile", - "env": null + "triggers": [ + { + "type": "Generic", + "generic": { + "secret": "s3cr3t", + "allowEnv": true + } } - }, - "output": {}, - "resources": {}, - "postCommit": {}, - "nodeSelector": {} + ], + "runPolicy": "Serial" } } diff --git a/jenkins/webhook-proxy/testdata/golden/pipeline.json b/jenkins/webhook-proxy/testdata/golden/pipeline.json index 4ecbbde14..5513ff8ab 100644 --- a/jenkins/webhook-proxy/testdata/golden/pipeline.json +++ b/jenkins/webhook-proxy/testdata/golden/pipeline.json @@ -7,16 +7,16 @@ "resourceVersion": "0" }, "spec": { - "triggers": [ - { - "type": "Generic", - "generic": { - "secret": "s3cr3t", - "allowEnv": true - } + "output": {}, + "resources": {}, + "strategy": { + "type": "JenkinsPipeline", + "jenkinsPipelineStrategy": { + "jenkinsfilePath": "foo/Jenkinsfile", + "env": [{"name":"FOO","value":"bar"}] } - ], - "runPolicy": "Serial", + }, + "postCommit": {}, "source": { "type": "Git", "git": { @@ -27,16 +27,15 @@ "name": "cd-user-with-password" } }, - "strategy": { - "type": "JenkinsPipeline", - "jenkinsPipelineStrategy": { - "jenkinsfilePath": "foo/Jenkinsfile", - "env": [{"name":"FOO","value":"bar"}] + "triggers": [ + { + "type": "Generic", + "generic": { + "secret": "s3cr3t", + "allowEnv": true + } } - }, - "output": {}, - "resources": {}, - "postCommit": {}, - "nodeSelector": {} + ], + "runPolicy": "Serial" } } diff --git a/jenkins/webhook-proxy/testdata/golden/prov-app-pipeline.json b/jenkins/webhook-proxy/testdata/golden/prov-app-pipeline.json index a665be275..3b6ac4cca 100644 --- a/jenkins/webhook-proxy/testdata/golden/prov-app-pipeline.json +++ b/jenkins/webhook-proxy/testdata/golden/prov-app-pipeline.json @@ -7,16 +7,16 @@ "resourceVersion": "0" }, "spec": { - "triggers": [ - { - "type": "Generic", - "generic": { - "secret": "s3cr3t", - "allowEnv": true - } + "output": {}, + "resources": {}, + "strategy": { + "type": "JenkinsPipeline", + "jenkinsPipelineStrategy": { + "jenkinsfilePath": "Jenkinsfile", + "env": null } - ], - "runPolicy": "Serial", + }, + "postCommit": {}, "source": { "type": "Git", "git": { @@ -27,16 +27,15 @@ "name": "cd-user-with-password" } }, - "strategy": { - "type": "JenkinsPipeline", - "jenkinsPipelineStrategy": { - "jenkinsfilePath": "Jenkinsfile", - "env": null + "triggers": [ + { + "type": "Generic", + "generic": { + "secret": "s3cr3t", + "allowEnv": true + } } - }, - "output": {}, - "resources": {}, - "postCommit": {}, - "nodeSelector": {} + ], + "runPolicy": "Serial" } } From 8f19d4e438b641c4bc6955d22b43ff377055d54e Mon Sep 17 00:00:00 2001 From: "Vazquez,Brais (IT EDP)" Date: Thu, 22 Aug 2024 09:14:52 +0200 Subject: [PATCH 06/12] remove space --- jenkins/webhook-proxy/testdata/golden/build-pipeline.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/jenkins/webhook-proxy/testdata/golden/build-pipeline.json b/jenkins/webhook-proxy/testdata/golden/build-pipeline.json index 33f5a4e0f..4054fcdc8 100644 --- a/jenkins/webhook-proxy/testdata/golden/build-pipeline.json +++ b/jenkins/webhook-proxy/testdata/golden/build-pipeline.json @@ -26,7 +26,7 @@ "sourceSecret": { "name": "cd-user-with-password" } - }, + }, "triggers": [ { "type": "Generic", From 38a2ad5c1ec886b152c44f87624c4325bc43a60d Mon Sep 17 00:00:00 2001 From: "Vazquez,Brais (IT EDP)" Date: Thu, 22 Aug 2024 09:17:56 +0200 Subject: [PATCH 07/12] Changelog --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index fb8c1eb4a..3137f9f61 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,7 @@ ### Added ### Changed +- Webhook Proxy maintenance ([#1298](https://github.com/opendevstack/ods-core/pull/1298)) ### Fixed From 2f61e2568e7415264a84b226cb59f3efa1639973 Mon Sep 17 00:00:00 2001 From: "Vazquez,Brais (IT EDP)" Date: Fri, 30 Aug 2024 14:46:52 +0200 Subject: [PATCH 08/12] restore templates --- jenkins/webhook-proxy/pipeline.json.tmpl | 39 ++++++++++--------- .../golden/build-component-pipeline.json | 39 ++++++++++--------- .../golden/build-pipeline-branch.json | 39 ++++++++++--------- .../build-pipeline-jenkinsfilepath.json | 39 ++++++++++--------- .../testdata/golden/build-pipeline.json | 39 ++++++++++--------- .../testdata/golden/foo-cd-pipeline.json | 39 ++++++++++--------- .../testdata/golden/pipeline.json | 39 ++++++++++--------- .../testdata/golden/prov-app-pipeline.json | 39 ++++++++++--------- 8 files changed, 160 insertions(+), 152 deletions(-) diff --git a/jenkins/webhook-proxy/pipeline.json.tmpl b/jenkins/webhook-proxy/pipeline.json.tmpl index 03d111e98..eb600be2c 100644 --- a/jenkins/webhook-proxy/pipeline.json.tmpl +++ b/jenkins/webhook-proxy/pipeline.json.tmpl @@ -7,16 +7,16 @@ "resourceVersion": "{{.ResourceVersion}}" }, "spec": { - "output": {}, - "resources": {}, - "strategy": { - "type": "JenkinsPipeline", - "jenkinsPipelineStrategy": { - "jenkinsfilePath": "{{.JenkinsfilePath}}", - "env": {{.Env}} + "triggers": [ + { + "type": "Generic", + "generic": { + "secret": "{{.TriggerSecret}}", + "allowEnv": true + } } - }, - "postCommit": {}, + ], + "runPolicy": "Serial", "source": { "type": "Git", "git": { @@ -27,15 +27,16 @@ "name": "cd-user-with-password" } }, - "triggers": [ - { - "type": "Generic", - "generic": { - "secret": "{{.TriggerSecret}}", - "allowEnv": true - } + "strategy": { + "type": "JenkinsPipeline", + "jenkinsPipelineStrategy": { + "jenkinsfilePath": "{{.JenkinsfilePath}}", + "env": {{.Env}} } - ], - "runPolicy": "Serial" + }, + "output": {}, + "resources": {}, + "postCommit": {}, + "nodeSelector": {} } -} +} \ No newline at end of file diff --git a/jenkins/webhook-proxy/testdata/golden/build-component-pipeline.json b/jenkins/webhook-proxy/testdata/golden/build-component-pipeline.json index d8ecfff8b..1e25efcba 100644 --- a/jenkins/webhook-proxy/testdata/golden/build-component-pipeline.json +++ b/jenkins/webhook-proxy/testdata/golden/build-component-pipeline.json @@ -7,16 +7,16 @@ "resourceVersion": "0" }, "spec": { - "output": {}, - "resources": {}, - "strategy": { - "type": "JenkinsPipeline", - "jenkinsPipelineStrategy": { - "jenkinsfilePath": "Jenkinsfile", - "env": [{"name":"FOO_BAR","value":"baz"}] + "triggers": [ + { + "type": "Generic", + "generic": { + "secret": "s3cr3t", + "allowEnv": true + } } - }, - "postCommit": {}, + ], + "runPolicy": "Serial", "source": { "type": "Git", "git": { @@ -27,15 +27,16 @@ "name": "cd-user-with-password" } }, - "triggers": [ - { - "type": "Generic", - "generic": { - "secret": "s3cr3t", - "allowEnv": true - } + "strategy": { + "type": "JenkinsPipeline", + "jenkinsPipelineStrategy": { + "jenkinsfilePath": "Jenkinsfile", + "env": [{"name":"FOO_BAR","value":"baz"}] } - ], - "runPolicy": "Serial" + }, + "output": {}, + "resources": {}, + "postCommit": {}, + "nodeSelector": {} } -} +} \ No newline at end of file diff --git a/jenkins/webhook-proxy/testdata/golden/build-pipeline-branch.json b/jenkins/webhook-proxy/testdata/golden/build-pipeline-branch.json index 99140315d..4804ed4e4 100644 --- a/jenkins/webhook-proxy/testdata/golden/build-pipeline-branch.json +++ b/jenkins/webhook-proxy/testdata/golden/build-pipeline-branch.json @@ -7,16 +7,16 @@ "resourceVersion": "42" }, "spec": { - "output": {}, - "resources": {}, - "strategy": { - "type": "JenkinsPipeline", - "jenkinsPipelineStrategy": { - "jenkinsfilePath": "Jenkinsfile", - "env": [{"name":"FOO_BAR","value":"baz"}] + "triggers": [ + { + "type": "Generic", + "generic": { + "secret": "s3cr3t", + "allowEnv": true + } } - }, - "postCommit": {}, + ], + "runPolicy": "Serial", "source": { "type": "Git", "git": { @@ -27,15 +27,16 @@ "name": "cd-user-with-password" } }, - "triggers": [ - { - "type": "Generic", - "generic": { - "secret": "s3cr3t", - "allowEnv": true - } + "strategy": { + "type": "JenkinsPipeline", + "jenkinsPipelineStrategy": { + "jenkinsfilePath": "Jenkinsfile", + "env": [{"name":"FOO_BAR","value":"baz"}] } - ], - "runPolicy": "Serial" + }, + "output": {}, + "resources": {}, + "postCommit": {}, + "nodeSelector": {} } -} +} \ No newline at end of file diff --git a/jenkins/webhook-proxy/testdata/golden/build-pipeline-jenkinsfilepath.json b/jenkins/webhook-proxy/testdata/golden/build-pipeline-jenkinsfilepath.json index 3cb7c4299..6d490c64d 100644 --- a/jenkins/webhook-proxy/testdata/golden/build-pipeline-jenkinsfilepath.json +++ b/jenkins/webhook-proxy/testdata/golden/build-pipeline-jenkinsfilepath.json @@ -7,16 +7,16 @@ "resourceVersion": "42" }, "spec": { - "output": {}, - "resources": {}, - "strategy": { - "type": "JenkinsPipeline", - "jenkinsPipelineStrategy": { - "jenkinsfilePath": "bar/Jenkinsfile", - "env": [{"name":"FOO_BAR","value":"baz"}] + "triggers": [ + { + "type": "Generic", + "generic": { + "secret": "s3cr3t", + "allowEnv": true + } } - }, - "postCommit": {}, + ], + "runPolicy": "Serial", "source": { "type": "Git", "git": { @@ -27,15 +27,16 @@ "name": "cd-user-with-password" } }, - "triggers": [ - { - "type": "Generic", - "generic": { - "secret": "s3cr3t", - "allowEnv": true - } + "strategy": { + "type": "JenkinsPipeline", + "jenkinsPipelineStrategy": { + "jenkinsfilePath": "bar/Jenkinsfile", + "env": [{"name":"FOO_BAR","value":"baz"}] } - ], - "runPolicy": "Serial" + }, + "output": {}, + "resources": {}, + "postCommit": {}, + "nodeSelector": {} } -} +} \ No newline at end of file diff --git a/jenkins/webhook-proxy/testdata/golden/build-pipeline.json b/jenkins/webhook-proxy/testdata/golden/build-pipeline.json index 4054fcdc8..85b410813 100644 --- a/jenkins/webhook-proxy/testdata/golden/build-pipeline.json +++ b/jenkins/webhook-proxy/testdata/golden/build-pipeline.json @@ -7,16 +7,16 @@ "resourceVersion": "0" }, "spec": { - "output": {}, - "resources": {}, - "strategy": { - "type": "JenkinsPipeline", - "jenkinsPipelineStrategy": { - "jenkinsfilePath": "Jenkinsfile", - "env": [{"name":"FOO_BAR","value":"baz"}] + "triggers": [ + { + "type": "Generic", + "generic": { + "secret": "s3cr3t", + "allowEnv": true + } } - }, - "postCommit": {}, + ], + "runPolicy": "Serial", "source": { "type": "Git", "git": { @@ -27,15 +27,16 @@ "name": "cd-user-with-password" } }, - "triggers": [ - { - "type": "Generic", - "generic": { - "secret": "s3cr3t", - "allowEnv": true - } + "strategy": { + "type": "JenkinsPipeline", + "jenkinsPipelineStrategy": { + "jenkinsfilePath": "Jenkinsfile", + "env": [{"name":"FOO_BAR","value":"baz"}] } - ], - "runPolicy": "Serial" + }, + "output": {}, + "resources": {}, + "postCommit": {}, + "nodeSelector": {} } -} +} \ No newline at end of file diff --git a/jenkins/webhook-proxy/testdata/golden/foo-cd-pipeline.json b/jenkins/webhook-proxy/testdata/golden/foo-cd-pipeline.json index 8359cf265..482d742b1 100644 --- a/jenkins/webhook-proxy/testdata/golden/foo-cd-pipeline.json +++ b/jenkins/webhook-proxy/testdata/golden/foo-cd-pipeline.json @@ -7,16 +7,16 @@ "resourceVersion": "0" }, "spec": { - "output": {}, - "resources": {}, - "strategy": { - "type": "JenkinsPipeline", - "jenkinsPipelineStrategy": { - "jenkinsfilePath": "Jenkinsfile", - "env": null + "triggers": [ + { + "type": "Generic", + "generic": { + "secret": "s3cr3t", + "allowEnv": true + } } - }, - "postCommit": {}, + ], + "runPolicy": "Serial", "source": { "type": "Git", "git": { @@ -27,15 +27,16 @@ "name": "cd-user-with-password" } }, - "triggers": [ - { - "type": "Generic", - "generic": { - "secret": "s3cr3t", - "allowEnv": true - } + "strategy": { + "type": "JenkinsPipeline", + "jenkinsPipelineStrategy": { + "jenkinsfilePath": "Jenkinsfile", + "env": null } - ], - "runPolicy": "Serial" + }, + "output": {}, + "resources": {}, + "postCommit": {}, + "nodeSelector": {} } -} +} \ No newline at end of file diff --git a/jenkins/webhook-proxy/testdata/golden/pipeline.json b/jenkins/webhook-proxy/testdata/golden/pipeline.json index 5513ff8ab..bd933b636 100644 --- a/jenkins/webhook-proxy/testdata/golden/pipeline.json +++ b/jenkins/webhook-proxy/testdata/golden/pipeline.json @@ -7,16 +7,16 @@ "resourceVersion": "0" }, "spec": { - "output": {}, - "resources": {}, - "strategy": { - "type": "JenkinsPipeline", - "jenkinsPipelineStrategy": { - "jenkinsfilePath": "foo/Jenkinsfile", - "env": [{"name":"FOO","value":"bar"}] + "triggers": [ + { + "type": "Generic", + "generic": { + "secret": "s3cr3t", + "allowEnv": true + } } - }, - "postCommit": {}, + ], + "runPolicy": "Serial", "source": { "type": "Git", "git": { @@ -27,15 +27,16 @@ "name": "cd-user-with-password" } }, - "triggers": [ - { - "type": "Generic", - "generic": { - "secret": "s3cr3t", - "allowEnv": true - } + "strategy": { + "type": "JenkinsPipeline", + "jenkinsPipelineStrategy": { + "jenkinsfilePath": "foo/Jenkinsfile", + "env": [{"name":"FOO","value":"bar"}] } - ], - "runPolicy": "Serial" + }, + "output": {}, + "resources": {}, + "postCommit": {}, + "nodeSelector": {} } -} +} \ No newline at end of file diff --git a/jenkins/webhook-proxy/testdata/golden/prov-app-pipeline.json b/jenkins/webhook-proxy/testdata/golden/prov-app-pipeline.json index 3b6ac4cca..64b01fafa 100644 --- a/jenkins/webhook-proxy/testdata/golden/prov-app-pipeline.json +++ b/jenkins/webhook-proxy/testdata/golden/prov-app-pipeline.json @@ -7,16 +7,16 @@ "resourceVersion": "0" }, "spec": { - "output": {}, - "resources": {}, - "strategy": { - "type": "JenkinsPipeline", - "jenkinsPipelineStrategy": { - "jenkinsfilePath": "Jenkinsfile", - "env": null + "triggers": [ + { + "type": "Generic", + "generic": { + "secret": "s3cr3t", + "allowEnv": true + } } - }, - "postCommit": {}, + ], + "runPolicy": "Serial", "source": { "type": "Git", "git": { @@ -27,15 +27,16 @@ "name": "cd-user-with-password" } }, - "triggers": [ - { - "type": "Generic", - "generic": { - "secret": "s3cr3t", - "allowEnv": true - } + "strategy": { + "type": "JenkinsPipeline", + "jenkinsPipelineStrategy": { + "jenkinsfilePath": "Jenkinsfile", + "env": null } - ], - "runPolicy": "Serial" + }, + "output": {}, + "resources": {}, + "postCommit": {}, + "nodeSelector": {} } -} +} \ No newline at end of file From 2147cac533fd99f16a880ae54bd30018eab2be6e Mon Sep 17 00:00:00 2001 From: "Vazquez,Brais (IT EDP)" Date: Fri, 30 Aug 2024 14:48:15 +0200 Subject: [PATCH 09/12] add endline --- jenkins/webhook-proxy/pipeline.json.tmpl | 2 +- .../webhook-proxy/testdata/golden/build-component-pipeline.json | 2 +- .../webhook-proxy/testdata/golden/build-pipeline-branch.json | 2 +- .../testdata/golden/build-pipeline-jenkinsfilepath.json | 2 +- jenkins/webhook-proxy/testdata/golden/build-pipeline.json | 2 +- jenkins/webhook-proxy/testdata/golden/foo-cd-pipeline.json | 2 +- jenkins/webhook-proxy/testdata/golden/pipeline.json | 2 +- jenkins/webhook-proxy/testdata/golden/prov-app-pipeline.json | 2 +- 8 files changed, 8 insertions(+), 8 deletions(-) diff --git a/jenkins/webhook-proxy/pipeline.json.tmpl b/jenkins/webhook-proxy/pipeline.json.tmpl index eb600be2c..e1097b581 100644 --- a/jenkins/webhook-proxy/pipeline.json.tmpl +++ b/jenkins/webhook-proxy/pipeline.json.tmpl @@ -39,4 +39,4 @@ "postCommit": {}, "nodeSelector": {} } -} \ No newline at end of file +} diff --git a/jenkins/webhook-proxy/testdata/golden/build-component-pipeline.json b/jenkins/webhook-proxy/testdata/golden/build-component-pipeline.json index 1e25efcba..e762edb3b 100644 --- a/jenkins/webhook-proxy/testdata/golden/build-component-pipeline.json +++ b/jenkins/webhook-proxy/testdata/golden/build-component-pipeline.json @@ -39,4 +39,4 @@ "postCommit": {}, "nodeSelector": {} } -} \ No newline at end of file +} diff --git a/jenkins/webhook-proxy/testdata/golden/build-pipeline-branch.json b/jenkins/webhook-proxy/testdata/golden/build-pipeline-branch.json index 4804ed4e4..9795b5c0f 100644 --- a/jenkins/webhook-proxy/testdata/golden/build-pipeline-branch.json +++ b/jenkins/webhook-proxy/testdata/golden/build-pipeline-branch.json @@ -39,4 +39,4 @@ "postCommit": {}, "nodeSelector": {} } -} \ No newline at end of file +} diff --git a/jenkins/webhook-proxy/testdata/golden/build-pipeline-jenkinsfilepath.json b/jenkins/webhook-proxy/testdata/golden/build-pipeline-jenkinsfilepath.json index 6d490c64d..1a6ca3805 100644 --- a/jenkins/webhook-proxy/testdata/golden/build-pipeline-jenkinsfilepath.json +++ b/jenkins/webhook-proxy/testdata/golden/build-pipeline-jenkinsfilepath.json @@ -39,4 +39,4 @@ "postCommit": {}, "nodeSelector": {} } -} \ No newline at end of file +} diff --git a/jenkins/webhook-proxy/testdata/golden/build-pipeline.json b/jenkins/webhook-proxy/testdata/golden/build-pipeline.json index 85b410813..e7b5c78de 100644 --- a/jenkins/webhook-proxy/testdata/golden/build-pipeline.json +++ b/jenkins/webhook-proxy/testdata/golden/build-pipeline.json @@ -39,4 +39,4 @@ "postCommit": {}, "nodeSelector": {} } -} \ No newline at end of file +} diff --git a/jenkins/webhook-proxy/testdata/golden/foo-cd-pipeline.json b/jenkins/webhook-proxy/testdata/golden/foo-cd-pipeline.json index 482d742b1..6cdeb48be 100644 --- a/jenkins/webhook-proxy/testdata/golden/foo-cd-pipeline.json +++ b/jenkins/webhook-proxy/testdata/golden/foo-cd-pipeline.json @@ -39,4 +39,4 @@ "postCommit": {}, "nodeSelector": {} } -} \ No newline at end of file +} diff --git a/jenkins/webhook-proxy/testdata/golden/pipeline.json b/jenkins/webhook-proxy/testdata/golden/pipeline.json index bd933b636..4ecbbde14 100644 --- a/jenkins/webhook-proxy/testdata/golden/pipeline.json +++ b/jenkins/webhook-proxy/testdata/golden/pipeline.json @@ -39,4 +39,4 @@ "postCommit": {}, "nodeSelector": {} } -} \ No newline at end of file +} diff --git a/jenkins/webhook-proxy/testdata/golden/prov-app-pipeline.json b/jenkins/webhook-proxy/testdata/golden/prov-app-pipeline.json index 64b01fafa..a665be275 100644 --- a/jenkins/webhook-proxy/testdata/golden/prov-app-pipeline.json +++ b/jenkins/webhook-proxy/testdata/golden/prov-app-pipeline.json @@ -39,4 +39,4 @@ "postCommit": {}, "nodeSelector": {} } -} \ No newline at end of file +} From ec15e0feb0ea9c5fd840efa8278a1a2548741fc7 Mon Sep 17 00:00:00 2001 From: "Vazquez,Brais (IT EDP)" Date: Fri, 30 Aug 2024 15:03:20 +0200 Subject: [PATCH 10/12] update packages and clean cache --- jenkins/webhook-proxy/Dockerfile | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/jenkins/webhook-proxy/Dockerfile b/jenkins/webhook-proxy/Dockerfile index 482824f06..ce6ea5055 100644 --- a/jenkins/webhook-proxy/Dockerfile +++ b/jenkins/webhook-proxy/Dockerfile @@ -7,7 +7,10 @@ FROM golang:1.23-alpine ARG allowedExternalProjects=opendevstack ENV ALLOWED_EXTERNAL_PROJECTS=$allowedExternalProjects -RUN apk add --no-cache ca-certificates && \ +RUN apk update && \ + apk add -i ca-certificates && \ + apk -i upgrade && \ + apk cache clean && \ mkdir -p /home/webhook-proxy && \ chgrp -R 0 /home/webhook-proxy && \ chmod g+w /home/webhook-proxy From 510de19c4149d5b93d4b34748078333c407bd9bf Mon Sep 17 00:00:00 2001 From: "Vazquez,Brais (IT EDP)" Date: Fri, 30 Aug 2024 15:11:29 +0200 Subject: [PATCH 11/12] Check in forward event --- jenkins/webhook-proxy/main.go | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/jenkins/webhook-proxy/main.go b/jenkins/webhook-proxy/main.go index 9af54380f..49615bc4b 100644 --- a/jenkins/webhook-proxy/main.go +++ b/jenkins/webhook-proxy/main.go @@ -593,6 +593,10 @@ func (c *ocClient) Forward(e *Event, triggerSecret string) (int, []byte, error) e.Pipeline, triggerSecret, ) + + c.CheckJenkinsAvailability(e) + c.CheckDocGenAvailability(e) + log.Println(e.RequestID, "Forwarding to", url) p := struct { @@ -626,9 +630,6 @@ func (c *ocClient) CreateOrUpdatePipeline(exists bool, tmpl *template.Template, return 500, err } - c.CheckJenkinsAvailability(e) - c.CheckDocGenAvailability(e) - url := fmt.Sprintf( "%s/namespaces/%s/buildconfigs", c.OpenShiftAPIBaseURL, @@ -670,9 +671,6 @@ func (c *ocClient) DeletePipeline(e *Event) error { e.Pipeline, ) - c.CheckJenkinsAvailability(e) - c.CheckDocGenAvailability(e) - req, _ := http.NewRequest( "DELETE", url, From a24f63e262e9cf47a94dd603e7b4295cf2a8eee0 Mon Sep 17 00:00:00 2001 From: brais <26645694+braisvq1996@users.noreply.github.com> Date: Mon, 2 Sep 2024 08:53:25 +0200 Subject: [PATCH 12/12] install necesary packages first Co-authored-by: gerardcl --- jenkins/webhook-proxy/Dockerfile | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/jenkins/webhook-proxy/Dockerfile b/jenkins/webhook-proxy/Dockerfile index ce6ea5055..762446d32 100644 --- a/jenkins/webhook-proxy/Dockerfile +++ b/jenkins/webhook-proxy/Dockerfile @@ -7,8 +7,8 @@ FROM golang:1.23-alpine ARG allowedExternalProjects=opendevstack ENV ALLOWED_EXTERNAL_PROJECTS=$allowedExternalProjects -RUN apk update && \ - apk add -i ca-certificates && \ +RUN apk add -i ca-certificates && \ + apk update && \ apk -i upgrade && \ apk cache clean && \ mkdir -p /home/webhook-proxy && \