Permalink
Switch branches/tags
Nothing to show
Find file Copy path
Fetching contributors…
Cannot retrieve contributors at this time
234 lines (230 sloc) 7.61 KB
version: 2
# Defining default values for all jobs
defaults: &defaults
docker:
- image: circleci/node:latest
jobs:
setup_dx:
# This command runs the preparation steps needed for the CI workflow:
#
# - Installation of the Salesforce CLI using npm
# - Authentication of the DevHub
# - Creation of a scratch org
#
# While a scratch org isn't needed in all steps it's still part of the process. The reason for this is
# that we need to store the sfdx configuration files for it in the workspace, so that data can be shared
# across different workflow steps.
#
# Keep it simple!
<<: *defaults
steps:
- checkout
- run:
name: Install Salesforce DX
command: |
openssl enc -nosalt -aes-256-cbc -d -in .circleci/server.key.enc -out .circleci/server.key -base64 -K $DECRYPTION_KEY -iv $DECRYPTION_IV
export SFDX_USE_GENERIC_UNIX_KEYCHAIN=true
export SFDX_DOMAIN_RETRY=300
npm install sfdx-cli
node_modules/sfdx-cli/bin/run --version
node_modules/sfdx-cli/bin/run plugins --core
- run:
name: Authenticate DevHub
command: |
node_modules/sfdx-cli/bin/run force:auth:jwt:grant --clientid $CONSUMERKEY --jwtkeyfile .circleci/server.key --username $USERNAME --setdefaultdevhubusername -a HubOrg
- run:
name: Define CI Org
# We define the to be used CI org. Based on the branch we either create a new scratch org
# or we use a project variable to authenticate a UAT or full-copy sandbox as target org.
#
# You can get the sfdxurl via sfdx force:org:display -u yourOrg --json --verbose from your local machine.
command: |
if [[ "${CIRCLE_BRANCH}" = "develop" ]]; then
echo $SFDX_AUTH_URL_FULL_COPY > ~/auth.url
node_modules/sfdx-cli/bin/run force:auth:sfdxurl:store -s -a ciorg -f ~/auth.url
elif [[ "${CIRCLE_BRANCH}" = "packaging" ]]; then
echo $SFDX_AUTH_URL_UAT > ~/auth.url
node_modules/sfdx-cli/bin/run force:auth:sfdxurl:store -s -a ciorg -f ~/auth.url
elif [[ "${CIRCLE_BRANCH}" = *"feature/"* ]]; then
node_modules/sfdx-cli/bin/run force:org:create -v HubOrg -s -f config/project-scratch-def.json -a ciorg -d 1
elif [[ "${CIRCLE_BRANCH}" = *"packaging/"* ]]; then
node_modules/sfdx-cli/bin/run force:org:create -v HubOrg -s -f config/project-scratch-def.json -a ciorg -d 1
fi
- persist_to_workspace:
# This is an important step. If we don't store the project data (cloned GitHub source and node_modules from the CLI installation)
# we'd have to re-run installation for every workflow step.
#
# Also this step is crucial as we use it to share sfdx config parameters between steps.
root: ~/
paths:
- .sfdx/*
- project/*
deploy_source:
# This deploys the source to the ci scratch org.
<<: *defaults
steps:
- attach_workspace:
at: ~/
- run:
name: Push Source
command: |
node_modules/sfdx-cli/bin/run force:source:push -u ciorg
create_package_es-base-objects:
# Creating a package for es-base-objects, based on the GitHub branch name.
<<: *defaults
steps:
- attach_workspace:
at: ~/
- run:
name: Create and install package
command: |
scripts/packagingDeployment.sh $CIRCLE_BRANCH
create_package_es-base-code:
# Creating a package for es-base-code, based on the GitHub branch name.
<<: *defaults
steps:
- attach_workspace:
at: ~/
- run:
name: Create and install package
command: |
scripts/packagingDeployment.sh $CIRCLE_BRANCH
create_package_es-base-styles:
# Creating a package for es-base-styles, based on the GitHub branch name.
<<: *defaults
steps:
- attach_workspace:
at: ~/
- run:
name: Create and install package
command: |
scripts/packagingDeployment.sh $CIRCLE_BRANCH
create_package_es-space-mgmt:
# Creating a package for es-space-mgmt, based on the GitHub branch name.
<<: *defaults
steps:
- attach_workspace:
at: ~/
- run:
name: Create and install package
command: |
scripts/packagingDeployment.sh $CIRCLE_BRANCH
install_packages_uat:
# Deploys packages to UAT sandbox.
<<: *defaults
steps:
- attach_workspace:
at: ~/
- run:
name: Deploy UAT
command: |
scripts/packagingDeployment.sh $CIRCLE_BRANCH
install_packages_full-copy-sandbox:
# Deploys packages to full copy sandbox.
<<: *defaults
steps:
- attach_workspace:
at: ~/
- run:
name: Deploy full-copy
command: |
scripts/packagingDeployment.sh $CIRCLE_BRANCH
run_apex_tests:
<<: *defaults
steps:
- attach_workspace:
at: ~/
- run:
name: Run Apex Tests
command: |
node_modules/sfdx-cli/bin/run force:apex:test:run -u ciorg -c -r human
cleanup_scratch_org:
<<: *defaults
steps:
- attach_workspace:
at: ~/
- run:
name: Clean Up
command: |
node_modules/sfdx-cli/bin/run force:org:delete -u ciorg -p
workflows:
version: 2
build_and_test:
jobs:
- setup_dx:
filters:
branches:
only:
- /feature/.*/
- /packaging/.*/
- packaging
- develop
- deploy_source:
requires:
- setup_dx
filters:
branches:
only: /feature/.*/
- create_package_es-base-objects:
requires:
- setup_dx
filters:
branches:
only: packaging/es-base-objects
- create_package_es-base-code:
requires:
- setup_dx
filters:
branches:
only: packaging/es-base-code
- create_package_es-base-styles:
requires:
- setup_dx
filters:
branches:
only: packaging/es-base-styles
- create_package_es-space-mgmt:
requires:
- setup_dx
filters:
branches:
only: packaging/es-space-mgmt
- install_packages_uat:
requires:
- setup_dx
filters:
branches:
only: packaging
- install_packages_full-copy-sandbox:
requires:
- setup_dx
filters:
branches:
only: develop
- run_apex_tests:
requires:
- deploy_source
- create_package_es-base-objects
- create_package_es-base-code
- create_package_es-base-styles
- create_package_es-space-mgmt
- install_packages_uat
- install_packages_full-copy-sandbox
filters:
branches:
ignore: master
- cleanup_scratch_org:
requires:
- setup_dx
- deploy_source
- create_package_es-base-objects
- create_package_es-base-code
- create_package_es-base-styles
- create_package_es-space-mgmt
- run_apex_tests
filters:
branches:
ignore:
- master
- develop
- packaging