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?
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
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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 must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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.
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.
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"
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
I'm having the same issue raschidjfr. "The step provided was invalid".
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Online forums and learning are now in one easy-to-use experience.
By continuing, you accept the updated Community Terms of Use and acknowledge the Privacy Policy. Your public name, photo, and achievements may be publicly visible and available in search engines.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.