From f62ec53e82975037f411a25b21d0b18dd34bf00e Mon Sep 17 00:00:00 2001 From: Stephen Boyd Date: Tue, 14 May 2024 17:35:43 -0700 Subject: [PATCH] githuborg: Pull build strategies into parent xml Either Jenkins seems to have made an update where the build strategy properties have been moved, or this never worked. When generating the XML using the Jenkins UI, the build strategies appear at the top level. Prior to this patch, when using jjb, the configuration was completely ignored, causing some charming build storms. Breaking change: The legacy github org output is no longer correct. Change-Id: Idb5bf025f9bcbf9d9588465713ea5a29ff069e6d --- jenkins_jobs/modules/project_githuborg.py | 10 +- tests/githuborg/fixtures/github-org-full.xml | 134 +++++----- .../fixtures/github-org-legacy-nc.xml | 229 ------------------ .../fixtures/github-org-legacy-nc.yaml | 101 -------- 4 files changed, 74 insertions(+), 400 deletions(-) delete mode 100644 tests/githuborg/fixtures/github-org-legacy-nc.xml delete mode 100644 tests/githuborg/fixtures/github-org-legacy-nc.yaml diff --git a/jenkins_jobs/modules/project_githuborg.py b/jenkins_jobs/modules/project_githuborg.py index fb8f2fa14..1ef6fbdae 100644 --- a/jenkins_jobs/modules/project_githuborg.py +++ b/jenkins_jobs/modules/project_githuborg.py @@ -194,6 +194,13 @@ class GithubOrganization(jenkins_jobs.modules.base.Base): ) helpers.convert_mapping_to_xml(factory, data, fopts_map, fail_required=False) + #################### + # Build Strategies # + #################### + + if data.get("github-org").get("build-strategies", None): + multibranch.build_strategies(xml_parent, data.get("github-org")) + return xml_parent @@ -403,9 +410,6 @@ def github_org(xml_parent, data): if data.get("property-strategies", None): multibranch.property_strategies(xml_parent, data) - if data.get("build-strategies", None): - multibranch.build_strategies(xml_parent, data) - multibranch.add_notification_context_trait(traits, data) # handle the default git extensions like: diff --git a/tests/githuborg/fixtures/github-org-full.xml b/tests/githuborg/fixtures/github-org-full.xml index 72194a96f..90c8f5173 100644 --- a/tests/githuborg/fixtures/github-org-full.xml +++ b/tests/githuborg/fixtures/github-org-full.xml @@ -155,73 +155,6 @@ - - - - - - - - - - - false - - - -1 - -1 - - - - - 86400000 - 604800000 - - - -1 - -1 - - - true - - - false - - - - - - - test - true - - - test.*$ - true - - - testinclude - testexclude - - - - - - - - false - - - ^.*$ - false - - - * - - - - - @@ -229,4 +162,71 @@ Jenkinsfile + + + + + + + + + + + false + + + -1 + -1 + + + + + 86400000 + 604800000 + + + -1 + -1 + + + true + + + false + + + + + + + test + true + + + test.*$ + true + + + testinclude + testexclude + + + + + + + + false + + + ^.*$ + false + + + * + + + + + diff --git a/tests/githuborg/fixtures/github-org-legacy-nc.xml b/tests/githuborg/fixtures/github-org-legacy-nc.xml deleted file mode 100644 index 84475952f..000000000 --- a/tests/githuborg/fixtures/github-org-legacy-nc.xml +++ /dev/null @@ -1,229 +0,0 @@ - - - - - - - - - false - - - - - - - true - -1 - -1 - - - - - example-owner - http://example.org/github - example-credential - - - 3 - - - ssh_secret - - - - 3 - - - - 3 - - - (.*/master|.*/release/.*) - - - foo/.* - 20\..* - - - foo* - bar* - qaz* - *baz - - - (foo/.*|bar/.*) - 1\..* - - - qaz* - baz* - bar* - *qaz - - - jenkins.example.com/my_context - true - - - - - - - - - - no-reply@ci.example.com - - - - - true - 3 - true - 100 - - - - - - - - path1 - - - path2 - - - path3 - - - - - - - false - true - false - true - - 100 - 1 - - - - - 100 - - - - - - - - - - - - - - - - - - +refs/heads/*:refs/remotes/@{remote}/* - - - - - - - - - - - MAX_SURVIVABILITY - - - Ci build! - - - - - - - - - - - - - - - - - false - - - -1 - -1 - - - - - 86400000 - 604800000 - - - -1 - -1 - - - true - - - false - - - - - - - test - true - - - test.*$ - true - - - testinclude - testexclude - - - - - - - - false - - - ^.*$ - false - - - * - - - - - - - - - - Jenkinsfile - - - diff --git a/tests/githuborg/fixtures/github-org-legacy-nc.yaml b/tests/githuborg/fixtures/github-org-legacy-nc.yaml deleted file mode 100644 index adfac9dbe..000000000 --- a/tests/githuborg/fixtures/github-org-legacy-nc.yaml +++ /dev/null @@ -1,101 +0,0 @@ -name: github-org-legacy-nc -project-type: githuborg -github-org: - api-uri: http://example.org/github - ssh-checkout: - credentials: 'ssh_secret' - repo-owner: example-owner - credentials-id: example-credential - branch-discovery: all - head-filter-regex: "(.*/master|.*/release/.*)" - head-pr-filter-behaviors: - head-pr-destined-regex: - branch-regexp: "foo/.*" - tag-regexp: "20\\..*" - head-pr-destined-wildcard: - branch-includes: "foo*" - tag-includes: "qaz*" - branch-excludes: "bar*" - tag-excludes: "*baz" - head-pr-originated-regex: - branch-regexp: "(foo/.*|bar/.*)" - tag-regexp: "1\\..*" - head-pr-originated-wildcard: - branch-includes: "qaz*" - tag-includes: "bar*" - branch-excludes: "baz*" - tag-excludes: "*qaz" - discover-pr-forks-strategy: both - discover-pr-forks-trust: everyone - discover-pr-origin: both - discover-tags: true - notification-context: 'jenkins.example.com/my_context' - property-strategies: - all-branches: - - suppress-scm-triggering: true - - pipeline-branch-durability-override: max-survivability - - trigger-build-on-pr-comment: "Ci build!" - - trigger-build-on-pr-review: true - - trigger-build-on-pr-update: true - build-strategies: - - all-strategies-match: - strategies: - - regular-branches: true - - skip-initial-build: true - - any-strategies-match: - strategies: - - change-request: {} - - tags: {} - - tags: - ignore-tags-newer-than: 1 - ignore-tags-older-than: 7 - - tags: {} - - change-request: - ignore-target-only-changes: true - - change-request: {} - - regular-branches: true - - skip-initial-build: true - - named-branches: - - exact-name: - name: 'test' - case-sensitive: true - - regex-name: - regex: 'test.*$' - case-sensitive: true - - wildcards-name: - excludes: 'testexclude' - includes: 'testinclude' - - named-branches: - - exact-name: {} - - regex-name: {} - - wildcards-name: {} - clean: - after: true - before: true - committer: - user: CI System - email: no-reply@ci.example.com - prune: true - local-branch: true - sparse-checkout: - paths: - - "path1" - - "path2" - - "path3" - shallow-clone: true - depth: 3 - do-not-fetch-tags: true - disable-pr-notifications: true - refspecs: - - '+refs/heads/*:refs/remotes/@{remote}/*' - submodule: - disable: false - recursive: true - parent-credentials: true - timeout: 100 - threads: 1 - timeout: "100" - skip-notifications: true - use-author: true - wipe-workspace: true - lfs-pull: true