Add salesforce and force.com ANT tasks to your grunt builds
This plugin requires Grunt ~0.4.0
If you haven't used Grunt before, be sure to check out the Getting Started guide, as it explains how to create a Gruntfile as well as install and use Grunt plugins. Once you're familiar with that process, you may install this plugin with this command:
npm install grunt-ant-sfdc --save-dev
One the plugin has been installed, it may be enabled inside your Gruntfile with this line of JavaScript:
grunt.loadNpmTasks('grunt-ant-sfdc');
The following are options that can be defined for all tasks...
Type: String
Required: true
Your Salesforce.com username
Type: String
Required: true
Your Salesforce.com password
Type: String
Your Salesforce.com password
Type: String
Default value: 'https://login.salesforce.com'
This option sets the api version to use for the package deployment
Type: String
Default value: '27.0'
This option sets the api version to use for the package deployment
Type: Boolean
Default value: false
This option will tell the task to look in environment variables for your Salesforce authentication details. This is really handy for making things secure and not having to put your login details in the Gruntfile. Make sure you set your username SFUSER
, password SFPASS
, and optionally your token SFTOKEN
In your project's Gruntfile, add a section named antdeploy
to the data object passed into grunt.initConfig()
.
grunt.initConfig({
antdeploy: {
options: {
// Task-specific options go here.
},
your_target: {
// Target-specific file lists and/or options go here.
pkg: { // Package to deploy
apexclass: ['*'],
staticresource: ['*']
},
tests: ['TestClass1', 'TestClass2'] // Optional tests to run
},
},
})
Type: String
Default value: 'build/'
The root options sets the base directory where metadata lives
Type: Boolean
Default value: false
This option sets whether this is a checkonly deploy or not
Type: Boolean
Default value: false
This option sets whether or not to run all tests
Type: Boolean
Default value: true
This option sets whether or not to roll back changes on test error
In this example, we will deploy all static resources to a single org
grunt.initConfig({
antdeploy: {
options: {},
// specify one deploy target
dev1: {
options: {
user: '[email protected]',
pass: 'mypassword',
token: 'mytoken',
serverurl: 'https://test.salesforce.com' // default => https://login.salesforce.com
},
pkg: {
staticresource: ['*']
}
}
}
})
In this example, we specify two different org deploy targets with different metadata for each
grunt.initConfig({
antdeploy: {
options: {
root: 'my/metadata/', // note trailing slash is important
version: '27.0'
},
// specify one deploy target
dev1: {
options: {
user: '[email protected]',
pass: 'mypassword',
token: 'mytoken'
},
pkg: {
staticresource: ['*']
}
},
dev2: {
options: {
user: '[email protected]',
pass: 'mypassword2',
token: 'mytoken2'
},
pkg: {
staticresource: ['*']
}
}
}
})
In your project's Gruntfile, add a section named antretrieve
to the data object passed into grunt.initConfig()
.
grunt.initConfig({
antretrieve: {
options: {
// Task-specific options go here.
},
your_target: {
// Target-specific file lists and/or options go here.
pkg: {
// Package to retrieve
}
},
},
})
Type: String
Default value: 'build/'
The root option sets the base directory where metadata lives
Type: String
Default value: '27.0'
This sets the target directory for the retrieve. This will default to the root
if not set.
Type: Boolean
Default value: true
This set whether or not the retrieve should be unzipped upon completion
In this example, we will retrieve all static resources, classes, and apexpages from a single org
grunt.initConfig({
antretrieve: {
options: {
user: '[email protected]',
pass: 'mypass'
},
// specify one retrieve target
dev1: {
serverurl: 'https://test.salesforce.com' // default => https://login.salesforce.com
pkg: {
staticresource: ['*'],
apexclass: ['*'],
apexpage: ['*']
}
}
}
})
In this example, we specify one org but multiple retrieve targets
grunt.initConfig({
antretrieve: {
options: {
root: 'metadata/',
version: '27.0'
},
// specify one deploy target
dev1all: {
options: {
user: '[email protected]',
pass: 'mypassword',
token: 'myauthtoken',
},
pkg: {
staticresource: ['*'],
apexclass: ['*'],
apexpage: ['*']
}
},
dev1classes: {
options: {
user: '[email protected]',
pass: 'mypassword',
token: 'myauthtoken'
},
pkg: {
apexclass: ['*']
}
},
dev1module: {
options: {
user: '[email protected]',
pass: 'mypassword',
token: 'myauthtoken'
},
pkg: {
apexclass: ['MyClass', 'MyClassTest'],
apexpage: ['MyPage'],
staticresource: ['MyPageResource'],
apextrigger: ['MyObjectTrigger']
}
}
}
})
In lieu of a formal styleguide, take care to maintain the existing coding style. Add unit tests for any new or changed functionality. Lint and test your code using Grunt.
(Nothing yet)