-
Notifications
You must be signed in to change notification settings - Fork 53
/
lication.sh
47 lines (41 loc) · 1.39 KB
/
lication.sh
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
#!/bin/bash
results=""
curl -XPOST -H 'Content-type: application/json' -d "{
\"artifactUrl\": \"${LICATION_ARTIFACT_URL}\",
\"artifactUser\": \"${ART_USERNAME}\",
\"artifactPass\": \"${ART_PASSWORD}\",
\"githubUrl\": \"${GIT_REPO_URL}\", \"jenkinsJobID\": \"${BUILD_NUMBER}\",
\"githubCreds\": \"${GIT_TOKEN}\"
}" "${LICATION_BACKEND}"
while [ "$results" = "" ]
do
echo "Checking scan status..."
results=`curl -s "${LICATION_BACKEND}"/sha/"${CHECKSUM}" | jq -r '.scanStatus'`
if [ "$results" = 2 ]
then
echo "Scan status is still pending..."
results=""
sleep ${SLEEP_SECOND}
elif [ "$results" = 0 ]
then
echo -e "Scan completed!\n"
echo "No vulnerabilities found, deploying ${APPLICATION_NAME}..."
cd "${WORKSPACE}"/"$PROJECT_NAME"
curl -X POST \
-H 'Content-Type: application/zip' \
--data-binary @"pcf_artifacts.zip" \
"${PCF_ENDPOINT}${PCF_ENV}/${PCF_ORG}/${PCF_SPACE}/${APPLICATION_NAME}"
elif [ "$results" = 1 ]
then
echo -e "Scan Completed!\n"
echo -e "Security Test Failed! Cannot Deploy ${APPLICATION_NAME}!"
exit 1
elif [[ "$results" =~ "null" ]]
then
echo "Return value is null!"
exit 1
else
echo "Something went wrong! Please review logs"
exit 1
fi
done