diff --git a/jenkins_jobs/modules/properties.py b/jenkins_jobs/modules/properties.py index b3bb04faf..c7561b94e 100644 --- a/jenkins_jobs/modules/properties.py +++ b/jenkins_jobs/modules/properties.py @@ -126,19 +126,29 @@ def github(registry, xml_parent, data): Sets the GitHub URL for the project. :arg str url: the GitHub URL (required) + :arg str display-name: This value will be used as context name for commit + status if status builder or status publisher is defined for this + project. (>= 1.14.1) (default '') - Example: + Minimal Example: - .. literalinclude:: /../../tests/properties/fixtures/github.yaml + .. literalinclude:: /../../tests/properties/fixtures/github-minimal.yaml + :language: yaml + + Full Example: + + .. literalinclude:: /../../tests/properties/fixtures/github-full.yaml :language: yaml """ - github = XML.SubElement(xml_parent, - 'com.coravy.hudson.plugins.github.' - 'GithubProjectProperty') - try: - XML.SubElement(github, 'projectUrl').text = data['url'] - except KeyError as e: - raise MissingAttributeError(e) + github = XML.SubElement( + xml_parent, 'com.coravy.hudson.plugins.github.GithubProjectProperty') + github.set('plugin', 'github') + + mapping = [ + ('url', 'projectUrl', None), + ('display-name', 'displayName', ''), + ] + helpers.convert_mapping_to_xml(github, data, mapping, fail_required=True) def gitlab(registry, xml_parent, data): diff --git a/tests/properties/fixtures/github-full.xml b/tests/properties/fixtures/github-full.xml new file mode 100644 index 000000000..4b93ed33b --- /dev/null +++ b/tests/properties/fixtures/github-full.xml @@ -0,0 +1,9 @@ + + + + + https://github.com/openstack-infra/jenkins-job-builder/ + foo + + + diff --git a/tests/properties/fixtures/github-full.yaml b/tests/properties/fixtures/github-full.yaml new file mode 100644 index 000000000..af05a1752 --- /dev/null +++ b/tests/properties/fixtures/github-full.yaml @@ -0,0 +1,4 @@ +properties: + - github: + url: https://github.com/openstack-infra/jenkins-job-builder/ + display-name: foo diff --git a/tests/properties/fixtures/github.xml b/tests/properties/fixtures/github-minimal.xml similarity index 71% rename from tests/properties/fixtures/github.xml rename to tests/properties/fixtures/github-minimal.xml index 08413fe37..35c98f519 100644 --- a/tests/properties/fixtures/github.xml +++ b/tests/properties/fixtures/github-minimal.xml @@ -1,8 +1,9 @@ - + https://github.com/openstack-infra/jenkins-job-builder/ + diff --git a/tests/properties/fixtures/github.yaml b/tests/properties/fixtures/github-minimal.yaml similarity index 100% rename from tests/properties/fixtures/github.yaml rename to tests/properties/fixtures/github-minimal.yaml