Forums

Articles
Create
cancel
Showing results for 
Search instead for 
Did you mean: 

Muliptle pipes in one step?

Uros Cvijan June 17, 2019 edited

Hi,

Is there a possibility to have mutliple pipes,each as its own script but only in one step?

Cause i want to deploy my new docker image, i have a deploy.sh script. My steps are use SCP pipe to copy the script, use SSH pipe to run the script with some variables.

When i tried that in a format:

-step:

   - script:

         pipe1:

   - script:

       pipe2:

It only executes the last script, and skips the first one.

 

Is there some better way to do this, or i have to create two steps each with one script/pipe?

And is there a way from me to access the ssh private key i added? If i would not to use pipe, how would I ssh to my server, what would be the path to the private key? Woud it be ssh -i ~/.ssh/config?

 

1 answer

1 accepted

2 votes
Answer accepted
Tom Bradshaw
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
June 17, 2019

Hi @Uros Cvijan ,

You don't need separate script commands for each pipe. Instead use

- step:
- script:
- pipe1:
- pipe2:

In terms of using ssh outside of a pipe the easiest way is to consult our documentation here  https://confluence.atlassian.com/bitbucket/use-ssh-keys-in-bitbucket-pipelines-847452940.html.

The location of your private key is in /opt/atlassian/pipelines/agent/ssh/

If you have any question let me know.

Cheers,
Tom

Uros Cvijan June 18, 2019

So that is the way, just multiple pipes in one script, nice. Will try it out. Thank you. If i have to create another question and mark your answer above as correct i can do it, not a problem. 

I have one more question, not sure if i should open new question. But lets try it here: 

If i want to use SSH pipe for example with command: script, and if i have some variables inside of that script (variables that i have setup in pipeline settings), username/password login for my docker private registry. Is there a way for bitbucket pipeline to use the variables from its setup or i have to do something like:

./deploy $USERNAME $PASSWORD 

And to create script with anchors $1, @$2 . I would very much would like to use $USERNAME and $PASSWORD inside of the script and just use variables from bitbucket. Or what would be the preferred way of having variables in deploy script and to use them from bitbucket if that is even possible? 

 

Thank you, 

Uros

Akiva Marks October 30, 2019

Well that didn't work for me, I get an editor warning (with no commit option) that gets me an "expected a string or a pipe".

 

- step: 
name: Deploy-push via sftp
deployment: QA
trigger: manual
script:
- pipe1: atlassian/sftp-deploy:0.3.1
variables:
USER: $USER
SERVER: $SERVER
REMOTE_PATH: /path
LOCAL_PATH: '$BITBUCKET_CLONE_DIR/*'
DEBUG: 'true'

- pipe2: atlassian/ssh-run:0.2.2
variables:
SSH_USER: $USER
SERVER: $SERVER
COMMAND: 'some_linux_cmd'


Uros Cvijan October 30, 2019

You don't have to name them pipe1, pipe2, i think that was just an example from Thomas. It works for me. I have practically the same code as you, just put pipe without the numbers and it should work. 

Akiva Marks October 30, 2019

Awesome, thanks!

raschidjfr
Contributor
February 5, 2020

After adding a second pipe I'm getting an error when trying to run the pipeline: "The step provided was invalid".

 

- step: &step-deploy-prod 
name: Deploy to Prod Server
deployment: Production
script:
- pipe: atlassian/sftp-deploy:0.5.3
variables: USER: $SSH_USER
SERVER: "$SERVER"
REMOTE_PATH: "apps/parse/htdocs/cloud_code/build/cloud"
LOCAL_PATH: "build/cloud"
PASSWORD: $SSH_PWD
- pipe: atlassian/ssh-run:0.2.3
variables:
SSH_USER: ""
SERVER: "$SSH_USER:$SSH_PWD@$SERVER"
COMMAND: "sudo /opt/bitnami/ctlscript.sh restart parse"
Like • Matt Mills likes this
seungmi
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
February 22, 2021 edited

I have a different issue. I can run, but the pipelne ignores second pipe. 

Edited)
For me, it's an anchor issue. it's working.

Matt Mills
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
September 30, 2021

I'm having the same issue raschidjfr.  "The step provided was invalid". 

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events