From c1d8a41666e6c87d3997e90b80875de211cf95a4 Mon Sep 17 00:00:00 2001 From: sp-ricard-valverde Date: Tue, 16 Mar 2021 17:34:38 +0100 Subject: [PATCH] feat(scm): add git extension for lfs-pull Add a missing extension to git scm which enables the option to do "Git LFS pull after checkout" Add lfs-pull fixtures Change-Id: Ie8b98877f3f282ac0b32dbeb089e6d0d9ccc25c8 --- jenkins_jobs/modules/project_multibranch.py | 9 +++++++++ jenkins_jobs/modules/scm.py | 12 ++++++++++++ tests/jsonparser/fixtures/complete001.json | 3 ++- tests/jsonparser/fixtures/complete001.xml | 1 + tests/multibranch/fixtures/scm_bitbucket_full.xml | 3 +++ tests/multibranch/fixtures/scm_bitbucket_full.yaml | 1 + tests/multibranch/fixtures/scm_git_full.xml | 3 +++ tests/multibranch/fixtures/scm_git_full.yaml | 1 + tests/multibranch/fixtures/scm_github_full.xml | 3 +++ tests/multibranch/fixtures/scm_github_full.yaml | 1 + tests/scm/fixtures/git-extensions01.xml | 1 + tests/scm/fixtures/git-extensions01.yaml | 1 + tests/scm/fixtures/git-extensions03.xml | 1 + tests/scm/fixtures/git-extensions03.yaml | 1 + tests/yamlparser/fixtures/complete001.xml | 1 + tests/yamlparser/fixtures/complete001.yaml | 1 + 16 files changed, 42 insertions(+), 1 deletion(-) diff --git a/jenkins_jobs/modules/project_multibranch.py b/jenkins_jobs/modules/project_multibranch.py index ac7c5ddf9..a30ef5bc6 100644 --- a/jenkins_jobs/modules/project_multibranch.py +++ b/jenkins_jobs/modules/project_multibranch.py @@ -456,6 +456,8 @@ def bitbucket_scm(xml_parent, data): build changeset (default false) * **wipe-workspace** (`bool`) - Wipe out workspace before build (default true) + * **lfs-pull** (`bool`) - Call git lfs pull after checkout + (default false) Minimal Example: @@ -645,6 +647,7 @@ def bitbucket_scm(xml_parent, data): # - prune # - wipe-workspace # - use-author + # - lfs-pull git_extensions(traits, data) @@ -826,6 +829,8 @@ def git_scm(xml_parent, data): build changeset (default false) * **wipe-workspace** (`bool`) - Wipe out workspace before build (default true) + * **lfs-pull** (`bool`) - Call git lfs pull after checkout + (default false) Minimal Example: @@ -885,6 +890,7 @@ def git_scm(xml_parent, data): # - prune # - wipe-workspace # - use-author + # - lfs-pull git_extensions(traits, data) @@ -975,6 +981,8 @@ def github_scm(xml_parent, data): build changeset (default false) * **wipe-workspace** (`bool`) - Wipe out workspace before build (default true) + * **lfs-pull** (`bool`) - Call git lfs pull after checkout + (default false) Minimal Example: @@ -1111,6 +1119,7 @@ def github_scm(xml_parent, data): # - prune # - wipe-workspace # - use-author + # - lfs-pull git_extensions(traits, data) if data.get("refspecs"): diff --git a/jenkins_jobs/modules/scm.py b/jenkins_jobs/modules/scm.py index 3a2571fc0..b16187fd2 100644 --- a/jenkins_jobs/modules/scm.py +++ b/jenkins_jobs/modules/scm.py @@ -327,6 +327,8 @@ def git(registry, xml_parent, data): build changeset (default false) * **wipe-workspace** (`bool`) - Wipe out workspace before build (default true) + * **lfs-pull** (`bool`) - Call git lfs pull after checkout + (default false) Example: @@ -733,6 +735,16 @@ def git_extensions(xml_parent, data): else: ext = XML.SubElement(xml_parent, ext_name) + lfs_pull = str(data.get("lfs-pull", False)).lower() + if lfs_pull == "true": + ext_name = impl_prefix + "GitLFSPull" + if trait: + trait_name = "GitLFSPullTrait" + tr = XML.SubElement(xml_parent, trait_prefix + trait_name) + XML.SubElement(tr, "extension", {"class": ext_name}) + else: + XML.SubElement(xml_parent, ext_name) + def cvs(registry, xml_parent, data): """yaml: cvs diff --git a/tests/jsonparser/fixtures/complete001.json b/tests/jsonparser/fixtures/complete001.json index d6614b668..cbe314f06 100644 --- a/tests/jsonparser/fixtures/complete001.json +++ b/tests/jsonparser/fixtures/complete001.json @@ -121,7 +121,8 @@ "clean": true, "browser": "gitweb", "browser-url": "http://review.openstack.org/gitweb?p={project_pattern}.git", - "choosing-strategy": "gerrit" + "choosing-strategy": "gerrit", + "lfs-pull": true } } ] diff --git a/tests/jsonparser/fixtures/complete001.xml b/tests/jsonparser/fixtures/complete001.xml index 17a54f725..5b328eb1b 100644 --- a/tests/jsonparser/fixtures/complete001.xml +++ b/tests/jsonparser/fixtures/complete001.xml @@ -38,6 +38,7 @@ + http://review.openstack.org/gitweb?p=openstack-infra/jenkins-job-builder.git diff --git a/tests/multibranch/fixtures/scm_bitbucket_full.xml b/tests/multibranch/fixtures/scm_bitbucket_full.xml index 72c426b61..d7e5be355 100644 --- a/tests/multibranch/fixtures/scm_bitbucket_full.xml +++ b/tests/multibranch/fixtures/scm_bitbucket_full.xml @@ -156,6 +156,9 @@ + + + diff --git a/tests/multibranch/fixtures/scm_bitbucket_full.yaml b/tests/multibranch/fixtures/scm_bitbucket_full.yaml index 253d84d41..4a0906e57 100644 --- a/tests/multibranch/fixtures/scm_bitbucket_full.yaml +++ b/tests/multibranch/fixtures/scm_bitbucket_full.yaml @@ -100,3 +100,4 @@ scm: skip-notifications: true use-author: true wipe-workspace: true + lfs-pull: true diff --git a/tests/multibranch/fixtures/scm_git_full.xml b/tests/multibranch/fixtures/scm_git_full.xml index 98242da05..cec382443 100644 --- a/tests/multibranch/fixtures/scm_git_full.xml +++ b/tests/multibranch/fixtures/scm_git_full.xml @@ -114,6 +114,9 @@ + + + diff --git a/tests/multibranch/fixtures/scm_git_full.yaml b/tests/multibranch/fixtures/scm_git_full.yaml index 4b3b164c3..4ba18202a 100644 --- a/tests/multibranch/fixtures/scm_git_full.yaml +++ b/tests/multibranch/fixtures/scm_git_full.yaml @@ -88,3 +88,4 @@ scm: timeout: "100" use-author: true wipe-workspace: true + lfs-pull: true diff --git a/tests/multibranch/fixtures/scm_github_full.xml b/tests/multibranch/fixtures/scm_github_full.xml index 49451804b..1bcfcb93a 100644 --- a/tests/multibranch/fixtures/scm_github_full.xml +++ b/tests/multibranch/fixtures/scm_github_full.xml @@ -138,6 +138,9 @@ + + + diff --git a/tests/multibranch/fixtures/scm_github_full.yaml b/tests/multibranch/fixtures/scm_github_full.yaml index cfd0feab6..835950281 100644 --- a/tests/multibranch/fixtures/scm_github_full.yaml +++ b/tests/multibranch/fixtures/scm_github_full.yaml @@ -100,3 +100,4 @@ scm: skip-notifications: true use-author: true wipe-workspace: true + lfs-pull: true diff --git a/tests/scm/fixtures/git-extensions01.xml b/tests/scm/fixtures/git-extensions01.xml index 8f9fd2b9f..dcc36669f 100644 --- a/tests/scm/fixtures/git-extensions01.xml +++ b/tests/scm/fixtures/git-extensions01.xml @@ -37,6 +37,7 @@ bob@example.com + http://github.com/foo/example.git diff --git a/tests/scm/fixtures/git-extensions01.yaml b/tests/scm/fixtures/git-extensions01.yaml index 96868207c..097b75886 100644 --- a/tests/scm/fixtures/git-extensions01.yaml +++ b/tests/scm/fixtures/git-extensions01.yaml @@ -14,3 +14,4 @@ scm: scm-name: something_special use-author: true wipe-workspace: false + lfs-pull: true diff --git a/tests/scm/fixtures/git-extensions03.xml b/tests/scm/fixtures/git-extensions03.xml index 8f9fd2b9f..dcc36669f 100644 --- a/tests/scm/fixtures/git-extensions03.xml +++ b/tests/scm/fixtures/git-extensions03.xml @@ -37,6 +37,7 @@ bob@example.com + http://github.com/foo/example.git diff --git a/tests/scm/fixtures/git-extensions03.yaml b/tests/scm/fixtures/git-extensions03.yaml index 98eec9c92..ece1d7784 100644 --- a/tests/scm/fixtures/git-extensions03.yaml +++ b/tests/scm/fixtures/git-extensions03.yaml @@ -14,3 +14,4 @@ scm: scm-name: something_special use-author: true wipe-workspace: false + lfs-pull: true diff --git a/tests/yamlparser/fixtures/complete001.xml b/tests/yamlparser/fixtures/complete001.xml index ef15abeb0..75eeff252 100644 --- a/tests/yamlparser/fixtures/complete001.xml +++ b/tests/yamlparser/fixtures/complete001.xml @@ -39,6 +39,7 @@ + http://review.openstack.org/gitweb?p=openstack-infra/jenkins-job-builder.git diff --git a/tests/yamlparser/fixtures/complete001.yaml b/tests/yamlparser/fixtures/complete001.yaml index f64b8084c..0342819a0 100644 --- a/tests/yamlparser/fixtures/complete001.yaml +++ b/tests/yamlparser/fixtures/complete001.yaml @@ -84,6 +84,7 @@ browser: gitweb browser-url: http://review.openstack.org/gitweb?p={project_pattern}.git choosing-strategy: gerrit + lfs-pull: true - project: name: complete001