Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Uplift error handling of gitClone.sh backend script #228

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
49 changes: 21 additions & 28 deletions Templates/Common-Backend-Scripts/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -179,37 +179,30 @@ The section below contains the output that is produced by the `gitClone.sh` scri
<summary>Script Output</summary>

```
gitClone.sh -w MortApp/release/rel-1.0.0/build-1 -r git@github.ibm.com:zDevOps-Acceleration/MortgageApplication.git -b release/rel-1.0.0

gitClone.sh: [INFO] Clone Repository. Version=1.00
gitClone.sh: [INFO] Git Clone Wrapper. Version=1.2.0
gitClone.sh: [INFO] **************************************************************
gitClone.sh: [INFO] ** Start Git Clone on HOST/USER: z/OS ZT01 04.00 02 8561/BPXROOT
gitClone.sh: [INFO] ** Repo: git@github.ibm.com:zDevOps-Acceleration/MortgageApplication.git
gitClone.sh: [INFO] ** WorkDir: /var/dbb/pipelineBackend/workspace/MortApp/release/rel-1.0.0/build-1
gitClone.sh: [INFO] ** GitDir: MortgageApplication
gitClone.sh: [INFO] ** Branch: release/rel-1.0.0 -> release/rel-1.0.0
gitClone.sh: [INFO] ** Start Git Clone on HOST/USER: z/OS ZT01 05.00 02 8561/***
gitClone.sh: [INFO] ** Repo: git@ssh.dev.azure.com:v3/IBM-DAT/retirementCalculator/retirementCalculator
gitClone.sh: [INFO] ** WorkDir: /u/ado/workspace/retirementCalculator/main/build-20240301.1
gitClone.sh: [INFO] ** GitDir: retirementCalculator
gitClone.sh: [INFO] ** Ref: main -> main
gitClone.sh: [INFO] **************************************************************

gitClone.sh: [INFO] Preforming Git Clone of Repo git@github.ibm.com:zDevOps-Acceleration/MortgageApplication.git, Branch release/rel-1.0.0 to /var/dbb/pipelineBackend/workspace/MortApp/release/rel-1.0.0/build-1
Cloning into 'MortgageApplication'...
...
Resolving deltas: 100% (344/344), done.
gitClone.sh: [INFO] Git Status for MortgageApplication
On branch release/rel-1.0.0
Your branch is up to date with 'origin/release/rel-1.0.0'.

gitClone.sh: [INFO] Preforming Git Clone of Repo git@ssh.dev.azure.com:v3/IBM-DAT/retirementCalculator/retirementCalculator, Ref main to /u/ado/workspace/retirementCalculator/main/build-20240301.1
gitClone.sh: [INFO] git clone -b main git@ssh.dev.azure.com:v3/IBM-DAT/retirementCalculator/retirementCalculator
Cloning into 'retirementCalculator'...
gitClone.sh: [INFO] Git Status for retirementCalculator
On branch main
Your branch is up to date with 'origin/main'.
nothing to commit, working tree clean
gitClone.sh: [INFO] Git Show-Ref for MortgageApplication
5d2b737fbc62cf2f14630ac4d4473e2d027212c0 refs/heads/release/rel-1.0.0
e720027dd4f1afac469484fc1b5c8f8675d62e27 refs/remotes/origin/Development
9f1ce97a11f4bebe07b30a59992052ddf39e71de refs/remotes/origin/HEAD
597012c81d1bc0714d4c0595619833f30581c314 refs/remotes/origin/feature/setmainbuildbranch
5d2b737fbc62cf2f14630ac4d4473e2d027212c0 refs/remotes/origin/hotfix/rel-1.0.0/myfix
9f1ce97a11f4bebe07b30a59992052ddf39e71de refs/remotes/origin/main
5d2b737fbc62cf2f14630ac4d4473e2d027212c0 refs/remotes/origin/release/rel-1.0.0
0cc39e464cdd6fa7a4a7e9bb1381e25daf757d08 refs/tags/rel-1.0.0
c08c90fb9b76d466b5717595b5de0dee9031f9ca refs/tags/rel100

gitClone.sh: [INFO] Git Show-Ref for retirementCalculator
c5fe1f8526fa2b20e7b6add8556aa773c9ab1d19 refs/heads/main
c5fe1f8526fa2b20e7b6add8556aa773c9ab1d19 refs/remotes/origin/HEAD
ca11720bdffc280fc9ddefdae41943bc5b2008fc refs/remotes/origin/feature/implementUnitTests
c5fe1f8526fa2b20e7b6add8556aa773c9ab1d19 refs/remotes/origin/main
8ee95ad28813cca2378463a2ef16958c60abcbd9 refs/tags/rel-1.0.0
f12465b6a9623033b6d4fcc393acbcfd71f8e8d8 refs/tags/rel-1.0.1
c7e7dcf9c65bebca8e3d0427c9ce82cb4127f7da refs/tags/rel-1.0.1_rc00
gitClone.sh: [INFO] Clone Repository Complete. rc=0
```

