From 7d5b802d1e3e86b373aa1e3fc16245221cca4ff8 Mon Sep 17 00:00:00 2001 From: nihussmann Date: Fri, 20 Sep 2024 14:24:58 +0200 Subject: [PATCH 1/6] disable yamllint and updating docs --- CHANGELOG.md | 3 +++ README.md | 8 ++++---- .../gitopsbuildlib/DeployViaGitopsTest.groovy | 16 +++++++++------- vars/deployViaGitops.groovy | 3 ++- 4 files changed, 18 insertions(+), 12 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 69e62ed..bf659d3 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## [Unreleased] +### Changed +- Disable yamllint image due to image is not longer maintained + ## [0.6.0](https://github.com/cloudogu/gitops-build-lib/releases/tag/0.6.0) - 2024-08-26 ### Changed diff --git a/README.md b/README.md index 05c45c8..d6e68a3 100644 --- a/README.md +++ b/README.md @@ -774,10 +774,10 @@ class GitHub extends SCMProvider { ## Validators The library itself provides three validators `yamllint`, `kubeval` and `helmKubeval` to validate the generated resources. -You can disable the built-in operators and/or add your own. +You can enable the built-in operators and/or add your own. The operators are processed sequentially in no particular order. -Example: Disable all built-ins and add a custom validator. +Example: Enable `yamllint`, `kubeval` and add a custom validator. ```groovy node { @@ -787,10 +787,10 @@ node { // ... validators : [ yamllint: [ - enabled : false, + enabled : enable, ], kubeval: [ - enabled : false, + enabled : enable, ], myVali: [ validator: new MyValidator(this), diff --git a/test/com/cloudogu/gitopsbuildlib/DeployViaGitopsTest.groovy b/test/com/cloudogu/gitopsbuildlib/DeployViaGitopsTest.groovy index 0db5258..be467ad 100644 --- a/test/com/cloudogu/gitopsbuildlib/DeployViaGitopsTest.groovy +++ b/test/com/cloudogu/gitopsbuildlib/DeployViaGitopsTest.groovy @@ -59,7 +59,7 @@ class DeployViaGitopsTest extends BasePipelineTest { validators : [ kubeval : [ validator: new Kubeval(deployViaGitops), - enabled : true, + enabled : false, config : [ // We use the helm image (that also contains kubeval plugin) to speed up builds by allowing to reuse image image : 'ghcr.io/cloudogu/helm:3.4.1-1', @@ -68,7 +68,7 @@ class DeployViaGitopsTest extends BasePipelineTest { ], yamllint: [ validator: new Yamllint(deployViaGitops), - enabled : true, + enabled : false, config : [ image : 'cytopia/yamllint:1.25-0.9', // Default to relaxed profile because it's feasible for mere mortalYAML programmers. @@ -221,10 +221,10 @@ spec: @Test - void 'default validator can be disabled'() { + void 'default validator can be enabled'() { deployViaGitops.metaClass.validateConfig = { Map actualGitOpsConfig -> - assertThat(actualGitOpsConfig.validators.kubeval.enabled).isEqualTo(false) + assertThat(actualGitOpsConfig.validators.kubeval.enabled).isEqualTo(true) assertThat(actualGitOpsConfig.validators.kubeval.validator).isNotNull() assertThat(actualGitOpsConfig.validators.yamllint.enabled).isEqualTo(true) } @@ -233,7 +233,10 @@ spec: deployViaGitops([ validators: [ kubeval: [ - enabled: false + enabled: true + ], + yamllint: [ + enabled: true ] ] ]) @@ -244,8 +247,7 @@ spec: deployViaGitops.metaClass.validateConfig = { Map actualGitOpsConfig -> assertThat(actualGitOpsConfig.validators.myVali.config.a).isEqualTo('b') - assertThat(actualGitOpsConfig.validators.yamllint.enabled).isEqualTo(true) - assertThat(actualGitOpsConfig.validators.yamllint.enabled).isEqualTo(true) + assertThat(actualGitOpsConfig.validators.myVali.enabled).isEqualTo(true) } deployViaGitops.metaClass.deploy = {Map actualGitOpsConfig ->} // Stop after validation diff --git a/vars/deployViaGitops.groovy b/vars/deployViaGitops.groovy index a30b490..0aaa38b 100644 --- a/vars/deployViaGitops.groovy +++ b/vars/deployViaGitops.groovy @@ -78,7 +78,8 @@ Map createDefaultConfig(String k8sVersion) { ], yamllint : [ validator: new Yamllint(this), - enabled : true, + //disabled due to image is not longer maintained + enabled : false, config : [ imageRef : 'yamllint', // Default to relaxed profile because it's feasible for mere mortalYAML programmers. From 7f1c0df59246cce4fa0698360d525fdcdb94bc1b Mon Sep 17 00:00:00 2001 From: nihussmann Date: Fri, 20 Sep 2024 13:40:19 +0200 Subject: [PATCH 2/6] adding welcome message and printing configs. --- CHANGELOG.md | 3 +++ vars/deployViaGitops.groovy | 22 ++++++++++++++++++++++ 2 files changed, 25 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index bf659d3..e9cb897 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## [Unreleased] +### Added +- Add welcome message and print configs at application start + ### Changed - Disable yamllint image due to image is not longer maintained diff --git a/vars/deployViaGitops.groovy b/vars/deployViaGitops.groovy index 0aaa38b..6fb9303 100644 --- a/vars/deployViaGitops.groovy +++ b/vars/deployViaGitops.groovy @@ -100,6 +100,7 @@ void call(Map gitopsConfig) { // Merge default config with the one passed as parameter gitopsConfig = mergeMaps(createDefaultConfig(gitopsConfig.k8sVersion as String), gitopsConfig) if (validateConfig(gitopsConfig)) { + printWelcomeAndConfigs(gitopsConfig) cesBuildLib = initCesBuildLib(gitopsConfig.cesBuildLibRepo, gitopsConfig.cesBuildLibVersion, gitopsConfig.cesBuildLibCredentialsId) deploy(gitopsConfig) } @@ -343,6 +344,27 @@ protected String createBuildDescription(String pushedChanges) { return description } +private printWelcomeAndConfigs(Map gitopsConfig){ + + print(""" +################################################################################################################ + + _ _ _ _ _ _ _ _ _ + (_) | | | (_) | | | | (_) | + __ _ _| |_ ___ _ __ ___ ______| |__ _ _ _| | __| |______| |_| |__ + / _` | | __/ _ \\| '_ \\/ __|______| '_ \\| | | | | |/ _` |______| | | '_ \\ + | (_| | | || (_) | |_) \\__ \\ | |_) | |_| | | | (_| | | | | |_) | + \\__, |_|\\__\\___/| .__/|___/ |_.__/ \\__,_|_|_|\\__,_| |_|_|_.__/ + __/ | | | + |___/ |_| + + config: +${gitopsConfig.collect { key, value -> " $key: $value" }.join("\n")} + +################################################################################################################ +""") +} + def cesBuildLib Deployment deployment SCMProvider provider From 36a80310aa2563a1b891d5e89c2a5cb67be40409 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Niklas=20Hu=C3=9Fmann?= Date: Mon, 7 Oct 2024 14:22:09 +0200 Subject: [PATCH 3/6] adding support for additional docker run args in pipeline --- CHANGELOG.md | 1 + README.md | 4 ++++ src/com/cloudogu/gitopsbuildlib/docker/DockerWrapper.groovy | 1 + 3 files changed, 6 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index e9cb897..a36fc71 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -8,6 +8,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## [Unreleased] ### Added +- Add additional docker runs args support - Add welcome message and print configs at application start ### Changed diff --git a/README.md b/README.md index d6e68a3..693c13e 100644 --- a/README.md +++ b/README.md @@ -383,6 +383,10 @@ def gitopsConfig = [ ] ``` +If you should need to add addition arguments to `docker run` you can do so globally by setting +`ADDITIONAL_DOCKER_RUN_ARGS` as global properties at `https://your-jenkins/manage/configure#global-properties`. +This can be used to globally fix certain bugs in Jenkins agents or their docker config. + ## Stages The GitOps-build-lib supports builds on multiple stages. A stage is defined by a name and contains a namespace (used to generate the resources) and a deployment-flag: diff --git a/src/com/cloudogu/gitopsbuildlib/docker/DockerWrapper.groovy b/src/com/cloudogu/gitopsbuildlib/docker/DockerWrapper.groovy index 8b3694f..27b4ef8 100644 --- a/src/com/cloudogu/gitopsbuildlib/docker/DockerWrapper.groovy +++ b/src/com/cloudogu/gitopsbuildlib/docker/DockerWrapper.groovy @@ -34,6 +34,7 @@ class DockerWrapper { script.docker.image(image).inside( // Allow accessing WORKSPACE even when we are in a child dir (using "dir() {}") "${script.pwd().equals(script.env.WORKSPACE) ? '' : "-v ${script.env.WORKSPACE}:${script.env.WORKSPACE} "}" + + "${script.env.ADDITIONAL_DOCKER_RUN_ARGS ? " ${script.env.ADDITIONAL_DOCKER_RUN_ARGS} " : ''}" + // Avoid: "ERROR: The container started but didn't run the expected command" '--entrypoint=""' ) { From 6d34750009ba895cdd017e10513f49442ea55864 Mon Sep 17 00:00:00 2001 From: nihussmann Date: Fri, 20 Sep 2024 15:34:04 +0200 Subject: [PATCH 4/6] updating 3rd party dependencies --- CHANGELOG.md | 1 + vars/deployViaGitops.groovy | 11 ++++++----- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index a36fc71..295143e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -13,6 +13,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ### Changed - Disable yamllint image due to image is not longer maintained +- Update k8s, helm and yamllint ## [0.6.0](https://github.com/cloudogu/gitops-build-lib/releases/tag/0.6.0) - 2024-08-26 diff --git a/vars/deployViaGitops.groovy b/vars/deployViaGitops.groovy index 6fb9303..acb279c 100644 --- a/vars/deployViaGitops.groovy +++ b/vars/deployViaGitops.groovy @@ -22,8 +22,9 @@ List getMandatoryFields() { Map createDefaultConfig(String k8sVersion) { if (k8sVersion == null || k8sVersion == ""){ - k8sVersion = "1.24.8" + k8sVersion = "1.29.8" } + String helmVersion = '3.16.1-1' return [ k8sVersion : "${k8sVersion}", @@ -34,7 +35,7 @@ Map createDefaultConfig(String k8sVersion) { buildImages : [ helm: [ credentialsId: '', - image: 'ghcr.io/cloudogu/helm:3.11.1-2' + image: "ghcr.io/cloudogu/helm:${helmVersion}" ], kubectl: [ credentialsId: '', @@ -43,15 +44,15 @@ Map createDefaultConfig(String k8sVersion) { // We use the helm image (that also contains kubeval plugin) to speed up builds by allowing to reuse image kubeval: [ credentialsId: '', - image: 'ghcr.io/cloudogu/helm:3.5.4-1' + image: "ghcr.io/cloudogu/helm:${helmVersion}" ], helmKubeval: [ credentialsId: '', - image: 'ghcr.io/cloudogu/helm:3.5.4-1' + image: "ghcr.io/cloudogu/helm:${helmVersion}" ], yamllint: [ credentialsId: '', - image: 'cytopia/yamllint:1.25-0.9' + image: 'cytopia/yamllint:1.26-0.9' ] ], deployments : [ From 9a3a6294b9a51ddf892e4b15347bed4d5811aedc Mon Sep 17 00:00:00 2001 From: Johannes Schnatterer Date: Mon, 14 Oct 2024 13:59:22 +0200 Subject: [PATCH 5/6] Upgrade ces-build-lib This fixes retry on git push for example. See cloudogu/ces-build-lib@fd67015. --- vars/deployViaGitops.groovy | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/vars/deployViaGitops.groovy b/vars/deployViaGitops.groovy index acb279c..607ff87 100644 --- a/vars/deployViaGitops.groovy +++ b/vars/deployViaGitops.groovy @@ -29,7 +29,7 @@ Map createDefaultConfig(String k8sVersion) { return [ k8sVersion : "${k8sVersion}", cesBuildLibRepo : 'https://github.com/cloudogu/ces-build-lib', - cesBuildLibVersion : '1.62.0', + cesBuildLibVersion : '2.5.0', cesBuildLibCredentialsId: '', mainBranch : 'main', buildImages : [ From 0dfae357ecea5085ab94cb17a7a59a2a9d4d25ba Mon Sep 17 00:00:00 2001 From: Johannes Schnatterer Date: Mon, 14 Oct 2024 14:21:01 +0200 Subject: [PATCH 6/6] Release 0.7.0 --- CHANGELOG.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 295143e..6c31b30 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## [Unreleased] +## [0.7.0](https://github.com/cloudogu/gitops-build-lib/releases/tag/0.7.0) - 2024-10-14 + ### Added - Add additional docker runs args support - Add welcome message and print configs at application start