Skip to content

Instantly share code, notes, and snippets.

@codingtony
Last active September 24, 2015 22:17
Show Gist options
  • Save codingtony/6a9dde631a212b438022 to your computer and use it in GitHub Desktop.
Save codingtony/6a9dde631a212b438022 to your computer and use it in GitHub Desktop.
Add build wrappers to scm that are hosted to a specific host (myhost)
<?xml version="1.0" encoding="utf-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:fn="http://www.w3.org/2005/xpath-functions">
<xsl:output method="xml" indent="yes"/>
<xsl:template match="@* | node()">
<xsl:copy>
<xsl:apply-templates select="@* | node()"/>
</xsl:copy>
</xsl:template>
<xsl:template match="publishers">
<xsl:choose>
<xsl:when test="/*/publishers/hudson.tasks.ArtifactArchiver[contains(artifacts,'rpm')]">
<xsl:choose>
<xsl:when test="/*/publishers/jenkins.plugins.publish__over__ssh.BapSshPublisherPlugin">
<xsl:copy>
<xsl:apply-templates select="@* | node()"/>
</xsl:copy>
</xsl:when>
<xsl:otherwise>
<xsl:copy>
<xsl:apply-templates select="@* | node()"/>
<xsl:copy-of select="document('publishers.xml')/*"/>
</xsl:copy>
</xsl:otherwise>
</xsl:choose>
</xsl:when>
<xsl:otherwise>
<xsl:copy>
<xsl:apply-templates select="@* | node()"/>
</xsl:copy>
</xsl:otherwise>
</xsl:choose>
</xsl:template>
</xsl:stylesheet>
<?xml version="1.0" encoding="utf-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:fn="http://www.w3.org/2005/xpath-functions">
<xsl:output method="xml" indent="yes"/>
<xsl:template match="@* | node()">
<xsl:copy>
<xsl:apply-templates select="@* | node()"/>
</xsl:copy>
</xsl:template>
<xsl:template match="jenkins.plugins.publish__over__ssh.BapSshPublisherPlugin"/>
</xsl:stylesheet>
<?xml version="1.0" encoding="utf-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:fn="http://www.w3.org/2005/xpath-functions">
<xsl:output method="xml" indent="yes"/>
<xsl:template match="@* | node()">
<xsl:copy>
<xsl:apply-templates select="@* | node()"/>
</xsl:copy>
</xsl:template>
<xsl:template match="buildWrappers">
<xsl:choose>
<xsl:when test="/maven2-moduleset/scm[contains(source,'myhost')]">
<xsl:element name="buildWrappers">
<xsl:element name="hudson.plugins.ws__cleanup.PreBuildCleanup">
<xsl:attribute name="plugin">[email protected]</xsl:attribute>
<xsl:element name="deleteDirs"><xsl:text>false</xsl:text></xsl:element>
<xsl:element name="cleanupParameter"/>
<xsl:element name="externalDelete"/>
</xsl:element>
<xsl:element name="org.jvnet.hudson.plugins.m2release.M2ReleaseBuildWrapper">
<xsl:attribute name="plugin">[email protected]</xsl:attribute>
<xsl:element name="scmUserEnvVar"/>
<xsl:element name="scmPasswordEnvVar"/>
<xsl:element name="releaseEnvVar"><xsl:text>IS_M2RELEASEBUILD</xsl:text></xsl:element>
<xsl:element name="releaseGoals">
<xsl:text disable-output-escaping="yes"><![CDATA[-Dresume=false release:prepare release:perform scm:checkin -Dmessage=&quot;noop&quot; -DdeveloperConnectionUrl=scm:hg:${MERCURIAL_REPOSITORY_URL}]]></xsl:text></xsl:element>
<xsl:element name="dryRunGoals"><xsl:text>-Dresume=false -DdryRun=true release:prepare</xsl:text></xsl:element>
<xsl:element name="selectAppendHudsonUsername"><xsl:text>true</xsl:text></xsl:element>
<xsl:element name="selectScmCredentials"><xsl:text>true</xsl:text></xsl:element>
<xsl:element name="numberOfReleaseBuildsToKeep"><xsl:text>-1</xsl:text></xsl:element>
</xsl:element>
</xsl:element>
</xsl:when>
<xsl:otherwise>
<xsl:copy>
<xsl:apply-templates select="@* | node()"/>
</xsl:copy>
</xsl:otherwise>
</xsl:choose>
</xsl:template>
</xsl:stylesheet>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment