Skip to content
Permalink
master
Switch branches/tags
Go to file
 
 
Cannot retrieve contributors at this time
# This file is a sample build configuration for Docker.
# See the guides at https://confluence.atlassian.com/x/O1toN for more examples.
# Only use spaces to indent your .yml configuration.
# -----
# You can specify a custom docker image from Docker Hub as your build environment.
image: atlassian/default-image:2
pipelines:
default: #These commands run for all branches unless specified otherwise
- step:
script:
#Assign variables
- export CLIURL=https://developer.salesforce.com/media/salesforce-cli/sfdx/channels/stable/sfdx-linux-x64.tar.xz
- export SFDX_AUTOUPDATE_DISABLE=false
- export SFDX_USE_GENERIC_UNIX_KEYCHAIN=true
- export SFDX_DOMAIN_RETRY=300
- export SFDX_DISABLE_APP_HUB=true
- export SFDX_LOG_LEVEL=DEBUG
- export ROOTDIR=force-app/main/default/
- export TESTLEVEL=RunLocalTests
#Be sure to update the package ID (package ID starts with OHo) or package alias here from the sfdx-project.json file
- export PACKAGENAME="0Ho4x000000XZOaCAO"
- export PACKAGEVERSION=""
#Create sfdx directory
- mkdir ~/sfdx
#Install Salesforce CLI
#By default, the script installs the current version of Salesforce CLI. To install the release candidate, set the DX_CLI_URL_CUSTOM local variable to the appropriate URL
- wget -qO- ${DX_CLI_URL_CUSTOM-$CLIURL} | tar xJ -C ~/sfdx --strip-components 1
- export PATH=~/sfdx/bin:$PATH
- sfdx --version
- sfdx plugins --core
#Install JSON processor
- apt-get install -y jq
#Decrypt server key
- openssl enc -nosalt -aes-256-cbc -d -in assets/server.key.enc -out assets/server.key -base64 -K $DECRYPTION_KEY -iv $DECRYPTION_IV
#Authorize Dev Hub
- sfdx force:auth:jwt:grant --clientid $HUB_CONSUMER_KEY --jwtkeyfile assets/server.key --username $HUB_USER_NAME --setdefaultdevhubusername --setalias HubOrg
#Create scratch org
- sfdx force:org:create --targetdevhubusername HubOrg --setdefaultusername --definitionfile config/project-scratch-def.json --setalias ciorg --wait 10 --durationdays 1
- sfdx force:org:display --targetusername ciorg
#Push source to scratch org
- sfdx force:source:push --targetusername ciorg
#Run unit tests on scratch org
- sfdx force:apex:test:run --targetusername ciorg --wait 10 --resultformat tap --codecoverage --testlevel $TESTLEVEL
#Delete scratch org
- sfdx force:org:delete --targetusername ciorg --noprompt
#Create package version
- PACKAGEVERSION="$(sfdx force:package:version:create --package $PACKAGENAME --installationkeybypass --wait 10 --json --targetdevhubusername HubOrg | jq '.result.SubscriberPackageVersionId' | tr -d '"')"
- echo "Package Version Id - "${PACKAGEVERSION}
#Create scratch org
- sfdx force:org:create --targetdevhubusername HubOrg --setdefaultusername --definitionfile config/project-scratch-def.json --setalias installorg --wait 10 --durationdays 1
- sfdx force:org:display --targetusername installorg
#Install package in scratch org
- sfdx force:package:install --package $PACKAGEVERSION --publishwait 10 --wait 10 --targetusername installorg
#Run unit tests on scratch org
- sfdx force:apex:test:run --targetusername installorg --wait 10 --resultformat tap --codecoverage --testlevel $TESTLEVEL
#Delete scratch org
- sfdx force:org:delete --targetusername installorg --noprompt