How to use netcat inside a gitlab-ci.yml
Asked Answered
S

0

5

I try to inspect that a service is up inside a gitlab runner.

For that I use netcat in my .gitlab-ci.yml

image: python:latest

before_script:
  - apt-get update -yq
  - apt-get install -y python-dev python-pip tree
  ## check about Rabbit
  - apt-get install -y curl netcat
  - nc -v -zw3 rabbitmq 15672

but when I run I get this error::

Unpacking netcat (1.10-41) ...
Setting up netcat-traditional (1.10-41) ...
update-alternatives: using /bin/nc.traditional to provide /bin/nc (nc) in auto mode
Setting up netcat (1.10-41) ...
$ nc -zw3 rabbitmq 15672
$ nc -v -zw3 rabbitmq 15672
rabbitmq [172.17.0.2] 15672 (?) : Connection refused
ERROR: Job failed: exit code 1
Seddon answered 14/4, 2017 at 10:31 Comment(5)
netcat is probably working alright, it justs spits out a non-zero error code if it cannot connect to a given host on a given port. So maybe you should merge this question with your other question #43410488 and mention that you've tried this netcat command and it's not working properly.Daphene
Try running netcatwith the -v option for a more verbose output: nc -zw3 -v rabbitmq 15672Daphene
effectively this is related to #43410488Seddon
I've updated the run with netcat -v on the issueSeddon
So netcat is running fine it's your rabbitmq service that's having an issue as highlighted by your other questionDaphene

© 2022 - 2024 — McMap. All rights reserved.