diff --git a/jenkins_jobs/modules/project_pipeline.py b/jenkins_jobs/modules/project_pipeline.py index ebf27fb8a..2b945cc0f 100644 --- a/jenkins_jobs/modules/project_pipeline.py +++ b/jenkins_jobs/modules/project_pipeline.py @@ -40,6 +40,9 @@ interpreted by the python str.format() command. source code repository * **script-path**: path to the Groovy file containing the job's steps (optional, default: ``Jenkinsfile``) + * **lightweight-checkout** (`bool`): If selected, try to obtain the + Pipeline script contents directly from the SCM without performing a + full checkout. (optional, default: ``false``) Note that ``dsl`` and ``pipeline-scm`` parameters are mutually exclusive. diff --git a/jenkins_jobs/modules/scm.py b/jenkins_jobs/modules/scm.py index 70e97253d..23ba7b67e 100644 --- a/jenkins_jobs/modules/scm.py +++ b/jenkins_jobs/modules/scm.py @@ -1422,9 +1422,11 @@ class PipelineSCM(jenkins_jobs.modules.base.Base): raise JenkinsJobsException("'scm' missing or empty") elif scms_count == 1: self.registry.dispatch('scm', definition_parent, scms[0]) - XML.SubElement(definition_parent, 'scriptPath' - ).text = pipeline_dict.get('script-path', - 'Jenkinsfile') + mapping = [('script-path', 'scriptPath', 'Jenkinsfile'), + ('lightweight-checkout', 'lightweight', None, + [True, False])] + convert_mapping_to_xml(definition_parent, pipeline_dict, + mapping, fail_required=False) else: raise JenkinsJobsException('Only one SCM can be specified ' 'as pipeline-scm') diff --git a/tests/yamlparser/fixtures/project_pipeline_template004.xml b/tests/yamlparser/fixtures/project_pipeline_template004.xml index 942de03a0..cd79ab946 100644 --- a/tests/yamlparser/fixtures/project_pipeline_template004.xml +++ b/tests/yamlparser/fixtures/project_pipeline_template004.xml @@ -11,6 +11,7 @@ false Jenkinsfile.groovy + true <!-- Managed by Jenkins Job Builder --> diff --git a/tests/yamlparser/fixtures/project_pipeline_template004.yaml b/tests/yamlparser/fixtures/project_pipeline_template004.yaml index 5f2f8f598..0bb9f79ed 100644 --- a/tests/yamlparser/fixtures/project_pipeline_template004.yaml +++ b/tests/yamlparser/fixtures/project_pipeline_template004.yaml @@ -8,4 +8,5 @@ url: http://hg.example.org/test_job clean: true script-path: Jenkinsfile.groovy + lightweight-checkout: true