diff --git a/jenkins_jobs/modules/properties.py b/jenkins_jobs/modules/properties.py index ffd78f821..e2cdb3789 100644 --- a/jenkins_jobs/modules/properties.py +++ b/jenkins_jobs/modules/properties.py @@ -230,6 +230,30 @@ def gitlab_logo(registry, xml_parent, data): helpers.convert_mapping_to_xml(logo, data, mapping, fail_required=True) +def gogs(registry, xml_parent, data): + """yaml: gogs + Sets the Gogs webhook properties for the project. + + Requires the Jenkins :jenkins-plugins:`Gogs Plugin `. + + :arg str secret: webhook secret (default '') + :arg str branch-filter: filter which needs to match to trigger a job (default '') + + Minimal Example: + + .. literalinclude:: /../../tests/properties/fixtures/gogs-minimal.yaml + :language: yaml + + Full Example: + + .. literalinclude:: /../../tests/properties/fixtures/gogs-full.yaml + :language: yaml + """ + gogs = XML.SubElement(xml_parent, "org.jenkinsci.plugins.gogs.GogsProjectProperty") + mapping = [("branch-filter", "gogsBranchFilter", ""), ("secret", "gogsSecret", "")] + helpers.convert_mapping_to_xml(gogs, data, mapping) + + def naginator_opt_out(registry, xml_parent, data): """yaml: naginator-opt-out Lets you opt-out so no rebuild option for Naginator is added. diff --git a/jenkins_jobs/modules/triggers.py b/jenkins_jobs/modules/triggers.py index 51df009d1..a71643382 100644 --- a/jenkins_jobs/modules/triggers.py +++ b/jenkins_jobs/modules/triggers.py @@ -1705,6 +1705,22 @@ def gitlab(registry, xml_parent, data): _add_xml(gitlab, xml_name, value) +def gogs(registry, xml_parent, data): + """yaml: gogs + Trigger a job when gogs repository is pushed to. + + Requires the Jenkins :jenkins-plugins:`Gogs Plugin `. + + Example: + + .. literalinclude:: + /../../tests/triggers/fixtures/gogs.yaml + :language: yaml + """ + gogstrig = XML.SubElement(xml_parent, "org.jenkinsci.plugins.gogs.GogsTrigger") + XML.SubElement(gogstrig, "spec") + + def build_result(registry, xml_parent, data): """yaml: build-result Configure jobB to monitor jobA build result. A build is scheduled if there diff --git a/tests/properties/fixtures/gogs-full.xml b/tests/properties/fixtures/gogs-full.xml new file mode 100644 index 000000000..f9ea91f58 --- /dev/null +++ b/tests/properties/fixtures/gogs-full.xml @@ -0,0 +1,9 @@ + + + + + master + yoursecret + + + diff --git a/tests/properties/fixtures/gogs-full.yaml b/tests/properties/fixtures/gogs-full.yaml new file mode 100644 index 000000000..f6593cdf5 --- /dev/null +++ b/tests/properties/fixtures/gogs-full.yaml @@ -0,0 +1,4 @@ +properties: + - gogs: + branch-filter: 'master' + secret: 'yoursecret' diff --git a/tests/properties/fixtures/gogs-minimal.xml b/tests/properties/fixtures/gogs-minimal.xml new file mode 100644 index 000000000..d9e199788 --- /dev/null +++ b/tests/properties/fixtures/gogs-minimal.xml @@ -0,0 +1,9 @@ + + + + + + + + + diff --git a/tests/properties/fixtures/gogs-minimal.yaml b/tests/properties/fixtures/gogs-minimal.yaml new file mode 100644 index 000000000..561113531 --- /dev/null +++ b/tests/properties/fixtures/gogs-minimal.yaml @@ -0,0 +1,2 @@ +properties: + - gogs diff --git a/tests/triggers/fixtures/gogs.xml b/tests/triggers/fixtures/gogs.xml new file mode 100644 index 000000000..535f06094 --- /dev/null +++ b/tests/triggers/fixtures/gogs.xml @@ -0,0 +1,8 @@ + + + + + + + + diff --git a/tests/triggers/fixtures/gogs.yaml b/tests/triggers/fixtures/gogs.yaml new file mode 100644 index 000000000..788eefa6a --- /dev/null +++ b/tests/triggers/fixtures/gogs.yaml @@ -0,0 +1,2 @@ +triggers: + - gogs