Deployment tasks

Deploy task

Objective

This task deploys all code from your local code to Salesforce organization, for this as a first step It truncates your local code and deploys those files truncated to Salesforce organization, as second step It deploys your local code to SatesForce organization.

The idea behind deployment process

All code will be deployed to organization using a smart deploy. That means that when you execute the task deploy:

    a) First step is truncate the next elements and deploy it.
    • Classes
    • Objects
    • Triggers
    • Components
    • Pages
    • WorkFlows
    b) Second step is deploy all local code to your organization

Parameters

This task has two parameters called excludes and folders. You can choose folder o folders to deploy it. Also, you are able to exclude files by name, by folder, and using wildcards.

Those parameters can be used as console commands or into your build script.

Executing deploy task

Without parameters

Once this task is executed without parameters it deploys all code to SalesForce organization.

$ gradle deploy

Using folders parameter

You can choose the folders that you want to deploy.

$ gradle deploy -Pfolders=classes
$ gradle deploy -Pfolders=classes,triggers,objects

Using excludes parameter:

User can deploy code excluding some files using excludes parameter.

By folders if you want to exclude a folder or folders, you should write the following parameter:

$ gradle deploy -Pexcludes=classes
$ gradle deploy -Pexcludes=classes,objects.

By files if you want to exclude a file or files, you should write the following parameter: $ gradle deploy -Pexcludes=classes/Class1.cls

using wildcard if you want to exclude using wildcard, you should write the next parameter:

$ gradle deploy  -Pexcludes=classes/**
$ gradle deploy  -Pexcludes=objects/*.object
$ gradle deploy  -Pexcludes=**/*Account*/**
$ gradle deploy  -Pexcludes=**/*.cls

Using help parameter

A user can view the description and the parameters that contains the task by using the help

	$gradle deploy -Phelp

Examples:

Without parameters

Once this task is executed without parameters it deploys all local code to your organization.

command:

$ gradle deploy

Output

    :deploy
    ___________________________________________
            Username: juan.perez@mail.com
            Login type: login
    ___________________________________________

    Deploying truncated code
    [==================================================]   100%
    Truncated code were successfully deployed

    Starting deploy
    [==================================================]   100%
    Code were successfully deployed

    BUILD SUCCESSFUL

Using folders parameters

You can choose folders that will be deployed.

$ gradle deploy -Pfolders=classes,triggers

Output:

    :deploy
    ___________________________________________
            Username: juan.perez@mail.com
            Login type: login
    ___________________________________________

    Starting deploy...
    [==================================================]   100%
    The files were successfully deployed

    BUILD SUCCESSFUL

Using excludes parameters

This command deploys all files from your local respository excluding classes.

 $ gradle deploy -Pexcludes=classes

Output:

    :deploy
    ___________________________________________
            Username: juan.perez@mail.com
            Login type: login
    ___________________________________________

     Deploying truncated code
     [==================================================]   100%
     Truncated code were successfully deployed

     Starting deploy
     [==================================================]   100%
     Code were successfully deployed

     BUILD SUCCESSFUL

This command deploys all code excluding Class1.cls

$ gradle deploy -Pexcludes=classes/Class1.cls

Output:

    :deploy
    ___________________________________________
            Username: juan.perez@mail.com
            Login type: login
    ___________________________________________

    Deploying truncated code
    [==================================================]   100%
    Truncated code were successfully deployed

    Starting deploy
    [==================================================]   100%
    Code were successfully deployed

    BUILD SUCCESSFUL

This command deploys all code excluding a folder class.

$ gradle deploy -Pexcludes=classes/**

Output:

    :deploy
    ___________________________________________
            Username: juan.perez@mail.com
            Login type: login
    ___________________________________________

    Deploying truncated code
    [==================================================]   100%
    Truncated code were successfully deployed

    Starting deploy
    [==================================================]   100%
    Code were successfully deployed

    BUILD SUCCESSFUL

Using help parameter

$ gradle delete -Phelp

Output:

**********************************************************************

                               deploy task

**********************************************************************

Description   :
    Deploys all code from your local code to Salesforce organization

Documentation : 
    http://fundacionjala.github.io/enforce-gradle-plugin/docs/deployment

Parameters :
    -Pfolders : Select which folders will be executed by the process
        > gradle deploy -Pfolders=classes
        > gradle deploy -Pfolders=classes,triggers,objects
    -Pexcludes : Select which files they will be ignored by the process
        > gradle deploy -Pexcludes=classes/Class1.cls
        > gradle deploy -Pexcludes=classes/Class1.cls,classes/Class2.cls
        > gradle deploy -Pexcludes=classes/*.cls,triggers/*.trigger
        > gradle deploy -Pexcludes=classes/**

**********************************************************************

BUILD SUCCESSFUL

Upload task

Objective

This task uploads your code from your local repository to SalesForce organization directly as it is.

Parameters

This task has three parameters called files, excludes and all.

If you want to upload a file or more files, you should use files parameters. It uploads code by file, by folder, and using wildcards.

If you want to exclude some files you should use excludes parameter.

If you want to upload all files from your organization you should use all parameter.

Executing upload task

Without parameters

User can upload all source code to organization, to do this you should execute upload task without any parameters. $ gradle upload

Once this command is executed shows you a warning message that say all files will be uploaded and you have to confirm. To avoid that shows this message you can use parameter all with true value by default is false.

Using files parameter

A user can upload specific files from source code using files parameter. It supports folders, files, and wildcards.

Using excludes parameter

User can deploy code excluding some files using excludes parameter.

By folders if you want to exclude a folder or folders, You should write the following parameter:

    $ gradle upload -Pexcludes=classes
    $ gradle upload -Pexcludes=classes,objects.

By files if you want to exclude a file or files, You should write the following parameter:

    $ gradle upload -Pexcludes=classes/Class1.cls
    $ gradle upload -Pexcludes=classes/Class1.cls,objects/Object1__c.object

Using wildcard if you want to exclude using wildcard, You should write the following parameter:

    $ gradle upload  -Pexcludes=classes/**
    $ gradle upload  -Pexcludes=objects/*.object
    $ gradle upload  -Pexcludes=**/*Account*/**
    $ gradle upload  -Pexcludes=**/*.cls

