Tuesday, August 29, 2017

Set Proxy for Force.com Migration Tool

When you  setup ANT and you believe it being setup correctly but still it still fail when you perform task, there are possibilities that your organization is using proxy.Example error that you receive when you run ant task.

Caused by: com.sforce.ws.ConnectionException: Failed to send request to https://
test.salesforce.com/services/Soap/u/39.0
 Here I list down of steps that I did to overcome this:

  1. Ask Network team what is the proxy host and port in your organization.Is username and password is required?
  2. Define proxy in target.In build.xml , create target name like below.
  3. <target name="proxy">
            <property name="proxy.host" value="xx.xx.xx.xx" />
            <property name="proxy.port" value="xxxx" />
            <!--If there username and password required
      <property name="proxy.user" value="UserName" />
            <property name="proxy.pwd" value="Password" />-->
            <setproxy proxyhost="${proxy.host}" proxyport="${proxy.port}"  />
        </target>
    

  4. Set depends to true for task that you going to perform.For example in given build.xml , I set depends for test and describeMetadata
  5.  <target name="test" depends="proxy"><!--set depends here-->
          <!-- Upload the contents of the "mypkg" package -->
          <sf:deploy username="${sf.username}" password="${sf.password}" sessionId="${sf.sessionId}" serverurl="${sf.serverurl}" maxPoll="${sf.maxPoll}" deployRoot="mypkg" rollbackOnError="true"/>
          <mkdir dir="retrieveOutput"/>
          <!-- Retrieve the contents into another directory -->
          <sf:retrieve username="${sf.username}" password="${sf.password}" sessionId="${sf.sessionId}" serverurl="${sf.serverurl}" maxPoll="${sf.maxPoll}" retrieveTarget="retrieveOutput" packageNames="MyPkg"/>
        </target>
    
    Another example, I set at describeMetadata task.
    <!-- Retrieve the information on all supported metadata type -->
        <target name="describeMetadata" depends="proxy">
          <sf:describeMetadata username="${sf.username}" password="${sf.password}" sessionId="${sf.sessionId}" serverurl="${sf.serverurl}"/>
        </target>
    
Now when I run ant test , the result will be like this :

C:\salesforce_ant_39.0\sample>ant test
Buildfile: C:\salesforce_ant_39.0\sample\build.xml
proxy:
test:
[sf:deploy] Using proxy: xx.xx.xx.xx:xxxx
[sf:deploy] Using proxy: xx.xx.xx.xx:xxxx
[sf:deploy] Request for a deploy submitted successfully.
[sf:deploy] Request ID for the current deploy task: 0Af4E00000QdHqLSAV
[sf:deploy] Waiting for server to finish processing the request...
[sf:deploy] Request Status: Pending
[sf:deploy] Request Status: Pending
[sf:deploy] Request Status: Pending
[sf:deploy] Request Status: Succeeded
[sf:deploy] *********** DEPLOYMENT SUCCEEDED ***********
[sf:deploy] Finished request 0Af4E00000QdHqLSAV successfully.
    [mkdir] Created dir: C:\salesforce_ant_39.0\sample\retrieveOutput
[sf:retrieve] Using proxy: xx.xx.xx.xx:xxxx
[sf:retrieve] Using proxy: xx.xx.xx.xx:xxxx
[sf:retrieve] Request for a retrieve submitted successfully.
[sf:retrieve] Request ID for the current retrieve task: 09S4E0000019PkVUAU
[sf:retrieve] Waiting for server to finish processing the request...
[sf:retrieve] Request Status: Pending
[sf:retrieve] Request Status: Succeeded
[sf:retrieve] Finished request 09S4E0000019PkVUAU successfully.
BUILD SUCCESSFUL
Total time: 1 minute 35 seconds
More details regarding Force.com Migration Tool can be found here.

Wednesday, August 16, 2017

Winmerge give me misguide message.

I am using Winmerge to compare code. For some reason, it give keep saying that the files are different while I really confident that I haven't touch the file.When I open the file , there no difference visibly shown which give me a little headache.


Turn out that I need to modify setting in Winmerge.Go to Edit, click on Options.


Now the view is better.