Access shell script and other resources to follow along with Jenkins project/ lecture

Hey guys, I’m trying to access the script being run in the Demo: Jenkins (for beginners) freestyle job lecture. I’m not getting the same build failure message the teacher is getting.

Here are the commands I’m running:

Build a message by invoking ADVICESLIP API

curl -s https://api.adviceslip.com/advice > advice.json
cat advice.json

Test to make sure the advice message has more than 5 words.

cat advice.json | jq -r .slip.advice advice.json > advice.message
[ $(wc -w ‹ advice-message) -gt 5 ] && echo “Advice has more than 5 words” || (echo “Advice - $(cat advice.message) has 5 words or less” &&exit 1)

Deploy

sudo apt-get install cowsay -y
cat advice.message | cowsay -f $(1s /usr/share/cowsay/cows | shuf -n 1)

I’m not clear which lecture demo you’re referring to. Could you please supply a link to the lecture?

Hey @swoods30311, looks like the issue might be in the line where you’re calling jq, you only need to reference advice.json once. Also, double-check that you’re using standard syntax (like < instead of ) in the word count check.

Jenkins setup and interface > Demo: working with freestyle jobs

A weblink is actually needed – I’ve checked several possible courses, and I still can’t find your lab. You know which it is – please get me a link.

https://learn.kodekloud.com/user/courses/jenkins-for-beginners/module/3c1739a1-ee72-4285-a832-4ce3c95b784d/lesson/a0827f66-dfb3-4e34-a723-5bc7c82e88fc

First of all, you should go through the “debugging” that the instructor does in the lecture. So it would be good to look at the Console Output as he does, and see what the output looks like. This may well show you the error.

Another thing to do is to try the script you used directly in the virtual system, to see what happens. This might tell you something as to whether you’re using the correct commands.

Can they just give us the script in the future? This is an unnecessary pain in the ass and something that would make me leave KodeKloud, learn Jenkins elsewhere (Udemy course I bought) and just come back to do the labs. I took a photo of the script, although it wasn’t easy getting a clear shot. Then there are all these nuanced errors and even when I fixed them I still don’t get the same build error. This is a waste of my time when the script should be provided as a resource! It’s that simple. Will I have to deal with this issue in future courses? I need clear insight as to how to complete the tutorial so that I can be successful on the lab with little to no help.

Actually, in this case we have a useful resource. We have a notes.kodekloud.com site with pretty good coverage of a number of our courses (increasing all the time) including this course. This lecture is covered here, and includes the script you’re referring to:

# Call the AdviceSlip API and save output as JSON
curl -s https://api.adviceslip.com/advice > advice.json
cat advice.json | jq -r '.slip.advice' > advice.message


# Ensure the advice has more than 5 words
[ $(wc -w < advice.message) -gt 5 ] && echo "Advice has more than 5 words" || (echo "Advice - $(cat advice.message) has 5 words or less")


# Install cowsay (if not already installed) and generate ASCII artwork
sudo apt-get install cowsay -y
echo $PATH
export PATH="$PATH:/usr/games:/usr/local/games"
cat advice.message | cowsay -f $(ls /usr/share/cowsay/cows | shuf -n 1)

Thanks. That helped. I’m glad they’re working on providing documents pertinent to the lectures . I got the script to work after install cowsay seperately, deleting that command and running the script again w/out it.

Hey, I hope all is well. I’m reaching out again because I’m at the extending Jenkins stage, Demo: Installing Plugins lecture and although the script you provided worked for the previous lectures, it’s causing my build to fail because advice.json is not apart of the script provided. I think I need to the original one to successfully build the ascii-test-job. @ 4:39 of the video, his config list copying advice.json and script reads something like this for the test job:

#Test to make sure the advice message has more than 5 words
ls advice.json
cat advice.json | jq -r.slip.advice > advice.message
[ $(wc -w < advice.message) -gt 5 ] && echo “Advice has more than 5 words” || (echo “Advice - $(cat advice.message) has 5 words or less”)

TBH, not sure what you need. Could you please work your way through the lab in this section ( Lab: Jenkins Jumpstart) and see if it uses the script you need? This particular instructor tends to like to use his labs to summarize sections of his course.

I’ll try. Please notify this instructor to review that material and provide all supplemental info for his lectures. It helps to be able to successfully complete the lecture examples so I know how to solve the labs without using AI. Also, it might even be better to cut that section out and go str8 to learning about pipelines b/c I’ve never been asked in an interview about freestyle jobs, chained jobs, etc; only pipelines. It shouldn’t take so much labor and headache to arrive to that point. I took a month off of this platform but the nuances I’m dealing with are creating a bad experience for me.

I hear you. I’ve passed your comment to one of our content managers, a good guy and sensible guy. We’ll see what what he says.

1 Like

I figured out the issues. I believe I copied the script I’m using from above as oppose to the one listed on the notes site. I used that one and it worked fine. I think there was a typo introduced. Nonetheless, my jobs built.