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

Hi @Percio_Castro1 where we have create above two file Or this file already exist inside our IS server, an you please give me more input on this since I’m new to this webmethod as you know very about in our previous post discussion.

Thanks.

Hi @srikanth.prathipati1803 - above import command is not working see the output error log.Error Executing Command

[[DEP.0100.4.01] Error - -609] : [[DEP.0100.5.51] Import] : [DEP.0100.-609] Command requires -mapFile option. Please specify -mapFile option

@palani_samy those snippets are for folks using the sagdevops-ci-asset GitHub project to kickstart their CI/CD pipeline. Are you using that project as a starting point?

My particular client mentioned above was. In that case, I added those Ant targets in the buildDeployer.xml file and I simply placed the XSLT file it in a resources folder within that same project.

If you’re not using that GitHub project as a starting point, then you wouldn’t perhaps use the snippets above. For example, in my current project where we’re using a Gitlab pipeline, I felt it was easier and simpler to just code everything in bash. The particular line that handles variable substitution looks like this:

$DEP_HOME/bin/Deployer.sh --import -varsub -vsFile $VARSUB_ENV_FILE -map defaultMap -project cicdProject -validate true -host $DEPLOYER_HOST -port $DEPLOYER_PORT -user $DEPLOYER_USER -pwd $DEPLOYER_PWD -force

It’s still a work in progress.

Hope this helps,
Percio

I’m not using GitHub project. Since I’m using Azure pipeline and also using bash script inside yaml file to run the above command (–import -varsub) but having question here correct me if anything wrong here.

let say yesterday i have created my VS file from wmDeployer UI page by selecting specific services then the file is created under this path /home/user/SAG/IntegrationServer/instances/default/packages/WmDeployer/replicate/outbound, now the question is do i need create VS for each services like manually by using WmDeployer UI page or we can use single vs file as template and we and keep VS file is common for all the services we can change only required parameter from our azure pipeline using bash script.

I have a single vs file for each environment, i.e. development.vs, testing.vs, staging.vs, and production.vs. Each vs file has all the variable substitutions for that environment.

Percio

Thanks for the details again, i will create file as template from wmdeployer ui page then i will keep name as enviornment specific then while running pipeline i will find and replace value before run deployment command.

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.