Skip to content

Commit ba224fd

Browse files
committed
📚 Update Documentation in validateRepoCurrent.sh
- Revised script description to accurately reflect synchronization check with NetSuite server. - Detailed script's role in preventing deployment conflicts due to unmerged server-side changes. - Clarified usage instructions and the importance of script in CI/CD pipeline for SuiteCloud projects. - Enhanced explanation of Git status check to prevent overwriting uncommitted changes.
1 parent d493d2e commit ba224fd

1 file changed

Lines changed: 52 additions & 0 deletions

File tree

.ci/scripts/validateRepoCurrent.sh

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
#!/bin/bash
2+
3+
# Script Name: validateRepoCurrent.sh
4+
# Purpose:
5+
# This script ensures the local repository's NetSuite object files are synchronized with the server state.
6+
# It's designed to prevent conflicts that may arise when changes made directly in the NetSuite server UI
7+
# have not been incorporated into the repository's main branch. By checking against the server,
8+
# the script helps avoid overwriting server-side changes that haven't been merged into the repository.
9+
10+
# Usage: ./validateRepoCurrent.sh
11+
12+
# Functionality:
13+
# - The script reads a list of object files (objectFileList.pipeline-test.txt).
14+
# - For each object, it checks for a "scriptid" attribute and runs the "update-suitecloud-object" script.
15+
# This fetches the latest version of each object from the NetSuite server, ensuring synchronization.
16+
# - The script also checks the Git repository's status for pending changes.
17+
# - If there are uncommitted changes, the deployment process is halted to prevent overwriting.
18+
# - If no changes are pending, it confirms the repository is ready for deployment.
19+
20+
# Example usage in package.json:
21+
# "validate-repo-current": "bash .ci/scripts/validateRepoCurrent.sh"
22+
23+
SCRIPTIDREGEX="scriptid=\"(.*)\""
24+
SCRIPTIDSEDREGEX="\(.*\)scriptid=\"\(.*\)\"\(.*\)"
25+
OBJFILE="./objectFileList.pipeline-test.txt"
26+
cat "$OBJFILE"
27+
while read OBJLINE; do
28+
while read line; do
29+
SCRIPTID=
30+
if [[ "$line" =~ $SCRIPTIDREGEX ]]; then
31+
# ScriptID found on the first line
32+
SCRIPTID=$(echo "$line" | sed "s:$SCRIPTIDSEDREGEX:\2:g")
33+
echo "Checking: $SCRIPTID"
34+
npm run update-suitecloud-object --scriptid=$SCRIPTID
35+
break
36+
fi
37+
38+
done < <(cat "$OBJLINE")
39+
40+
done < <(cat "$OBJFILE")
41+
42+
# Checking for uncommitted changes in the Git repository
43+
git status --porcelain
44+
if [[ $(git status --porcelain) ]]; then
45+
# Changes detected
46+
echo "Repository Changes Pending: ABORT!"
47+
# Flag to stop the deployment process in case of pending changes
48+
echo "##vso[task.setvariable variable=sfdxExitCode;]1" # Stops the build event for error checking
49+
else
50+
# No changes detected
51+
echo "Repository Current: Ready for Deployment!"
52+
fi

0 commit comments

Comments
 (0)