From 177d51b881cb319a23456b2a16299c2cd2eb53cc Mon Sep 17 00:00:00 2001 From: Kevin de Berk Date: Mon, 18 Jun 2018 13:02:07 +0200 Subject: [PATCH] multibranch: Configurable script-path By default the script-path is set to 'Jenkinsfile', but it can now be configured. Change-Id: If02468b292b6b771b3794ea0606acd233c2e9e4b --- jenkins_jobs/modules/project_multibranch.py | 5 ++++- tests/multibranch/fixtures/multi_scm_full.xml | 2 +- tests/multibranch/fixtures/multi_scm_full.yaml | 1 + tests/multibranch/fixtures/scm_bitbucket_full.xml | 2 +- tests/multibranch/fixtures/scm_bitbucket_full.yaml | 1 + tests/multibranch/fixtures/scm_gerrit_full.xml | 2 +- tests/multibranch/fixtures/scm_gerrit_full.yaml | 1 + tests/multibranch/fixtures/scm_git_full.xml | 2 +- tests/multibranch/fixtures/scm_git_full.yaml | 1 + tests/multibranch/fixtures/scm_github_full.xml | 2 +- tests/multibranch/fixtures/scm_github_full.yaml | 1 + 11 files changed, 14 insertions(+), 6 deletions(-) diff --git a/jenkins_jobs/modules/project_multibranch.py b/jenkins_jobs/modules/project_multibranch.py index d6447cb8c..ef83ccbbb 100644 --- a/jenkins_jobs/modules/project_multibranch.py +++ b/jenkins_jobs/modules/project_multibranch.py @@ -55,6 +55,8 @@ Plugins required: (default '-1, all') * **days-to-keep** (`int`): For how many days should a build be kept. (default '-1, forever') + * **script-path** (`str`): Path to Jenkinsfile, relative to workspace. + (default 'Jenkinsfile') Job examples: @@ -270,7 +272,8 @@ class WorkflowMultiBranch(jenkins_jobs.modules.base.Base): 'class': self.jenkins_class, 'reference': '../..' }) - XML.SubElement(factory, 'scriptPath').text = 'Jenkinsfile' + XML.SubElement(factory, 'scriptPath').text = data.get( + 'script-path', 'Jenkinsfile') return xml_parent diff --git a/tests/multibranch/fixtures/multi_scm_full.xml b/tests/multibranch/fixtures/multi_scm_full.xml index c54a4c5e0..a2dfb18f2 100644 --- a/tests/multibranch/fixtures/multi_scm_full.xml +++ b/tests/multibranch/fixtures/multi_scm_full.xml @@ -79,6 +79,6 @@ - Jenkinsfile + some.Jenkinsfile diff --git a/tests/multibranch/fixtures/multi_scm_full.yaml b/tests/multibranch/fixtures/multi_scm_full.yaml index f7739c4f3..f9978c32f 100644 --- a/tests/multibranch/fixtures/multi_scm_full.yaml +++ b/tests/multibranch/fixtures/multi_scm_full.yaml @@ -7,6 +7,7 @@ periodic-folder-trigger: 1d prune-dead-branches: True number-to-keep: '10' days-to-keep: '10' +script-path: 'some.Jenkinsfile' scm: - bitbucket: repo-owner: 'SANDBOX' diff --git a/tests/multibranch/fixtures/scm_bitbucket_full.xml b/tests/multibranch/fixtures/scm_bitbucket_full.xml index 9a4b78a96..5bc3ec432 100644 --- a/tests/multibranch/fixtures/scm_bitbucket_full.xml +++ b/tests/multibranch/fixtures/scm_bitbucket_full.xml @@ -46,6 +46,6 @@ - Jenkinsfile + some.Jenkinsfile diff --git a/tests/multibranch/fixtures/scm_bitbucket_full.yaml b/tests/multibranch/fixtures/scm_bitbucket_full.yaml index 50138255f..84be75acd 100644 --- a/tests/multibranch/fixtures/scm_bitbucket_full.yaml +++ b/tests/multibranch/fixtures/scm_bitbucket_full.yaml @@ -1,5 +1,6 @@ name: 'demo-multibranch-bitbucket-min' project-type: multibranch +script-path: 'some.Jenkinsfile' scm: - bitbucket: credentials-id: 'secret' diff --git a/tests/multibranch/fixtures/scm_gerrit_full.xml b/tests/multibranch/fixtures/scm_gerrit_full.xml index e14588ae1..92124e3fd 100644 --- a/tests/multibranch/fixtures/scm_gerrit_full.xml +++ b/tests/multibranch/fixtures/scm_gerrit_full.xml @@ -55,6 +55,6 @@ - Jenkinsfile + some.Jenkinsfile diff --git a/tests/multibranch/fixtures/scm_gerrit_full.yaml b/tests/multibranch/fixtures/scm_gerrit_full.yaml index 373bffca0..6c6c60717 100644 --- a/tests/multibranch/fixtures/scm_gerrit_full.yaml +++ b/tests/multibranch/fixtures/scm_gerrit_full.yaml @@ -1,5 +1,6 @@ name: 'demo-multibranch-gerrit-min' project-type: multibranch +script-path: some.Jenkinsfile scm: - gerrit: url: 'https://review.gerrithub.io/johndoe/foo' diff --git a/tests/multibranch/fixtures/scm_git_full.xml b/tests/multibranch/fixtures/scm_git_full.xml index 0a125a108..d7096791f 100644 --- a/tests/multibranch/fixtures/scm_git_full.xml +++ b/tests/multibranch/fixtures/scm_git_full.xml @@ -46,6 +46,6 @@ - Jenkinsfile + some.Jenkinsfile diff --git a/tests/multibranch/fixtures/scm_git_full.yaml b/tests/multibranch/fixtures/scm_git_full.yaml index 13735c962..01e52f42f 100644 --- a/tests/multibranch/fixtures/scm_git_full.yaml +++ b/tests/multibranch/fixtures/scm_git_full.yaml @@ -1,5 +1,6 @@ name: 'demo-multibranch-git-min' project-type: multibranch +script-path: some.Jenkinsfile scm: - git: url: 'https://example.com/jonhndoe/keep-frontend.git' diff --git a/tests/multibranch/fixtures/scm_github_full.xml b/tests/multibranch/fixtures/scm_github_full.xml index 672967376..389c1b55a 100644 --- a/tests/multibranch/fixtures/scm_github_full.xml +++ b/tests/multibranch/fixtures/scm_github_full.xml @@ -57,6 +57,6 @@ - Jenkinsfile + some.Jenkinsfile diff --git a/tests/multibranch/fixtures/scm_github_full.yaml b/tests/multibranch/fixtures/scm_github_full.yaml index c35ca97cc..197c0dfcd 100644 --- a/tests/multibranch/fixtures/scm_github_full.yaml +++ b/tests/multibranch/fixtures/scm_github_full.yaml @@ -1,5 +1,6 @@ name: scm-github-full project-type: multibranch +script-path: some.Jenkinsfile scm: - github: api-uri: http://example.org/github