Examples:

Without parameters

When you run this command, all files are uploaded to an organization.

$ gradle upload

Output:

    :upload
    ___________________________________________
            Username: juan.perez@mail.com
            Login type: login
    ___________________________________________

    Starting deploy...
    [==================================================]   100%
    The files were successfully deployed

    BUILD SUCCESSFUL

Note: Once upload task is executed without parameters, a message is shown to you to confirm and upload all code.

Using files parameter

This command just uploads classes and triggers files.

$ gradle upload -Pfiles=classes,triggers

Output:

    :upload
    ___________________________________________
            Username: juan.perez@mail.com
            Login type: login
    ___________________________________________


    Starting deploy...
    [==================================================]   100%
    The files were successfully deployed

    BUILD SUCCESSFUL

Note: Many Folders can be added

This command uploads class1.cls and trigger1.trigger

$ gradle upload -Pfiles=classes/class1.cls,triggers/trigger1.trigger

Output:

    :upload
    ___________________________________________
            Username: juan.perez@mail.com
            Login type: login
    ___________________________________________


    Starting deploy...
    [==================================================]   100%
    The files were successfully deployed

    BUILD SUCCESSFUL

Note: Many Files can be added

This command uploads Class1.cls and all triggers and all objects.

$ gradle upload -Pfiles=classes/Class1.cls,triggers,objects

Output:

    :upload
    ___________________________________________
            Username: juan.perez@mail.com
            Login type: login
    ___________________________________________


    Starting deploy...
    [==================================================]   100%
    The files were successfully deployed

    BUILD SUCCESSFUL

This command uploads all classes all triggers and all objects.

$ gradle upload -Pfiles=classes/**,triggers,objects

Output:

    :upload
    ___________________________________________
            Username: juan.perez@mail.com
            Login type: login
    ___________________________________________


    Starting deploy...
    [==================================================]   100%
    The files were successfully deployed

    BUILD SUCCESSFUL

Using excludes parameter

This commando uploads all files excluding all classes.

$ gradle upload -Pexcludes=classes

Output:

    > gradle upload
    :upload
    ___________________________________________
            Username: juan.perez@mail.com
            Login type: login
    ___________________________________________

     Starting deploy...
     [==================================================]   100%
     The files were successfully deployed

     BUILD SUCCESSFUL

This command uploads all files excluding Class1.cls

$ gradle upload -Pexcludes=classes/Class1.cls

Output:

    > gradle upload
    :upload
    ___________________________________________
            Username: juan.perez@mail.com
            Login type: login
    ___________________________________________

   Starting deploy...
   [==================================================]   100%
   The files were successfully deployed

    BUILD SUCCESSFUL

This command uploads all files excluding all classes.

$ gradle upload -Pexcludes=classes/**

Output:

    > gradle upload
    :upload
    ___________________________________________
            Username: juan.perez@mail.com
            Login type: login
    ___________________________________________

    Starting deploy...
    [==================================================]   100%
    The files were successfully deployed

    BUILD SUCCESSFUL

Using help parameter

$ gradle upload -Phelp

Output:

**************************************************************************

                               upload task

**************************************************************************

Description   :
    Uploads your code from your local repository to SalesForce 
    organization directly as it is

Documentation : 
    http://fundacionjala.github.io/enforce-gradle-plugin/docs/deployment

Parameters :
    -Pfiles : Select which files will be executed by the process
        > gradle upload -Pfiles=classes/Class1.cls
        > gradle upload -Pfiles=classes/Class1.cls,classes/Class2.cls
        > gradle upload -Pfiles=classes/*.cls,triggers/*.trigger
        > gradle upload -Pfiles=classes/**
    -Pexcludes : Select which files they will be ignored by the process
        > gradle upload -Pexcludes=classes/Class1.cls
        > gradle upload -Pexcludes=classes/Class1.cls,classes/Class2.cls
        > gradle upload -Pexcludes=classes/*.cls,triggers/*.trigger
        > gradle upload -Pexcludes=classes/**

**************************************************************************

BUILD SUCCESSFUL

Limitations of Upload task