salesforce-deploy-tool 3.1.0 → 3.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +42 -16
- data/bin/sf +14 -6
- data/features/pull.feature +39 -0
- data/features/push.feature +45 -2
- data/features/resources/mock/ant +51 -5
- data/features/support/env.rb +20 -10
- data/features/support/hooks.rb +1 -1
- data/lib/salesforcedeploytool/app.rb +12 -7
- data/lib/salesforcedeploytool/cli.rb +39 -9
- data/lib/salesforcedeploytool/functions.rb +11 -6
- data/lib/salesforcedeploytool/version.rb +1 -1
- data/tpl/build.xml.erb +0 -6
- metadata +2 -3
- data/build.xml +0 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 564089e30d21649d7dd0d313b63b09c6f8431c73
|
4
|
+
data.tar.gz: e2422efa9dd61c3ee7449a2aef97f0e3ea5ebbed
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 75f26823c0782c45d5e14946d9329d67d26fe91ade750e53c498c0f72322da8aa35431cf478941d95a62d63c879d7e270b1cbbe0d3e4198b8a4f2648de668654
|
7
|
+
data.tar.gz: e77174b0e7782992c9bae765ac69099db86e8b50903c23501b875d22725f5ca208718c9f2c9a30b411a20bf2f4f00d60aca3b43dd6c19ba824321d0a3cb41f0b
|
data/README.md
CHANGED
@@ -1,29 +1,55 @@
|
|
1
|
-
# Salesforce
|
1
|
+
# Salesforce Deploy Tool
|
2
2
|
|
3
|
-
|
3
|
+
Salesforce deploy tool is a command line tool that sits on top of ant to facilitate
|
4
|
+
salesforce deploys.
|
5
|
+
|
6
|
+
## Features
|
7
|
+
|
8
|
+
* push code / pull code / validate / destructive push support
|
9
|
+
* Easier than using ant
|
10
|
+
* Specify environment to deploy using a flag
|
11
|
+
* Exclude and include metadata and metadata types
|
12
|
+
* Destructive Changes autogeneration
|
13
|
+
* GIT integration
|
14
|
+
* Production / Test deployment support
|
15
|
+
* Fast deploy support
|
16
|
+
* Specify different ant libraries so to use different APIs
|
4
17
|
|
5
18
|
## Installation
|
6
19
|
|
7
|
-
|
20
|
+
$ gem install salesforce-deploy-tool
|
8
21
|
|
9
|
-
|
22
|
+
## Quick Start
|
10
23
|
|
11
|
-
|
24
|
+
To generate a configuration file do
|
12
25
|
|
13
|
-
$
|
26
|
+
$ sf config
|
14
27
|
|
15
|
-
|
28
|
+
## Example
|
16
29
|
|
17
|
-
|
30
|
+
For how to use this tool just run:
|
31
|
+
|
32
|
+
$ sf pull -h
|
33
|
+
$ sf push -h
|
34
|
+
|
35
|
+
### specific examples
|
36
|
+
|
37
|
+
```
|
38
|
+
$ sf pull -d
|
39
|
+
$ sf pull -d -s mySandbox
|
40
|
+
$ sf push -T
|
41
|
+
$ sf push -l /path/to/ant-salesforce.jar
|
42
|
+
$ sf push -s prod
|
43
|
+
$ sf push -i apexclass
|
44
|
+
$ sf push -i apexclass -e TestClass -d -s myOtherSandbox
|
45
|
+
$ sf push -a
|
46
|
+
```
|
18
47
|
|
19
|
-
##
|
48
|
+
## Contrib
|
20
49
|
|
21
|
-
|
50
|
+
Feel free to fork and request a pull, or submit a ticket
|
51
|
+
http://github.com/BreinsNet/salesforce-deploy-tool/issues
|
22
52
|
|
23
|
-
##
|
53
|
+
## License
|
24
54
|
|
25
|
-
|
26
|
-
2. Create your feature branch (`git checkout -b my-new-feature`)
|
27
|
-
3. Commit your changes (`git commit -am 'Add some feature'`)
|
28
|
-
4. Push to the branch (`git push origin my-new-feature`)
|
29
|
-
5. Create a new Pull Request
|
55
|
+
This project is available under the MIT license. See LICENSE for details.
|
data/bin/sf
CHANGED
@@ -50,18 +50,26 @@ config[:build_number_pattern] = ENV["SFDT_BUILD_NUMBER_PATTERN"] || config[:
|
|
50
50
|
config[:commit_hash_pattern] = ENV["SFDT_COMMIT_HASH_PATTERN"] || config[:commit_hash_pattern]
|
51
51
|
config[:deploy_ignore_files] = ENV["SFDT_DEPLOY_IGNORE_FILES"].nil? ? config[:deploy_ignore_files] : ENV["SFDT_DEPLOY_IGNORE_FILES"].split(',')
|
52
52
|
|
53
|
+
# Ant options
|
54
|
+
config[:libant] = ENV["SFDT_ANT_LIB"] || config[:libant]
|
55
|
+
|
53
56
|
# Minimal config validation
|
54
|
-
abort "Config error: src_dir not found in #{GLOBAL_CONFIG_FILE} or through SFDT_SRC_DIR"
|
55
|
-
|
56
|
-
abort "Config error:
|
57
|
-
|
58
|
-
abort "Config error:
|
57
|
+
abort "Config error: src_dir not found in #{GLOBAL_CONFIG_FILE} or through SFDT_SRC_DIR" \
|
58
|
+
if config[:src_dir].nil? && !['-v'].include?(ARGV.first)
|
59
|
+
abort "Config error: git_dir not found in #{GLOBAL_CONFIG_FILE} or through SFDT_GIT_DIR" \
|
60
|
+
if config[:git_dir].nil? && !['-v'].include?(ARGV.first)
|
61
|
+
abort "Config error: git_repo not found in #{GLOBAL_CONFIG_FILE} or through SFDT_GIT_DIR" \
|
62
|
+
if config[:git_repo].nil? && !['-v'].include?(ARGV.first)
|
63
|
+
abort "Config error: username not found in #{GLOBAL_CONFIG_FILE} or through SFDT_USERNAME" \
|
64
|
+
if config[:username].nil? && !['config','-v'].include?(ARGV.first)
|
65
|
+
abort "Config error: password not found in #{GLOBAL_CONFIG_FILE} or through SFDT_PASSWORD" \
|
66
|
+
if config[:password].nil? && !['config','-v'].include?(ARGV.first)
|
59
67
|
|
60
68
|
# Create a temporary directory
|
61
69
|
config[:tmp_dir] = Dir.mktmpdir 'sfdt-'
|
62
70
|
|
63
|
-
begin
|
64
71
|
SalesforceDeployTool::CLI.new.run config
|
72
|
+
begin
|
65
73
|
rescue => e
|
66
74
|
puts "ERROR: #{e}"
|
67
75
|
exit 1
|
data/features/pull.feature
CHANGED
@@ -57,3 +57,42 @@ Feature: Pull code from salesforce
|
|
57
57
|
^INFO: Pulling changes from testEnv using url https://test.salesforce.com.*$
|
58
58
|
"""
|
59
59
|
|
60
|
+
@ant
|
61
|
+
Scenario: Retrieve code from the default sandbox with debug output and specifying ant library path
|
62
|
+
When I run `sf pull -d -l lib/ant34.jar`
|
63
|
+
Then the exit status should be 0
|
64
|
+
And the output should match:
|
65
|
+
"""
|
66
|
+
^INFO: Pulling changes from testEnv using url https://test.salesforce.com $
|
67
|
+
^$
|
68
|
+
^AntLibraryFile: .*lib/ant34.jar$
|
69
|
+
^Buildfile: .*$
|
70
|
+
^$
|
71
|
+
^retrieveCode:$
|
72
|
+
"""
|
73
|
+
|
74
|
+
@ant
|
75
|
+
Scenario: Retrieve code from the default sandbox with debug output and specifying ant library path
|
76
|
+
Given I set the environment variables to:
|
77
|
+
| variable | value |
|
78
|
+
| SFDT_ANT_LIB | lib/ant34.jar |
|
79
|
+
When I run `sf pull -d`
|
80
|
+
Then the exit status should be 0
|
81
|
+
And the output should match:
|
82
|
+
"""
|
83
|
+
^INFO: Pulling changes from testEnv using url https://test.salesforce.com $
|
84
|
+
^$
|
85
|
+
^AntLibraryFile: .*lib/ant34.jar$
|
86
|
+
^Buildfile: .*$
|
87
|
+
^$
|
88
|
+
^retrieveCode:$
|
89
|
+
"""
|
90
|
+
|
91
|
+
@ant
|
92
|
+
Scenario: Retrieve code from the default sandbox with debug output and specifying a wrong ant library path
|
93
|
+
When I run `sf pull -d -l lib/invalid_ant34.jar`
|
94
|
+
Then the exit status should be 1
|
95
|
+
And the output should match:
|
96
|
+
"""
|
97
|
+
^error: ant library file .* not found$
|
98
|
+
"""
|
data/features/push.feature
CHANGED
@@ -101,6 +101,7 @@ Feature: Push code to salesforce
|
|
101
101
|
And the output should match /Running Test/
|
102
102
|
And the output should match /DEPLOYMENT SUCCEEDED.*BUILD SUCCESSFUL/
|
103
103
|
|
104
|
+
@test
|
104
105
|
Scenario: Push code to a sandbox with a build number
|
105
106
|
Given I set the environment variables to:
|
106
107
|
| variable | value |
|
@@ -119,7 +120,6 @@ Feature: Push code to salesforce
|
|
119
120
|
^INFO: Deploying code to testEnv:.*OK$
|
120
121
|
"""
|
121
122
|
|
122
|
-
@test
|
123
123
|
Scenario: Push code to a sandbox with the commit hash stamped into a version file
|
124
124
|
Given I set the environment variables to:
|
125
125
|
| variable | value |
|
@@ -280,7 +280,6 @@ Feature: Push code to salesforce
|
|
280
280
|
And the output should match /INFO: Deploying code to testEnv/
|
281
281
|
And the output should match /DEPLOYMENT SUCCEEDED.*BUILD SUCCESSFUL/
|
282
282
|
|
283
|
-
@new
|
284
283
|
Scenario: Push code to a sandbox in debug mode and specifieng specific metadata exclude from destructive change
|
285
284
|
When I run `sf push -e NewVersionTest -d`
|
286
285
|
Then the exit status should be 0
|
@@ -292,3 +291,47 @@ Feature: Push code to salesforce
|
|
292
291
|
And the output should match /excluded: NewVersionTest/
|
293
292
|
And the output should match /INFO: Deploying code to testEnv/
|
294
293
|
And the output should match /DEPLOYMENT SUCCEEDED.*BUILD SUCCESSFUL/
|
294
|
+
|
295
|
+
@ant
|
296
|
+
Scenario: Push code to a sandbox using a different ant library path in debug mode should show the library path in the output
|
297
|
+
Given I set the environment variables to:
|
298
|
+
| variable | value |
|
299
|
+
| SFDT_ANT_LIB | lib/ant34.jar |
|
300
|
+
When I run `sf push -d`
|
301
|
+
Then the exit status should be 0
|
302
|
+
And a file named "repo/salesforce/src/destructiveChanges.xml" should exist
|
303
|
+
And the file "repo/salesforce/src/destructiveChanges.xml" should match /ApexClass|ApexPage/
|
304
|
+
And the output should match:
|
305
|
+
"""
|
306
|
+
^INFO: Deploying code to .*$
|
307
|
+
^$
|
308
|
+
^AntLibraryFile: .*lib/ant34.jar$
|
309
|
+
^Buildfile: .*$
|
310
|
+
^$
|
311
|
+
^deployCode:$
|
312
|
+
"""
|
313
|
+
|
314
|
+
@ant
|
315
|
+
Scenario: Push code to a sandbox using a different ant library path in debug mode should show the library path in the output
|
316
|
+
When I run `sf push -l lib/ant34.jar -d`
|
317
|
+
Then the exit status should be 0
|
318
|
+
And a file named "repo/salesforce/src/destructiveChanges.xml" should exist
|
319
|
+
And the file "repo/salesforce/src/destructiveChanges.xml" should match /ApexClass|ApexPage/
|
320
|
+
And the output should match:
|
321
|
+
"""
|
322
|
+
^INFO: Deploying code to .*$
|
323
|
+
^$
|
324
|
+
^AntLibraryFile: .*lib/ant34.jar$
|
325
|
+
^Buildfile: .*$
|
326
|
+
^$
|
327
|
+
^deployCode:$
|
328
|
+
"""
|
329
|
+
|
330
|
+
@ant
|
331
|
+
Scenario: Push code to a sandbox using a invalid ant library path should fail
|
332
|
+
When I run `sf push -l lib/invalid_ant34.jar`
|
333
|
+
Then the exit status should be 1
|
334
|
+
And the output should match:
|
335
|
+
"""
|
336
|
+
^error: ant library file .* not found$
|
337
|
+
"""
|
data/features/resources/mock/ant
CHANGED
@@ -1,6 +1,17 @@
|
|
1
1
|
#!/bin/bash
|
2
2
|
|
3
|
-
|
3
|
+
if [[ $1 == '-lib' ]] ;then
|
4
|
+
COMMAND=$3
|
5
|
+
ANTLIB=$2
|
6
|
+
else
|
7
|
+
COMMAND=$1
|
8
|
+
ANTLIB=$2
|
9
|
+
fi
|
10
|
+
|
11
|
+
if [[ ! -z $ANTLIB ]] && [[ ! -f $ANTLIB ]]; then
|
12
|
+
echo "ERROR: ANT lib path not found"
|
13
|
+
exit 1
|
14
|
+
fi
|
4
15
|
|
5
16
|
if [[ -z $SF_SRC_DIR ]]; then
|
6
17
|
echo "ERROR: SF_SRC_DIR Not defined"
|
@@ -75,7 +86,7 @@ case $COMMAND in
|
|
75
86
|
# Add two more classes and two more pages so to simulate
|
76
87
|
# Destructive changes
|
77
88
|
cd $SF_SRC_DIR
|
78
|
-
git reset --hard
|
89
|
+
git reset --hard > /dev/null 2>&1
|
79
90
|
old_dir=`pwd`
|
80
91
|
cd $SF_SRC_DIR/classes
|
81
92
|
ls|tail -2|while read class;do cp $class New$class;done
|
@@ -146,8 +157,40 @@ BUILD SUCCESSFUL
|
|
146
157
|
EOF
|
147
158
|
fi
|
148
159
|
;;
|
149
|
-
"deployAndTestCode"
|
150
|
-
|
160
|
+
"deployAndTestCode")
|
161
|
+
cat << EOF
|
162
|
+
Buildfile: ${PWD}/build.xml
|
163
|
+
|
164
|
+
${COMMAND}:
|
165
|
+
[sf:deploy] Request for a deploy submitted successfully.
|
166
|
+
[sf:deploy] Request ID for the current deploy task: 0Af2400000a0FeVCAU
|
167
|
+
[sf:deploy] Waiting for server to finish processing the request...
|
168
|
+
[sf:deploy] Request Status: Pending
|
169
|
+
[sf:deploy] Request Status: InProgress (94/1473) -- Processing Type: CustomObject
|
170
|
+
[sf:deploy] Request Status: InProgress
|
171
|
+
[sf:deploy] Request Status: InProgress (1204/1473) -- Processing Type: ApprovalProcess
|
172
|
+
[sf:deploy] Request Status: InProgress (1212/1473) -- Processing Type: ApexClass
|
173
|
+
[sf:deploy] Request Status: InProgress (1212/1473) -- Processing Type: ApexClass
|
174
|
+
[sf:deploy] Request Status: InProgress (1442/1473) -- Processing Type: PermissionSet
|
175
|
+
[sf:deploy] Request Status: InProgress (7/227) -- Running Test: FooClassTest
|
176
|
+
[sf:deploy] Request Status: InProgress (26/227) -- Running Test: BarClassTest
|
177
|
+
[sf:deploy] Request Status: Succeeded
|
178
|
+
[sf:deploy] *********** DEPLOYMENT SUCCEEDED ***********
|
179
|
+
[sf:deploy] Finished request 0Af2400000a0FeVCAU successfully.
|
180
|
+
|
181
|
+
BUILD SUCCESSFUL
|
182
|
+
EOF
|
183
|
+
;;
|
184
|
+
"deployAndRunSpecifiedTests")
|
185
|
+
if ! grep 'testLevel="RunSpecifiedTests"' build.xml > /dev/null 2>&1; then
|
186
|
+
echo "ERROR: RunSpecifiedTests is not in build.xml"
|
187
|
+
exit 1
|
188
|
+
fi
|
189
|
+
if ! grep -E '<runTest>.*<\/runTest>' build.xml > /dev/null 2>&1; then
|
190
|
+
echo "ERROR: <runTest> tag is not in build.xml"
|
191
|
+
exit 1
|
192
|
+
fi
|
193
|
+
cat << EOF
|
151
194
|
Buildfile: ${PWD}/build.xml
|
152
195
|
|
153
196
|
${COMMAND}:
|
@@ -198,4 +241,7 @@ EOF
|
|
198
241
|
|
199
242
|
esac
|
200
243
|
|
201
|
-
|
244
|
+
# Sleep 2 seconds so that the tests with version files can detect changes on it
|
245
|
+
[[ ! -z $SFDT_VERSION_FILE ]] && sleep 1
|
246
|
+
|
247
|
+
exit 0
|
data/features/support/env.rb
CHANGED
@@ -2,13 +2,6 @@ require 'aruba/cucumber'
|
|
2
2
|
require 'filewatcher'
|
3
3
|
require 'git'
|
4
4
|
|
5
|
-
# Necesary environment variables:
|
6
|
-
ENV["SFDT_GIT_REPO"] = File.join(Dir.pwd,'features/resources/repo')
|
7
|
-
ENV["SFDT_GIT_DIR"] = 'repo'
|
8
|
-
ENV["SFDT_SRC_DIR"] = 'salesforce/src'
|
9
|
-
ENV["SFDT_USERNAME"] = 'john.doe@example.com'
|
10
|
-
ENV["SFDT_PASSWORD"] = 'mysecurepass'
|
11
|
-
ENV["SFDT_SANDBOX"] = 'testEnv'
|
12
5
|
|
13
6
|
# Create a temprary home directory:
|
14
7
|
new_home = File.join(Dir.pwd,'tmp','home')
|
@@ -28,13 +21,30 @@ Before '@config' do
|
|
28
21
|
FileUtils.rm_rf File.join(File.expand_path('~/'),'.sf')
|
29
22
|
end
|
30
23
|
|
31
|
-
|
32
|
-
|
24
|
+
Before '@push,@pull,@config' do
|
25
|
+
|
26
|
+
# Necesary environment variables:
|
27
|
+
ENV["SFDT_GIT_REPO"] = File.join(Dir.pwd,'features/resources/repo')
|
28
|
+
ENV["SFDT_GIT_DIR"] = 'repo'
|
29
|
+
ENV["SFDT_SRC_DIR"] = 'salesforce/src'
|
30
|
+
ENV["SFDT_USERNAME"] = 'john.doe@example.com'
|
31
|
+
ENV["SFDT_PASSWORD"] = 'mysecurepass'
|
32
|
+
ENV["SFDT_SANDBOX"] = 'testEnv'
|
33
|
+
|
34
|
+
# Clone repository
|
33
35
|
uri = ENV['SFDT_GIT_REPO']
|
34
36
|
name = File.join 'tmp', 'aruba', ENV['SFDT_GIT_DIR']
|
35
37
|
Git.clone(uri, name)
|
38
|
+
|
39
|
+
# Simulate a different ant library
|
40
|
+
FileUtils.mkdir File.join 'tmp','aruba','lib'
|
41
|
+
FileUtils.touch File.join 'tmp','aruba','lib','ant34.jar'
|
36
42
|
end
|
37
43
|
|
38
44
|
at_exit do
|
39
|
-
FileUtils.rm 'bin/ant'
|
45
|
+
FileUtils.rm 'bin/ant' if File.exists? 'bin/ant'
|
46
|
+
end
|
47
|
+
|
48
|
+
After do |s|
|
49
|
+
Cucumber.wants_to_quit = true if s.failed?
|
40
50
|
end
|
data/features/support/hooks.rb
CHANGED
@@ -25,6 +25,7 @@ module SalesforceDeployTool
|
|
25
25
|
@commit_hash_pattern = config[:commit_hash_pattern]
|
26
26
|
@username = @sandbox == 'prod' ? @username : @username + '.' + @sandbox
|
27
27
|
@server_url = config[:salesforce_url]
|
28
|
+
@libant = File.expand_path(config[:libant]) if config[:libant]
|
28
29
|
|
29
30
|
# Defaults
|
30
31
|
@check_only = false
|
@@ -109,7 +110,9 @@ module SalesforceDeployTool
|
|
109
110
|
env_vars += " SF_USERNAME=" + @username
|
110
111
|
env_vars += " SF_PASSWORD=" + @password
|
111
112
|
env_vars += " SF_SERVERURL=" + @server_url
|
112
|
-
cmd = " ant
|
113
|
+
cmd = " ant"
|
114
|
+
cmd += " -lib #{@libant}" if @libant
|
115
|
+
cmd += " retrieveCode"
|
113
116
|
|
114
117
|
full_cmd = env_vars + cmd
|
115
118
|
|
@@ -167,21 +170,23 @@ module SalesforceDeployTool
|
|
167
170
|
exec_options[:failmsg] = nil
|
168
171
|
end
|
169
172
|
|
173
|
+
ant_cmd = " ant"
|
174
|
+
ant_cmd += " -lib #{@libant}" if @libant
|
170
175
|
if @run_all_tests
|
171
|
-
cmd = "
|
176
|
+
cmd = " deployAndTestCode"
|
172
177
|
else
|
173
178
|
if ! @run_tests.empty?
|
174
|
-
cmd = "
|
179
|
+
cmd = " deployAndRunSpecifiedTests"
|
175
180
|
else
|
176
|
-
cmd = "
|
181
|
+
cmd = " deployCode"
|
177
182
|
end
|
178
183
|
end
|
179
184
|
|
180
185
|
if @check_only
|
181
|
-
cmd = "
|
186
|
+
cmd = " checkOnlyCode"
|
182
187
|
end
|
183
|
-
|
184
|
-
full_cmd = env_vars + cmd
|
188
|
+
|
189
|
+
full_cmd = env_vars + ant_cmd + cmd
|
185
190
|
|
186
191
|
# Delete files to be ignored:
|
187
192
|
@deploy_ignore_files.each do |file|
|
@@ -16,9 +16,6 @@ module SalesforceDeployTool
|
|
16
16
|
abort "ERROR: The source directory #{full_src_dir} is not a valid salesforce source directory"
|
17
17
|
end
|
18
18
|
|
19
|
-
# Chdir to working directory
|
20
|
-
Dir.chdir config[:tmp_dir]
|
21
|
-
|
22
19
|
# saleforce-deploy-tool version and description
|
23
20
|
program :version, SalesforceDeployTool::VERSION
|
24
21
|
program :description, 'A cli tool to help manage and deploy salesforce sandboxes with git'
|
@@ -32,34 +29,49 @@ module SalesforceDeployTool
|
|
32
29
|
c.option "--append", "Pull code appending it to the local repository"
|
33
30
|
c.option "--debug", "Verbose output"
|
34
31
|
c.option "--sandbox NAME", "-s NAME", "use 'prod' to deploy production or sandbox name"
|
32
|
+
c.option "--lib-ant PATH", "-l PATH", "Path to the ant-library to use"
|
35
33
|
c.action do |args, options|
|
36
34
|
|
37
35
|
# short flag mapping
|
38
36
|
options.sandbox = options.s if options.s
|
37
|
+
options.libant = options.l if options.l
|
39
38
|
|
40
39
|
# Parameter validation:
|
41
40
|
if options.sandbox.nil? and config[:sandbox].nil?
|
42
41
|
puts "error: please specify sandbox using --sandbox or sf sandbox"
|
43
42
|
exit 1
|
44
43
|
end
|
44
|
+
|
45
|
+
if options.libant && !File.exists?(File.expand_path options.libant)
|
46
|
+
puts "error: ant library file #{options.libant} not found"
|
47
|
+
exit 1
|
48
|
+
end
|
49
|
+
|
50
|
+
# Config array
|
51
|
+
config[:libant] = config[:libant] || options.libant
|
52
|
+
config[:libant] = File.expand_path(config[:libant]) if config[:libant]
|
45
53
|
config[:sandbox] = options.sandbox if options.sandbox
|
46
54
|
config[:debug] = options.debug.nil? ? false : true
|
47
|
-
|
48
|
-
# The salesforce URL
|
49
55
|
config[:salesforce_url] =
|
50
56
|
ENV["SFDT_SALESFORCE_URL"] || # First from environment variables
|
51
57
|
config[:salesforce_url] || # Second from the configuration files
|
52
58
|
( config[:sandbox] == 'prod' ? 'https://login.salesforce.com' : 'https://test.salesforce.com' ) # If not defined anywhere, use defaults
|
53
59
|
|
60
|
+
# Chdir to working directory
|
61
|
+
Dir.chdir config[:tmp_dir]
|
62
|
+
|
54
63
|
# Initialize
|
55
64
|
sfdt = SalesforceDeployTool::App.new config
|
56
65
|
|
57
66
|
# Clean all files from repo
|
58
67
|
sfdt.clean_git_dir unless options.append
|
59
68
|
|
60
|
-
#
|
69
|
+
# output message
|
61
70
|
print "INFO: Pulling changes from #{config[:sandbox]} using url #{config[:salesforce_url]} "
|
62
71
|
print "\n\n" if options.debug
|
72
|
+
print "AntLibraryFile: #{config[:libant]}\n" if config[:libant] && options.debug
|
73
|
+
|
74
|
+
# Pull
|
63
75
|
sfdt.pull
|
64
76
|
sfdt.clean_version
|
65
77
|
|
@@ -81,6 +93,7 @@ module SalesforceDeployTool
|
|
81
93
|
c.option "--run-tests CSV_LIST", "-r CSV_LIST", "a CSV list of individual classes to run tests"
|
82
94
|
c.option "--check-only", "-c", "Check only, don't deploy"
|
83
95
|
c.option "--include CSV_LIST", "-i CSV_LIST", "A CSV list of metadata type to include when creating destructiveChange.xml"
|
96
|
+
c.option "--lib-ant PATH", "-l PATH", "Path to the ant-library to use"
|
84
97
|
c.action do |args, options|
|
85
98
|
|
86
99
|
# short flag mapping
|
@@ -90,6 +103,7 @@ module SalesforceDeployTool
|
|
90
103
|
options.exclude = options.x if options.x
|
91
104
|
options.sandbox = options.s if options.s
|
92
105
|
options.include = options.i if options.i
|
106
|
+
options.libant = options.l if options.l
|
93
107
|
|
94
108
|
# Parameter validation:
|
95
109
|
if options.run_all_tests and options.run_tests
|
@@ -100,15 +114,25 @@ module SalesforceDeployTool
|
|
100
114
|
puts "error: please specify the sandbox to pull from using --sandbox"
|
101
115
|
exit 1
|
102
116
|
end
|
117
|
+
|
118
|
+
if options.libant && !File.exists?(File.expand_path options.libant)
|
119
|
+
puts "error: ant library file #{options.libant} not found"
|
120
|
+
exit 1
|
121
|
+
end
|
122
|
+
|
123
|
+
# Config array
|
124
|
+
config[:libant] = config[:libant] || options.libant
|
125
|
+
config[:libant] = File.expand_path(config[:libant]) if config[:libant]
|
103
126
|
config[:sandbox] = options.sandbox if options.sandbox
|
104
127
|
config[:debug] = options.debug.nil? ? false : true
|
105
|
-
|
106
|
-
# The salesforce URL
|
107
128
|
config[:salesforce_url] =
|
108
129
|
ENV["SFDT_SALESFORCE_URL"] || # First from environment variables
|
109
130
|
config[:salesforce_url] || # Second from the configuration files
|
110
131
|
( config[:sandbox] == 'prod' ? 'https://login.salesforce.com' : 'https://test.salesforce.com' ) # If not defined anywhere, use defaults
|
111
132
|
|
133
|
+
# Chdir to working directory
|
134
|
+
Dir.chdir config[:tmp_dir]
|
135
|
+
|
112
136
|
# Initialize
|
113
137
|
sfdt = SalesforceDeployTool::App.new config
|
114
138
|
|
@@ -123,8 +147,11 @@ module SalesforceDeployTool
|
|
123
147
|
FileUtils.cp_r config[:git_dir],config_tmp[:git_dir]
|
124
148
|
sfdt_tmp = SalesforceDeployTool::App.new config_tmp
|
125
149
|
sfdt_tmp.clean_git_dir
|
150
|
+
|
126
151
|
print "INFO: Pulling changes from #{config[:sandbox]} using url #{config[:salesforce_url]} to temporary directory to generate destructiveChanges.xml "
|
127
152
|
print( options.debug.nil? ? "" : "\n\n" )
|
153
|
+
print "AntLibraryFile: #{config[:libant]}\n" if config[:libant] && options.debug
|
154
|
+
|
128
155
|
sfdt_tmp.pull
|
129
156
|
|
130
157
|
# Create destructiveChanges.xml
|
@@ -153,9 +180,12 @@ module SalesforceDeployTool
|
|
153
180
|
# Check only option:
|
154
181
|
sfdt.check_only = options.check_only
|
155
182
|
|
156
|
-
#
|
183
|
+
# Output message:
|
157
184
|
print( options.run_all_tests.nil? && options.run_tests.nil? ? "INFO: Deploying code to #{config[:sandbox]}: ": "INFO: Deploying and Testing code to #{config[:sandbox]}: " )
|
158
185
|
print( options.debug.nil? ? "" : "\n\n" )
|
186
|
+
print "AntLibraryFile: #{config[:libant]}\n" if config[:libant] && options.debug
|
187
|
+
|
188
|
+
# Push
|
159
189
|
sfdt.push
|
160
190
|
ensure
|
161
191
|
sfdt.clean_version
|
@@ -47,16 +47,20 @@ def myexec cmd, opts = {}
|
|
47
47
|
# try to read. Loop every 1 second over and over the same process until
|
48
48
|
# the process finishes or timeout is reached.
|
49
49
|
elapsed = 0
|
50
|
-
while wait_thr.status
|
50
|
+
while wait_thr.status && (elapsed = Time.now - start) < opts[:timeout]
|
51
|
+
|
52
|
+
# Monitor stdout and stderr for changes
|
51
53
|
Kernel.select([stdout,stderr],nil,nil,1)
|
52
54
|
|
53
55
|
# Read STDIN in a nonblock way.
|
54
56
|
begin
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
57
|
+
# Read the full buffer
|
58
|
+
while (stdout_line = stdout.read_nonblock(100))
|
59
|
+
print stdout_line if opts[:stdout]
|
60
|
+
stdout_all += stdout_line
|
61
|
+
# spin the pinwheel
|
62
|
+
pinwheel.spin_it if opts[:spinner]
|
63
|
+
end
|
60
64
|
rescue IO::WaitReadable
|
61
65
|
# Exception raised when there is nothing to read
|
62
66
|
rescue EOFError
|
@@ -80,6 +84,7 @@ def myexec cmd, opts = {}
|
|
80
84
|
|
81
85
|
end
|
82
86
|
|
87
|
+
|
83
88
|
# Log stdout output
|
84
89
|
logger.info "\n" + stdout_all if logger and ! stdout_all.empty?
|
85
90
|
logger.error "\n" + stderr_all if logger and ! stderr_all.empty?
|
data/tpl/build.xml.erb
CHANGED
@@ -2,12 +2,6 @@
|
|
2
2
|
|
3
3
|
<property environment="env"/>
|
4
4
|
|
5
|
-
<taskdef resource="com/salesforce/antlib.xml" uri="antlib:com.salesforce">
|
6
|
-
<classpath>
|
7
|
-
<pathelement location="../ant-salesforce.jar" />
|
8
|
-
</classpath>
|
9
|
-
</taskdef>
|
10
|
-
|
11
5
|
<target name="deployCode">
|
12
6
|
<sf:deploy
|
13
7
|
username="${env.SF_USERNAME}"
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: salesforce-deploy-tool
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 3.
|
4
|
+
version: 3.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Juan Breinlinger
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-06-
|
11
|
+
date: 2015-06-09 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -150,7 +150,6 @@ files:
|
|
150
150
|
- README.md
|
151
151
|
- Rakefile
|
152
152
|
- bin/sf
|
153
|
-
- build.xml
|
154
153
|
- features/config.feature
|
155
154
|
- features/misc.feature
|
156
155
|
- features/pull.feature
|
data/build.xml
DELETED
@@ -1 +0,0 @@
|
|
1
|
-
deployCode
|