Search This Blog

Thursday, May 29, 2014

Replace characters Using ANT

There is an inbuilt task given in ant library called 'replaceregexp'. This task is used to check about a specific pattern i.e. a regular expression and replace them with a different pattern in a single file or set of files.

Replace in a set of files

<replaceregexp match="test" replace="replacedTest" flags="gm" byline="false">
            <fileset dir="${sf.srcdir}" includes="*.txt" />
</replaceregexp>
The above task will look at all the files ending with extension 'txt' in the source directory given as 'sf.srcdir' in the properties file. In all those files, it tries to find the pattern 'test' and replaces with pattern 'replacedTest'

Fail an ANT build if a property is not set

Any number of properties can be used in ANT build.xml. They can be environment variables or variables set in a properties file.

There is an ability to check if required properties are set or not i.e. included or not in the properties file. Also we can match them to a regular expression to see of they are empty or matching as per the requirement. If they do not match the requirement, the build can be made to fail. There is a fail task provided by the ant library to fail the build. Add this as first task before adding any cutom tasks.

Including Properties File

You can include a properties file or environmental variables in build.xml in the below way
    <property file="build.properties"/>
    <property environment="env"/>


Tuesday, May 13, 2014

Copy files from Local to remote using ssh

In order to copy files from local to a remote system using ssh, there should be an  authorized user with a pem file. And also for that particular user in the remote system, there should be proper permissions for the destination.

Remote System

  • Login to the remote server using putty or through powershell.
  • Navigate to the destination folder
            > cd <destination>
  • Change the permissions using the below command
            > chmod -R 777 *

Monday, May 12, 2014

How to Restart Jenkins


  • Login to the Jenkins server using powershell or Putty
  • In order to check of the jenkins process is running or not; execute the below command; This will give you the process Id if it is running.
                        > ps -ef | grep jenkins
  • Jenkins service can be started/stopped/restarted only as a root user. So change to the root user and do the action as below
                        > sudo su
                        > sudo service jenkins start
  • If the service is not detected using this script; do the following
                       > /etc/init.d/jenkins start
  • The above command will start your jenkins server. Now open the Jenkins web page in browser and check for the status.


Thursday, May 8, 2014

Login through putty using pem file

Putty needs a private key to make an ssh call. Puttygen is used to generate the private key from the pem file.

PuttyGen is a key generation tool. This is an RSA and DSA key generation utility. This can be used to create new private keys or convert pem files to ppk(private keys).

To convert pem to ppk

  • Install Puttygen from Putty Download and run the exe.
  • Then select the type of key to be generated

Wednesday, May 7, 2014

VisualForce - Make Remote Action Call from Static Resource

Remote Action in Visual Force gives us the ability to make a call asynchronously to the salesforce controller and handle the response in a callback function without making the complete page refresh or waiting for an action. Basically in terms of HTML, this can be treated as an ajax call made through the script tags.

Controller

Lets check the controller now and assume that the namespace of the package is 'namespace'.
  1. global class ControllerName {
  2.    @RemoteAction
  3.     global static String MethodName(Paramters....)
  4.     {
  5.         return 'Hello';
  6.     }
  7. }
All the remote actions are annotated and static.