-
-
Notifications
You must be signed in to change notification settings - Fork 28
Expand file tree
/
Copy pathazure-pipelines-flow-changedFiles.yml
More file actions
63 lines (52 loc) · 2.33 KB
/
Copy pathazure-pipelines-flow-changedFiles.yml
File metadata and controls
63 lines (52 loc) · 2.33 KB
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
pool:
vmImage: 'ubuntu-latest'
variables:
targetBranch: "origin/main"
destinationFolder: "$(Build.ArtifactStagingDirectory)/diff/"
# Use the Salesforce-Provided docker image with SF CLI preinstalled
# https://developer.salesforce.com/docs/atlas.en-us.sfdx_setup.meta/sfdx_setup/sfdx_setup_docker.htm
container: salesforce/cli:latest-slim
steps:
# Checkout the repository with credentials persisted for git commands
- checkout: self
persistCredentials: true
clean: true
fetchDepth: 1
fetchTags: false
# Ensure lightning-flow-scanner is installed (pipe "Y" to confirm)
- script: |
echo Y | sf plugins install lightning-flow-scanner
displayName: 'Ensure lightning-flow-scanner is installed'
# Get added and changed files from the PR and copy them to a directory
- script: |
# Fetch the PRs target branch so that we can compare against it
echo "Fetching target branch: $(targetBranch)..."
git fetch $targetBranch
diffFilter="AM" # Added and modified files
echo "Determining changed files..."
# Compute the list of changed files between target and source branches.
CHANGED_FILES=$(git diff --name-only --diff-filter=$diffFilter $(targetBranch))
echo "Changed files: $CHANGED_FILES"
# Create the destination directory to store changed files
mkdir -p "$(destinationFolder)"
# Copy each changed file into the directory while preserving the directory structure.
for file in $CHANGED_FILES; do
if [ -f "$file" ]; then
mkdir -p "$(destinationFolder)$(dirname $file)"
cp "$file" "$(destinationFolder)$file"
fi
done
echo "Files copied to $(destinationFolder)"
displayName: 'Extract Added and Changed Files'
# Scan only the changed files and capture SARIF from stdout → file
- script: |
sf flow:scan -d "$(destinationFolder)" --sarif > $(Build.ArtifactStagingDirectory)/results.sarif
displayName: Run Flow Scanner (stdout to SARIF)
# Upload SARIF as artifact pipeline (per documentation https://marketplace.visualstudio.com/items?itemName=sariftools.scans)
- task: PublishBuildArtifacts@1
# Flow scanner may report failure when it detects violations. ignore that and publish artifacts anyway
condition: succeededOrFailed()
inputs:
PathtoPublish: '$(Build.ArtifactStagingDirectory)/results.sarif'
ArtifactName: 'CodeAnalysisLogs'
publishLocation: 'Container'