</details>
Expand Down
13 changes: 8 additions & 5 deletions Templates/Common-Backend-Scripts/gitClone.sh
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
# ---------- --- ----- --------------------------------------------------------------
# 2023/07/06 TLD 1.0.0 Initial Release
# 2023/09/25 DB 1.1.0 Initial Release
# 2024/03/01 DB 1.2.0 Updated Error Handling
#===================================================================================

Help() {
Expand Down Expand Up @@ -91,7 +92,7 @@ pipelineConfiguration="${SCRIPT_HOME}/pipelineBackend.config"
#export BASH_XTRACEFD=1 # Write set -x trace to file descriptor

PGM=$(basename "$0")
PGMVERS="1.1.0"
PGMVERS="1.2.0"
USER=$(whoami)
SYS=$(uname -Ia)

Expand Down Expand Up @@ -263,7 +264,7 @@ if [ $rc -eq 0 ]; then
else
echo $PGM": [INFO] ** GitDir:" ${GitDir}
fi
echo $PGM": [INFO] ** Branch:" ${Branch} "->" ${BranchID}
echo $PGM": [INFO] ** Ref:" ${Branch} "->" ${BranchID}
echo $PGM": [INFO] **************************************************************"
echo ""
fi
Expand Down Expand Up @@ -301,7 +302,7 @@ fi
# Clone the Repo to z/OS UNIX System Services with a re-Direct of STDERR to STDOUT
if [ $rc -eq 0 ]; then

echo $PGM": [INFO] Preforming Git Clone of Repo ${Repo}, Branch ${BranchID} to $(getWorkDirectory)"
echo $PGM": [INFO] Preforming Git Clone of Repo ${Repo}, Ref ${BranchID} to $(getWorkDirectory)"
if [ ! -z "${application}" ]; then
CMD="git clone -b ${BranchID} ${Repo} ${application}"
else
Expand All @@ -311,10 +312,9 @@ if [ $rc -eq 0 ]; then
echo $PGM": [INFO] ${CMD}"
${CMD} 2>&1
rc=$?
rc=$?

if [ $rc -ne 0 ]; then
ERRMSG=$PGM": [ERROR] Unable to Clone Repo ${Repo}, Branch ${BranchID}. rc="$rc
ERRMSG=$PGM": [ERROR] Unable to Clone Repo ${Repo}, Ref ${BranchID}. rc="$rc
echo $ERRMSG
rc=8
fi
Expand Down Expand Up @@ -363,6 +363,9 @@ fi
if [ $rc -eq 0 ]; then
ERRMSG=$PGM": [INFO] Clone Repository Complete. rc="$rc
echo $ERRMSG
else
ERRMSG=$PGM": [ERROR] Clone Repository Failed. Check Log. rc="$rc
echo $ERRMSG
fi

exit $rc