Add support for Artifactory Trigger

This change adds support for Artifactory Trigger. [0]

In order to use this trigger in JJB Templates, Artifactory
Instances the jobs are polling the paths from must be configured
on Jenkins Global Configuration in advance.

[0] https://plugins.jenkins.io/artifactory/

Change-Id: I7b4651c54c5d4dc14916d58ab6c7d6c7e1e8d4c5
This commit is contained in:
Fatih Degirmenci 2021-10-14 08:14:33 +02:00
parent 471483029e
commit 210a70fb4a
5 changed files with 87 additions and 0 deletions

View File

@ -2701,6 +2701,53 @@ def generic_webhook_trigger(registry, xml_parent, data):
helpers.convert_mapping_to_xml(gwtrig, data, mapping, fail_required=False)
def artifactory(registry, xml_parent, data):
"""yaml: artifactory
Artifactory trigger. Trigger if files are added or modified in configured
path(s) to watch on chosen Artifactory server.
Requires the Jenkins :jenkins-plugins:`Artifactory Plugin <Artifactory>`.
:arg str artifactory-server: Artifactory server where the configured
path(s) are monitored from. Available Artifactory servers must be
configured on Jenkins Global Configuration in advance. (default '')
:arg str schedule: cron syntax of when to poll. (default '')
:arg str paths: Paths in Artifactory to poll for changes. Multiple
paths can be configured by the ';' separator. (default '')
Example with Single Path to Monitor:
.. literalinclude::
/../../tests/triggers/fixtures/artifactory-trigger-single-path.yaml
:language: yaml
Example with Multiple Paths to Monitor:
.. literalinclude::
/../../tests/triggers/fixtures/artifactory-trigger-multi-path.yaml
:language: yaml
"""
artifactory = XML.SubElement(
xml_parent, "org.jfrog.hudson.trigger.ArtifactoryTrigger"
)
artifactory.set("plugin", "artifactory")
mapping = [
("schedule", "spec", ""),
("paths", "paths", ""),
("", "branches", ""),
("", "lastModified", ""),
]
helpers.convert_mapping_to_xml(artifactory, data, mapping, fail_required=True)
details = XML.SubElement(artifactory, "details")
details_mapping = [
("artifactory-server", "artifactoryName", None),
("", "stagingPlugin", ""),
]
helpers.convert_mapping_to_xml(details, data, details_mapping, fail_required=True)
class Triggers(jenkins_jobs.modules.base.Base):
sequence = 50

View File

@ -0,0 +1,15 @@
<?xml version="1.0" encoding="utf-8"?>
<project>
<triggers class="vector">
<org.jfrog.hudson.trigger.ArtifactoryTrigger plugin="artifactory">
<spec>H 0,8,16 * * *</spec>
<paths>myrepo/myfolder/latest;myrepo/myfolder/commit</paths>
<branches/>
<lastModified/>
<details>
<artifactoryName>my-artifactory</artifactoryName>
<stagingPlugin/>
</details>
</org.jfrog.hudson.trigger.ArtifactoryTrigger>
</triggers>
</project>

View File

@ -0,0 +1,5 @@
triggers:
- artifactory:
artifactory-server: my-artifactory
schedule: H 0,8,16 * * *
paths: myrepo/myfolder/latest;myrepo/myfolder/commit

View File

@ -0,0 +1,15 @@
<?xml version="1.0" encoding="utf-8"?>
<project>
<triggers class="vector">
<org.jfrog.hudson.trigger.ArtifactoryTrigger plugin="artifactory">
<spec>H/15 * * * *</spec>
<paths>myrepo/myfolder/latest</paths>
<branches/>
<lastModified/>
<details>
<artifactoryName>my-artifactory</artifactoryName>
<stagingPlugin/>
</details>
</org.jfrog.hudson.trigger.ArtifactoryTrigger>
</triggers>
</project>

View File

@ -0,0 +1,5 @@
triggers:
- artifactory:
artifactory-server: my-artifactory
schedule: H/15 * * * *
paths: myrepo/myfolder/latest