You've been invited into the Kudos (beta program) private group. Chat with others in the program, or give feedback to Atlassian.
View groupJoin the community to find out what other Atlassian users are discussing, debating and creating.
Hi, I'd like to know how to curl a defined service in difinitions.services section from my step.
This is my bitbucket-pipelines.yml:
image: cypress/base:10
pipelines:
default:
- step: &run
name: Run
image: mongo
script:
- curl http://my-service
/my-path
services:
- my-service
branches:
'**':
- step: *run
definitions:
services:
my-service:
image:
name: 098765431234.dkr.ecr.us-east-1.amazonaws.com/my-service:latest
aws:
access-key: $AWS_ACCESS_KEY_ID
secret-key: $AWS_SECRET_ACCESS_KEY
mongo:
image: mongo
That's the error I'm facing:
<1s+ curl http://my-service/my-path
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
0 0 0 0 0 0 0 0 --:--:-- --:--:-- --:--:-- 0curl: (6) Could not resolve host: my-service
I'm assuming the request could be performed to service definition name my-service instead of host name or IP, folowing docker-compose principles.
Please, appreciate any help
Thanx
Hello @Garry Dias , thanks for using pipelines.
I suspect, definitions cannot work this way, I could not find example without the image mentioning. Definitions documentation .
But if I got your point, the feature you want, is described here https://community.atlassian.com/t5/Bitbucket-questions/Is-it-possible-to-use-the-add-host-option-in-pipeline-docker/qaq-p/1156756 .
I tried his solution but I hadn't success.
I'm trying to change the strategy and perform a docker run in my scripts block. But even so I'm facing connection refused issues when trying a curl.
Already tried:
At this point, I just want fire an http request over a container started from pipelines script on 8080 port
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
@Garry Dias could you please share a part of pipeline and more logs if you have? did you expose the appropriate port ? without this it would not be accessible.
Cheers, Galyna
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Actually, after my post I noticed a randomly failing curl after a lot of pipelines run. Even using 9090 port.
I ran this yml I've shared dozens of times and surprisingly sometimes 8080 requests works and 9090 did not.
I suspected the container hadn't started the server yet.
So I inserted a
- sleep 10
between docker run and curl. Then, after dozens of pipelines execution, 100% of these executions were successful.
So, the REAL cause was the container port availability delay.
Everything's fine now.
Thanx one more time, @Galyna Zholtkevych
note: I kept as Accepted Answer because there's no support to accept replies
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
@Galyna Zholtkevych I've found the issue.
It seems that not only the port described at Caveats and limitations section here is actually restricted but also 8080.
As we can see, the 1st and 5th requests in bitbucket-pipelines.yml file bellow are similar, except by its ports. The 5th is the one that have worked:
# This is a sample build configuration for Docker.
# Check our guides at https://confluence.atlassian.com/x/O1toN for more examples.
# Only use spaces to indent your .yml configuration.
# -----
# You can specify a custom docker image from Docker Hub as your build environment.
image: atlassian/default-image:2
pipelines:
default:
- parallel:
- step:
services:
- docker
script:
- docker run -d -p 8080:80 strm/helloworld-http
- curl -vvv http://localhost:8080
- step:
services:
- docker
script:
- docker run -d -p 8080:80 strm/helloworld-http
- curl -vvv http://127.0.0.1:8080
- step:
services:
- docker
script:
- sh -c 'echo 8.8.8.8 myserver >> /etc/hosts'
- docker run -d -p 8080:80 strm/helloworld-http
- curl -vvv http://myserver:8080
- step:
services:
- docker
script:
- sh -c 'echo 8.8.8.8 myserver >> /etc/hosts'
- docker run -d -p 8080:80 strm/helloworld-http
- curl -vvv myserver:8080
# This is the one that properly works. I suppose 8080 is a restricted port
- step:
services:
- docker
script:
- docker run -d -p 9090:80 strm/helloworld-http
- curl -vvv http://localhost:9090
- step:
services:
- docker
script:
- docker run --name myserver -d -p 8080:80 strm/helloworld-http
- curl -vvv http://myserver:8080
- step:
services:
- docker
script:
- sh -c 'echo 8.8.8.8 myserver >> /etc/hosts'
- docker run --add-host myserver:8.8.8.8 -d -p 8080:80 strm/helloworld-http
- curl -vvv http://myserver:8080
This pipelines file was extracted from blank project with only bitbucket-pipelines.yml file inside.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Yes, 8080 is the port that is often used. Perhaps that is why you cannot use again
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
...hey are a part of us, shaping how we interact with the world around us. The same holds true for programming languages when we think about how different kinds of vulnerabilities raise their heads in t...
Connect with like-minded Atlassian users at free events near you!
Find an eventConnect with like-minded Atlassian users at free events near you!
Unfortunately there are no Community Events near you at the moment.
Host an eventYou're one step closer to meeting fellow Atlassian users at your local event. Learn more about Community Events
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.