This project downloads metadata from Salesforce orgs and can run test cases.
It should work out of the box with Jenkins, I have tried it with some modifications with Visualstudio.com but ran into troubles regarding commiting back to the built in GIT repository.
You need a Jenkins instance with Ant and Git, optionally you can add the Slack notifier to get notifications in Slack about the jobs.
Add these 3 global variables to Jenkins (Under http://jenkinsinstance/jenkins/configure)
- GIT_PATH = your_absolute_path_to_git
- GIT_USER_EMAIL = email_address_of_your_git_user
- GIT_USER_NAME = full_name_of_your_git_user
-
Create a new job in Jenkins.
-
Check the "This project is parameterized" checkbox
-
Add 2 String parameters
- SF_SERVERURL = https://login.salesforce.com
(If you're taking a backup from a sandbox login should be test) - SF_ENVIRONMENTNAME = {whatever_you_like}
(The environmentname is just a string used to give your backup a unique path (src/$SF_ENVIRONMENTNAME))
- SF_SERVERURL = https://login.salesforce.com
-
Set up your Source Code Management, this should be git since we're commiting to git in the end.
-
Add "Check out to specific local branch" = master, this will make sure that we'll commit back to master later
-
Add a build trigger, Build periodically is the one I recommend
-
Under Build Environment, check "Use secret text(s) or file(s)"
-
Add a "Username and password (separated)" binding with the following information:
- Username Variable = SF_USERNAME
- Password Variable = SF_PASSWORD
- Credentials = Specific credentials
(Make sure to add your Salesforce credentials for this specific Salesforce org, it can be done by clicking the (Key)Add button)
-
Under Build, add
- Execute shell
sh generate_build_properties.sh
- Invoce Ant
Targets
backupMetadata -lib lib\ant-salesforce-41.0.jar
- Execute shell
sh commit_to_git.sh
- Execute shell
-
Under Post-build Actions, add Git Publisher Push Only if Build Succeeds: checked Merge Results: checked Branches
- Branch to push: master
- Target remote name: origin
-
Optionally add the Slack Notifications post build step.
- Repeat steps 1 to 8 from the metadata retreive job (or clone it if you're lazy). You don't need the SF_ENVIRONMENTNAME parameter in step 3 and you can skip step 5 since we're not commiting anything.
- Under Build, add
- Execute shell
sh generate_build_properties.sh
- Invoce Ant
Targets
deployCodeCheckOnly -lib lib\ant-salesforce.jar;lib\ant-contrib-1.0b3.jar
- Execute shell
- Optionally add the Slack Notifications post build step.