How to import variable substitution (.vs) file during Webmethods Deployment using sagdevops-ci-assets

We are using SAG WM 10.3 and using sagdevops-ci-assets (GitHub - SoftwareAG/sagdevops-ci-assets: Software AG DevOps library to support assets CI (continuous integration) with webMethods 9.x and 10.0. Work together with https://github.com/SoftwareAG/webmethods-sample-project-layout) for build and deployment.

My build and deployment server is different.

there are only build and deployment commands in sagdevops-ci-assets but no import command. we want to import variable substitution (.vs) file. In WmDeployer.sh, there is an “import” command using which .vs file can be imported. Same thing I want to do using sagdevops-ci-assets. Please help.

Thanks in advance.

Please refer this Automated build and deployment using Jenkins, ABE, Deployer

*cp .vs /IntegrationServer/instances//packages/WmDeployer/replicate/inbound/

Deployer.bat --import -varsub <you-file-name(.vs file)> -map -project -validate <true/false> -host -port -user -pwd

Hi @aniruddha87 -

I implemented this exact function for a customer a few years ago who had also used those GitHub projects as a starting point for their CI/CD implementation. Here are the related Ant targets from that implementation:

	<target name="substituteVariables" depends="checkForVarsubFile, transformVarsubFile" if="${varsubFile.exists}">
		<echo>Substituting variables with file ${varsubFile}</echo>
		<exec executable="${deployerInstallationPath}/${deployerExecutable}" dir="${deployerInstallationPath}" failonerror="true" resultproperty="appState">
			<arg value="--import"/>
			<arg value="-varsub"/>
			<arg line="-vsFile ${varsubFile}"/>
			<arg line="-map myDeploymentMap"/>
			<arg line="-project ${projectName}"/>
			<arg line="-validate true"/>
			<arg line="-host ${deployerHost}"/>
			<arg line="-port ${deployerPort}"/>
			<arg line="-user ${deployerUsername}"/>
			<arg line="-pwd ${deployerPassword}"/>
		</exec>

		<if>
			<equals arg1="${appState}" arg2="0" trim="true"/>
			<then>
				<echo message="WMDeployer variable substitution successfully executed."/>
			</then>
			<else>
				<fail message="WMDeployer variable substitution failed."/>
			</else>
		</if>
	</target>
	
	<target name="checkForVarsubFile">
		<echo>Checking if Deployer variable substitution file ${varsubWorkspacePath}/${varsubFile} exists...</echo>
		<condition property="varsubFile.exists" else="false">
			<available file="${varsubWorkspacePath}/${varsubFile}"/>
		</condition>
		<echo>... file exists? ${varsubFile.exists}</echo>
	</target>

	<target name="transformVarsubFile" if="${varsubFile.exists}">
		<echo>Transforming variable substitution file with XSLT ${varsubXSLT} and copying the file to Deployer folder...</echo>
		<!-- Fill in attributes in varsub file and copy it to the Deployer location -->
		<xslt style="${varsubXSLT}" in="${varsubWorkspacePath}/${varsubFile}" out="${varsubDeployerPath}/${varsubFile}" force="true">
			<!--target server props -->
			<param name="serverAliasName" expression="${repositoryName}"/>
			<param name="targetServerName" expression="${deployerTargetAlias}"/>
		</xslt>
		<echo>... done.</echo>
	</target>

And here’s the source code for the varsub XSLT:

<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
	<xsl:output method="xml" encoding="utf-8" indent="yes" />

	<xsl:param name="serverAliasName" />
	<xsl:param name="targetServerName" />

	<xsl:template match="@*|node()">
		<xsl:copy>
			<xsl:apply-templates select="@*|node()" />
		</xsl:copy>
	</xsl:template>

	<xsl:template match="Root/DeploymentSet/@serverAliasName">
		<xsl:attribute name="serverAliasName">
			<xsl:value-of select="$serverAliasName" />
		</xsl:attribute>
	</xsl:template>
	
	<xsl:template match="Root/DeploymentSet/@targetServerName">
		<xsl:attribute name="targetServerName">
			<xsl:value-of select="$targetServerName" />
		</xsl:attribute>
	</xsl:template>
</xsl:stylesheet>

Hope this helps,
Percio

1 Like