Websphere Commerce (WCS) is e-Commerce software platform. It supports multiple business models to support a wide range of customer requirements. WCS did not have Git support till version 8.  It has introduced Git support from version 9 onwards. Git is a free open source distributed source control management software. This blog we are going to discuss Git configuration with WCS build.

Prerequisite:

Copy2 the template file from wcbd template to wcbd  folder and update the names as given below.

gras

Configure build.property to pick new extract-git.xml

extract.ant.file=${basedir}/extract-git.xml

Configure git URL and default branch or tag name in extract-git.properties.

#-------------------------------------------------------------------------------
# git.url
#
# The git url variable. On Windows, use the escaped backslash (\) as the path
# separator if repository is local.
#-------------------------------------------------------------------------------
git.url=yourgitip:yourgit:port/yourprojectname.git

#-------------------------------------------------------------------------------
# git.branchOrTag
#
# The branch or tag of the package/module to check out.
#-------------------------------------------------------------------------------
git.branchOrTag=development

 Configure git username and password in extract-git.private.properties

Run the build and test it using the following command.

git.password=<someusername>
git.username=<somepassword>

Update the extract-git.xml with below ant code.

<project name="extract-git" default="all">

  <available property="found.${ant.project.name}.properties"
             file="${basedir}/${ant.project.name}.properties"
             type="file" />
  <fail message="${basedir}/${ant.project.name}.properties does not exist."
        unless="found.${ant.project.name}.properties" />
  <property file="${basedir}/${ant.project.name}.properties" />

  <encodeProperties file="${ant.project.name}.private.properties" />
  <decodeLoadProperties file="${ant.project.name}.private.properties" />

  <!--
   Runs the source extraction process.
  -->
  <target name="all">
    <condition property="branchOrTag" value="${build.branchOrTag}" else="${git.branchOrTag}">
        <isset property="build.branchOrTag"/>
    </condition>
    <if>
      <istrue value="${extract.update.mode}" />
      <then>
        <if>
          <available file="${module.dir}" type="dir" />
          <then>
            <echo message = "GIT Command: git pull --tags" />
            <exec executable = "git" dir = "${module.dir}" failonerror="true">
              <arg value = "pull" />
              <arg value = "--tags" />
            </exec>
            <echo message = "GIT Command: git reset --hard origin/${branchOrTag}" />
            <exec executable = "git" dir = "${module.dir}" failonerror="true">
              <arg value = "reset" />
              <arg value = "--hard" />
              <arg value = "origin/${branchOrTag}" />
            </exec>
          </then>
          <else>
            <echo message = "GIT Command: git clone -b ${branchOrTag} http://${git.username}:${git.password}@${git.url}" />
            <exec executable = "git" dir = "${source.dir}" failonerror="true">
              <arg value = "clone" />
              <arg value = "-b" />
              <arg value = "${branchOrTag}" />
              <arg value = "http://${git.username}:${git.password}@${git.url}" />
            </exec>
          </else>
        </if>
      </then>
      <else>
        <echo message = "GIT Command: git clone -b ${branchOrTag} http://${git.username}:${git.password}@${git.url}" />
        <exec executable = "git" dir = "${source.dir}" failonerror="true">
          <arg value = "clone" />
          <arg value = "-b" />
          <arg value = "${branchOrTag}" />
          <arg value = "http://${git.username}:${git.password}@${git.url}" />
        </exec>
      </else>
    </if>
    <defaultexcludes add="CVSROOT/**" />
  </target>

</project>

Run the build and test it using the following command.

./wcbd-ant -buildfile wcbd-build.xml This is all about configuring Git with WCBD ant script. This script covers build in both the modes full and update. Also, this build supports code checkout form tag and branch both.