Skip to content

Commit e2d95ff

Browse files
committed
Updates logic in Jenkinsfile to handle tagging issues
1 parent 593457c commit e2d95ff

File tree

1 file changed

+14
-11
lines changed

1 file changed

+14
-11
lines changed

Jenkinsfile

Lines changed: 14 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -75,13 +75,15 @@ spec:
7575
secretKeyRef:
7676
name: git-credentials
7777
key: username
78+
optional: true
7879
- name: GIT_AUTH_PWD
7980
valueFrom:
8081
secretKeyRef:
8182
name: git-credentials
8283
key: password
84+
optional: true
8385
- name: buildah
84-
image: quay.io/buildah/stable:v1.9.2
86+
image: quay.io/buildah/stable:v1.9.0
8587
tty: true
8688
command: ["/bin/bash"]
8789
workingDir: ${workingDir}
@@ -208,10 +210,16 @@ spec:
208210
set -x
209211
set -e
210212
211-
git fetch origin ${BRANCH} --tags
213+
git config --local credential.helper "!f() { echo username=\\$GIT_AUTH_USER; echo password=\\$GIT_AUTH_PWD; }; f"
214+
215+
git fetch --unshallow
216+
git fetch --tags
212217
git checkout ${BRANCH}
213218
git branch --set-upstream-to=origin/${BRANCH} ${BRANCH}
214219
220+
git config --global user.name "Jenkins Pipeline"
221+
git config --global user.email "[email protected]"
222+
215223
if [[ "${BRANCH}" == "master" ]] && [[ $(git describe --tag `git rev-parse HEAD`) =~ (^[0-9]+.[0-9]+.[0-9]+$) ]] || \
216224
[[ $(git describe --tag `git rev-parse HEAD`) =~ (^[0-9]+.[0-9]+.[0-9]+-${BRANCH}[.][0-9]+$) ]]
217225
then
@@ -221,10 +229,6 @@ spec:
221229
exit 0
222230
fi
223231
224-
git config --global user.name "Jenkins Pipeline"
225-
git config --global user.email "[email protected]"
226-
git config --local credential.helper "!f() { echo username=\\$GIT_AUTH_USER; echo password=\\$GIT_AUTH_PWD; }; f"
227-
228232
mkdir -p ~/.npm
229233
npm config set prefix ~/.npm
230234
export PATH=$PATH:~/.npm/bin
@@ -241,8 +245,8 @@ spec:
241245
--verbose \
242246
-VV
243247
244-
echo "IMAGE_NAME=$(basename -s .git `git config --get remote.origin.url` | tr '[:upper:]' '[:lower:]' | sed 's/_/-/g')" > ./env-config
245-
echo "IMAGE_VERSION=$(git describe --abbrev=0 --tags)" >> ./env-config
248+
echo "IMAGE_VERSION=$(git describe --abbrev=0 --tags)" > ./env-config
249+
echo "IMAGE_NAME=$(basename -s .git `git config --get remote.origin.url` | tr '[:upper:]' '[:lower:]' | sed 's/_/-/g')" >> ./env-config
246250
247251
cat ./env-config
248252
'''
@@ -336,7 +340,6 @@ spec:
336340
}
337341
stage('Health Check') {
338342
sh '''#!/bin/bash
339-
set +x
340343
. ./env-config
341344
342345
if [[ "${CLUSTER_TYPE}" == "openshift" ]]; then
@@ -370,8 +373,8 @@ spec:
370373
. ./env-config
371374
372375
if [[ -z "${ARTIFACTORY_ENCRYPT}" ]]; then
373-
echo "Encryption key not available for Jenkins pipeline, please add it to the artifactory-access"
374-
exit 0
376+
echo "Encrption key not available for Jenkins pipeline, please add it to the artifactory-access"
377+
exit 1
375378
fi
376379
377380
# Check if a Generic Local Repo has been created and retrieve the URL for it

0 commit comments

Comments
 (0)