2

I am new in writing pipelines, below is the job which I am trying to run

test website:
 image: node
 stage: test
 script:
 - npm i
 - npm i -g gatsby-cli
 - gatsby serve &
 - sleep 3
 - curl "http://localhost:9000" | grep -q "Gatsby"

But it failed at the very last step which below log

gatsby serve &
$ sleep 3
$ curl "http://localhost:9000" | grep -q "Gatsby"
 % Total % Received % Xferd Average Speed Time Time Time Current
 Dload Upload Total Spent Left Speed
 0 0 0 0 0 0 0 0 --:--:-- --:--:-- --:--:-- 0curl: (7) Failed to connect to localhost port 9000: Connection refused
ERROR: Job failed: exit code 1

Please help me to resolve this, also help me in understanding the mistake.

asked Aug 30, 2020 at 18:38

2 Answers 2

2

The error message means that nothing is running on localhost:9000. Check that your application is actually configured to run on port 9000 and if so, try to defer your curl request for a few seconds to allow the application to initialize.

answered Aug 30, 2020 at 18:42
Sign up to request clarification or add additional context in comments.

2 Comments

if possible can you tell me how should I defer it?
It seems that you already do that with the sleep command. Try to increase the sleep value and also check the output of the serve command for errors.
0

I had a similar issue. After a google search, I figure out that the gatsby server isn't having enough time to start so I increased the sleep time. Later the pipeline output a different code error (23) Failed writing body here it seemed that something wrong with the script pipeline curl "http://localhost:9000" | grep -q "Gatsby". this answer explains why this error occur with such piped program, so I ended up like that,

test website:
 image: node
 stage: test
 script:
 - npm i
 - npm i -g gatsby-cli
 - gatsby serve &
 - sleep 10
 - curl "http://localhost:9000" | tac | tac | grep -q "Gatsby"

and my pipeline worked, I hope my answer will help you

answered Dec 31, 2020 at 16:30

Comments

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.