-
Notifications
You must be signed in to change notification settings - Fork 15
/
bitbucket-pipelines.yml
126 lines (110 loc) · 4.37 KB
/
bitbucket-pipelines.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
# Bitbucket Pipelines configuration
# For documentation please check: https://support.atlassian.com/bitbucket-cloud/docs/configure-bitbucket-pipelinesyml/
image:
name: salesforce/salesforcedx:latest-full
definitions:
scripts: # This section defines scripts that can be reused in more than one step, using YAML anchors
authToOrg: &authToOrg echo $TARGET_SFDX_AUTH_URL > ./TARGET_SFDX_AUTH_URL.txt && sfdx auth:sfdxurl:store --sfdxurlfile ./TARGET_SFDX_AUTH_URL.txt --setdefaultusername
validateTempFolder: &validateTempFolder if [ ! -d "temp/force-app" ]; then echo "There is not metadata to manage"; exit 0; fi
steps:
- step: &getDeps
name: Get dependencies
caches:
- node
script:
- npm ci
- echo y | sfdx plugins:install sfdx-git-delta
- echo y | sfdx plugins:install @salesforce/sfdx-scanner
- step: &generateDeltaForPr
name: Generate Delta changes for Pull Request
caches:
- node
script:
- mkdir -p temp
# We'll check for metadata changes in the PR so we can scan what's changed and not all
- git merge "origin/$BITBUCKET_PR_DESTINATION_BRANCH" -m "Local update with destination"
- sfdx sgd:source:delta --from "origin/$BITBUCKET_PR_DESTINATION_BRANCH" --to "HEAD" --output temp -d
- ls -R temp
artifacts:
- temp/**
- step: &scanPrettier
name: Prettier
caches:
- node
script:
- *validateTempFolder
- npx prettier temp/force-app --debug-check
artifacts:
- temp/**
- step: &sfdxScannerWithPmd
name: Salesforce Code Analyzer with PMD
caches:
- node
script:
- *validateTempFolder
- sfdx scanner:run --format table --target force-app --engine "pmd" --pmdconfig=ruleset.xml
artifacts:
- temp/**
- step: &sfdxScannerRetireJs
name: Salesforce Code Analyzer RetireJS
caches:
- node
script:
- sfdx scanner:run --format table --target force-app --engine "retire-js"
- step: &sfdxScannerDfa
name: Salesforce Code Analyzer Graph Engine
caches:
- node
script:
# DFA performs a data-flow analysis, hence it needs the complete directory
- sfdx scanner:run:dfa --format table --target force-app --projectdir force-app
- step: &sfdxScannerEslint
name: Salesforce Code Analyzer with ESLint
caches:
- node
script:
- *validateTempFolder
- sfdx scanner:run --format table --target "temp/force-app/**/*.js" --engine eslint --eslintconfig=.eslintrc.json --severity-threshold 3
artifacts:
- temp/**
- step: &validateToScratchOrg
name: Validate with new Scratch Org
caches:
- node
script:
# Include in the validation the new changes of the target branch
- git merge "origin/$BITBUCKET_PR_DESTINATION_BRANCH" -m "Local update with destination"
- sfdx force:auth:sfdxurl:store -d -a $DEV_HUB_ALIAS -f <(printf $DEV_HUB_AUTH_URL)
- ./scripts/validate-with-scratch-org.sh
- step: &autoPushNewPackageVersionToUat
name: Auto Push New Package Version to UAT
condition:
changesets:
includePaths:
- "force-app/**"
script:
- sfdx force:auth:sfdxurl:store -d -a $DEV_HUB_ALIAS -f <(printf $DEV_HUB_AUTH_URL)
- export UAT_AUTH_URL=$(eval echo \${UAT_SFDX_AUTH_URL})
- ./scripts/create-new-package-version.sh
- step: &manualPushNewPackageVersionToUat
name: Manual Push New Package Version to UAT
script:
- sfdx force:auth:sfdxurl:store -d -a $DEV_HUB_ALIAS -f <(printf $DEV_HUB_AUTH_URL)
- export UAT_AUTH_URL=$(eval echo \${UAT_SFDX_AUTH_URL})
- ./scripts/create-new-package-version.sh
pipelines:
pull-requests:
"**": # This runs validation when opening a PR
- step: *getDeps
- step: *generateDeltaForPr
- parallel:
- step: *scanPrettier
- step: *sfdxScannerWithPmd
- step: *sfdxScannerEslint
- step: *validateToScratchOrg
branches:
master:
- step: *autoPushNewPackageVersionToUat
custom:
manualPushNewPackageVersionToUat:
- step: *manualPushNewPackageVersionToUat