Come for the products,
stay for the community

The Atlassian Community can help you and your team get more value out of Atlassian products and practices.

Atlassian Community about banner
4,361,909
Community Members
 
Community Events
168
Community Groups

Muliptle pipes in one step?

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 Jun 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

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

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'


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. 

Awesome, thanks!

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

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.

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

Suggest an answer

Log in or Sign up to answer
TAGS
Community showcase
Published in Bitbucket

Git push size limits are coming to Bitbucket Cloud starting April 4th, 2022

Beginning on April 4th, we will be implementing push limits. This means that your push cannot be completed if it is over 3.5 GB. If you do attempt to complete a push that is over 3.5 GB, it will fail...

3,499 views 3 10
Read article

Atlassian Community Events