Source code for pyjen.plugins.artifactarchiver

"""Interface to the Jenkins 'archive artifacts' publishing plugin"""
from xml.etree import ElementTree
from pyjen.utils.xml_plugin import XMLPlugin


[docs]class ArtifactArchiverPublisher(XMLPlugin): """Interface to the Jenkins 'archive artifacts' publishing plugin This plugin is a default, built-in plugin which is part of the Jenkins core """
[docs] @staticmethod def get_jenkins_plugin_name(): """str: the name of the Jenkins plugin associated with this PyJen plugin This static method is used by the PyJen plugin API to associate this class with a specific Jenkins plugin, as it is encoded in the config.xml """ return "hudson.tasks.ArtifactArchiver"
@property def artifact_regex(self): """str: the regular expression used to locate files to archive""" children_node = self._root.find('artifacts') return children_node.text
[docs] @classmethod def instantiate(cls, file_pattern): """Factory method for creating a new artifact archiver Args: file_pattern (str): regular expression matching files to be archived at the end of the build returns: ArtifactArchiverPublisher: Reference to the newly created publisher """ default_xml = """ <hudson.tasks.ArtifactArchiver> <allowEmptyArchive>false</allowEmptyArchive> <onlyIfSuccessful>false</onlyIfSuccessful> <fingerprint>false</fingerprint> <defaultExcludes>true</defaultExcludes> <caseSensitive>true</caseSensitive> </hudson.tasks.ArtifactArchiver>""" root_node = ElementTree.fromstring(default_xml) child = ElementTree.SubElement(root_node, "artifacts") child.text = file_pattern return cls(root_node)
PluginClass = ArtifactArchiverPublisher if __name__ == "__main__": # pragma: no cover pass