Notes
Notes - notes.io |
#latest result INCLUDING currently running builds
latestResult="https://forge.lmig.com/builds/rest/api/latest/result/GSCLAIMS-GCLSV/latest.json?includeAllStates"
latestFinished="https://forge.lmig.com/builds/rest/api/latest/result/GSCLAIMS-GCLSV/latest.json"
specificBuild="https://forge.lmig.com/builds/rest/api/latest/result/GSCLAIMS-GCLSV"
#get build number for last build (finished or ongoing)
buildNumber=$(curl --user $user:$bamboo_gs_claims_bamboo_password $latestResult | jq '.buildNumber')
buildStatus=$(curl --user $user:$bamboo_gs_claims_bamboo_password $latestResult | jq '.buildState')
unknown="Unknown"
false="false"
buildStep=$(curl --user $user:$bamboo_gs_claims_bamboo_password $latestResult | jq '.buildReason')
stepSnip="<b>Run"
#make sure that there is no ongoing build, otherwise fail test
#echo "DEBUG: var 1: $buildStatus"
#echo "DEBUG: var 2: $unknown"
if [[ $buildStatus = *"$unknown"* ]] ; then
echo "ERROR: Concurrent build detected."
percentageComplete=$(curl --user $user:$bamboo_gs_claims_bamboo_password $latestResult | jq '.percentageCompleted')
if [[ $buildStep = *"$stepSnip"* ]] ; then
echo "Current Build is running full tests, not just Smoke Tests. Try again later."
exit 0
fi
lowestPercent=0.8
if [ $(bc <<< "$percentageComplete < $lowestPercent") -eq 1 ] ; then
echo "Currently running build is less than 80% complete. Please try again after current build is complete."
exit 0
else
numTries=0
maxTries=10
echo "Currently running build is over 80% complete. Will attempt to run smoke tests once it completes. Will re-attempt every minute for 10 minutes."
buildStatus=$(curl --user $user:$bamboo_gs_claims_bamboo_password $specificBuild-$buildNumber.json | jq '.buildState')
while [ $numTries -lt $maxTries ]
do
if [[ $buildStatus = *"$unknown"* ]] ; then #was having issues with both conditionals in while statement
if [[ $buildStep = *"$stepSnip"* ]] ; then
echo "Curent Build has started running full tests, not just Smoke Tests. Try again later."
exit 1
fi
sleep 60
buildStatus=$(curl --user $user:$bamboo_gs_claims_bamboo_password $specificBuild-$buildNumber.json | jq '.buildState')
buildStep=$(curl --user $user:$bamboo_gs_claims_bamboo_password $specificBuild-$buildNumber.json | jq '.buildReason')
numTries=$(($numTries + 1))
echo "$numTries re-attempt(s) so far to start smoke tests."
else
echo "Previous build complete."
break
fi
done
#fail the task if loop was exited on retries alone
if [[ $buildStatus = *"$unknown"* ]] ; then
echo "Previous build did not finish within 10 minutes. Please retry deploy once this build is complete."
exit 1
fi
fi
fi
expectedBuildNumber=$(($buildNumber + 1))
#queue new build
echo "Starting Smoke Tests"
curl -f -v -k --user $user:$bamboo_gs_claims_bamboo_password -X POST "https://forge.lmig.com/builds/rest/api/latest/queue/GSCLAIMS-GCLSV?&bamboo.environment=sit1"
#sleep 10 seconds
sleep 10
#update build number for last build (finished or ongoing)
# at this point, should be our NEW build, that we just kicked off
buildNumber=$(curl --user $user:$bamboo_gs_claims_bamboo_password $latestResult | jq '.buildNumber')
#make sure that new build was kicked off an is the next build being run
# if we get a different build number than expected then it is either not kicked off or a concurrent build occurred
if [ $expectedBuildNumber != $buildNumber ]; then
echo "ERROR: Build Number not as expected. Possible issue with concurrent runs."
exit 0
fi
#get build number for last finished build into new variable
# finished build necessary here, because we want to test against OUR build when it finishes
newBuildNumber=$(curl --user $user:$bamboo_gs_claims_bamboo_password $latestFinished | jq '.buildNumber')
# while new build number is less than the expected build number (which is last build number plus one)
while [ $newBuildNumber -lt $expectedBuildNumber ]
do
sleep 60
newBuildNumber=$(curl --user $user:$bamboo_gs_claims_bamboo_password $latestFinished | jq '.buildNumber')
done
#determine still no issues with concurrent runs (in 60 second sleep another run could have kicked off and immediately failed, in that case $newBuildNumber would be ahead)
if [ $expectedBuildNumber != $newBuildNumber ]; then
echo "ERROR: Build Number not as expected. Possible issue with concurrent runs."
exit 0
fi
#get variable to see if stage has passed
# DONE -> get it for a specific build number, not just the latest
result=$(curl --user $user:$bamboo_gs_claims_bamboo_password $specificBuild-$expectedBuildNumber.json | jq '.successful')
#if stage has failed, then exit script with one which forces a failed task
# OR if something went wrong with the newBuildNumber, such as a concurrent build being run
echo "DEBUG: smoke test result: $result"
if [[ $result = *"$false"* ]]; then
echo "ERROR: Smoke Tests FAILED. See Bamboo build GSCLAIMS-GCLSV-$newBuildNumber"
exit 0
else #smoke tests passed
echo "SUCCESS: Smoke Tests Passed."
fi
![]() |
Notes is a web-based application for online taking notes. You can take your notes and share with others people. If you like taking long notes, notes.io is designed for you. To date, over 8,000,000,000+ notes created and continuing...
With notes.io;
- * You can take a note from anywhere and any device with internet connection.
- * You can share the notes in social platforms (YouTube, Facebook, Twitter, instagram etc.).
- * You can quickly share your contents without website, blog and e-mail.
- * You don't need to create any Account to share a note. As you wish you can use quick, easy and best shortened notes with sms, websites, e-mail, or messaging services (WhatsApp, iMessage, Telegram, Signal).
- * Notes.io has fabulous infrastructure design for a short link and allows you to share the note as an easy and understandable link.
Fast: Notes.io is built for speed and performance. You can take a notes quickly and browse your archive.
Easy: Notes.io doesn’t require installation. Just write and share note!
Short: Notes.io’s url just 8 character. You’ll get shorten link of your note when you want to share. (Ex: notes.io/q )
Free: Notes.io works for 14 years and has been free since the day it was started.
You immediately create your first note and start sharing with the ones you wish. If you want to contact us, you can use the following communication channels;
Email: [email protected]
Twitter: http://twitter.com/notesio
Instagram: http://instagram.com/notes.io
Facebook: http://facebook.com/notesio
Regards;
Notes.io Team
