We should allow SSH access from Bitbucket to the target server. For this - you should have a keypair - generate it with:
ssh-keygen
and then:
ssh-copy-id user@target.server
Next, encode private key in base64:
base64 -w 0 < ~/.ssh/id_rsa
and copy the output.pipelines:
branches:
dev:
- step:
script:
- pipe: atlassian/ssh-run:0.8.0
variables:
SSH_USER: 'user'
SERVER: 'x.x.x.x'
SSH_KEY: $SSH_KEY
COMMAND: 'echo "Executing hook.sh" && /home/user/hook.sh'
EXTRA_ARGS:
- '-o ControlMaster=auto'
Basically it will connect to the server with an user user and target key SSH_KEY and will execute:
echo "Executing hook.sh" && /home/user/hook.sh
on each commit on dev branch on Bitbucket