Consume API service from Bash in Docker

sergibarca November 17, 2020

Hello to all,

 

My problem is that I need to use Powershell with an specific modul that don't have compatibility with Linux os. Also, I can't use Windows os to build my own Pipelines.

Then I'm thinking into create a API Services and consume that through Bash. Can I consume API from docker for Bitbucket Pipeline?

 

@Halyna Berezovska can you help me?

 

Thanks! :)

1 answer

0 votes
Halyna Berezovska
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
November 27, 2020

@sergibarca hello!

Okay, let's go in details.

Am I right that you need to use an API?

What exactly you want to do?

 

You can actually defaine firstly your api as service definition (see here how to define a service in definitions block https://support.atlassian.com/bitbucket-cloud/docs/databases-and-service-containers/ )


definitions:
    services:
         my-awesome-api:

               image: my-dockerhub/my-repository
         mongo:

               image: mongo

And then you can use it in step:

step: 
image : ...
...
script:
   - # execute bash command here
services:


   - my-awesome-api

 

As bash command you actually can also execute some powershell commands using in your step

image: mcr.microsoft.com/powershell, and put in script lines like

pwsh -Command {your command}

but it may be limited somehow and this depends on what you're trying to do in powershell.

Perhaps in bash it would be easier for you, but this depends on what you need exactly.

 

How are you supposed to use API? If you just need to check urls, you can write bash script, it will be much easier, for example, using curl utility , e.g. like 

curl <your_api_url>:<port>/v1/users/

 

Let's talk about your case.

Regards, Galyna

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events