Hello Guys
Below is my pipe code and want to use multiple command so how can i do that.
Thank you.
pipe: atlassian/ssh-run:0.1.3
variables:
SSH_USER: $USER
SERVER: $SERVER
#SSH_KEY: $MYKEY
PORT: 22
COMMAND: 'sudo chmod -R 755 filename/*'
The command variable only accepts a single command. If the shell on the remote server happens to be Bourne shell-like (such as bash), you can use a YAML multiline block with command chaining to get this effect.
- pipe: atlassian/ssh-run:0.1.3
variables:
# ... other vars ...
COMMAND: >
sudo chmod -R 755 filename/* &&
sudo other command/*
This style will not run the second command if the first one fails. If you want the second command run no matter what, you can use `;` instead of `&&` as a separator.
As the docs suggest, it's probably better to use a script file, as you can control the shell being used and can more easily write tests around the command.
Very neat and straight answer, thank you dude!
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Hardik,
I haven't used this pipe myself, but from reading the docs I think what you want is the "script" mode, as per this example (taken straight from the docs):
script: - pipe: atlassian/ssh-run:0.2.0 variables: SSH_USER: 'ec2-user' SERVER: '127.0.0.1' SSH_KEY: $MY_SSH_KEY MODE: 'script' COMMAND: 'myscript.sh' # path to a script in your repository
If you don't want to add the script to your repository, then you could always create it in your build script just before launching the pipe, eg:
script:
- 'echo ''command 1'' > myscript.sh'
- 'echo ''command 2'' >> myscript.sh'
- 'echo ''command 3'' >> myscript.sh'
- pipe: atlassian/ssh-run:0.2.0
... etc
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hello Steven,
Thankx for your response. But I am looking like something as below
pipe: atlassian/ssh-run:0.1.3
variables:
SSH_USER: $USER
SERVER: $SERVER
#SSH_KEY: $MYKEY
PORT: 22
COMMAND: 'sudo chmod -R 755 filename/*'
COMMAND: 'sudo other command/*'
Is this possible?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Try this:
script:
- 'echo ''sudo chmod -R 755 filename/*'' > my-ssh-script.sh'
- 'echo ''sudo other command/*'' >> my-ssh-script.sh'
- pipe: atlassian/ssh-run:0.2.0
variables:
SSH_USER: $USER
SERVER: $SERVER
PORT: 22
MODE: 'script'
COMMAND: 'my-ssh-script.sh'
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.