MYHOSPITALNOW.COM

Find Trusted Doctors & Hospitals

Discover healthcare providers, compare hospitals, and explore treatment options worldwide.

Free Treatment Quotes • Doctor Search • Hospital Comparison

Find Healthcare Options

www.myhospitalnow.com

Check to see if a build is running or not

rajeshkumar created the topic: Check to see if a build is running or not
All I need to do is check to see if a build is running or not. To do that I used curl and grep, like this:

curl http://myjenkins/job/myjob/lastBuild/api/json | grep –color result\”:null

If a build is in progress, a grep for result\”:null will return 0.
If a build is finished, a grep for result\”:null will return 1.
Not especially elegant, but it works well enough for my needs.

For example, I have a Bash script that starts a build, then waits for it to finish:

JOB_URL=http://jenkins.local/job/stevehhhbuild
JOB_STATUS_URL=${JOB_URL}/lastBuild/api/json

GREP_RETURN_CODE=0

# Start the build
curl $JOB_URL/build?delay=0sec

# Poll every thirty seconds until the build is finished
while [ $GREP_RETURN_CODE -eq 0 ]
do
sleep 30
# Grep will return 0 while the build is running:
curl –silent $JOB_STATUS_URL | grep result\”:null > /dev/null
GREP_RETURN_CODE=$?
done

echo Build finished

Reference – serverfault.com/questions/309848/how-can…49988bb53ee820fe202a
Regards,
Rajesh Kumar
Twitt me @ twitter.com/RajeshKumarIn

Find Trusted Cardiac Hospitals

Compare heart hospitals by city and services — all in one place.

Explore Hospitals
I'm Rajesh Kumar, a DevOps, SRE, DevSecOps, Cloud, and Platform Engineering expert passionate about sharing practical knowledge, real-world experiences, and industry best practices. I have worked at Cotocus and regularly write about technology, travel, investing, health, product reviews, and digital marketing through my various platforms. I publish technical articles at DevOps School, travel stories at Holiday Landmark, stock market insights at Stocks Mantra, health and fitness guidance at My Medic Plus, product reviews at TrueReviewNow, and SEO and digital marketing strategies at Wizbrand.

Related Posts

Interview Questions & Answers Complete Guide for Linux

Linux What is your experience with Linux? Explain what each of the following commands does and give an example on how to use it: Explain each field…

Read More

Grep and Sed Questions with Shell script

scmuser created the topic: grep and sed questions with shell script Search for a pattern with grep and sed and look for a file with find. Test…

Read More

Remove blank line using Grep and sed

scmuser created the topic: Remove blank line using Grep and sed Hi, How do you remove blank line using grep and sed in shell scripting? rajeshkumar replied…

Read More

Frequently Used Shell Script

rajeshkumar created the topic: Frequently Used Shell Script Shell scripts to convert file names to lower case and upper case To convert to lower case: #!/bin/sh for…

Read More

Shell Bash Scripting: Assignment & Excercise – 7

This exercise uses Bash, rsync and SSH to copy a local file to a remote backup server, then sends an email when the copy finishes. Below the…

Read More

Shell Bash Scripting: Assignment & Excercise – 4

This exercise asks for a Bash script that checks CPU usage and sends an email when it goes over a threshold. The script above reads /proc/stat, but…

Read More
Subscribe
Notify of
guest
0 Comments
Newest
Oldest Most Voted
0
Would love your thoughts, please comment.x
()
x