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.
2 Answers 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.
2 Comments
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
Comments
Explore related questions
See similar questions with these tags.