Missed Team ’24? Catch up on announcements here.

×
Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in

How to avoid overwriting git remote in bitbucket pipeline?

Backend
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!
March 28, 2024

When executing pipeline, the git remote set-url origin command is executed http://bitbucket.org /$BITBUCKET_REPO_FULL_NAME, how to skip or replace the ssh command

bitbucket-pipelines.yml:

image: wodby/drupal-php:7.4-dev-4.21.4

pipelines:
branches:
dev:
#- step:
# name: Install Dependencies
# script:
# - composer install

- step:
name: "Deploy to Dev"
deployment: DEV
script:
- pipe: atlassian/rsync-deploy:0.12.0
variables:
USER: '${DEV_USER}'
SERVER: '${DEV_SERVER}'
REMOTE_PATH: '${DEV_PATH}'
LOCAL_PATH: '${BITBUCKET_CLONE_DIR}/'
SSH_PORT: '${DEV_PORT}'
DEBUG: 'true'
#EXTRA_ARGS: '-avzh --exclude-from=./ignorelist.txt'
# SSH_KEY: '<string>' # Optional.
DELETE_FLAG: 'false'
- pipe: atlassian/ssh-run:0.2.3
variables:
SSH_USER: '${DEV_USER}'
SERVER: '${DEV_SERVER}'
COMMAND: 'scripts/ssh-d8-script.sh'
PORT: '${DEV_PORT}'
DEBUG: 'true'
DEV_PATH_VAR: '${DEV_PATH}'
MODE: 'script'

Снимок экрана 2024-03-28 143006.png

1 answer

1 vote
Theodora Boudale
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
April 2, 2024

Hi @Backend and welcome to the community!

It is not possible to skip any of the commands from the Build setup. However, you can change the URL of the remote origin by adding a command in the script of a certain step. There is a default variable ${BITBUCKET_GIT_SSH_ORIGIN} that you can use, in a command like the following:

- git remote set-url origin ${BITBUCKET_GIT_SSH_ORIGIN}

May I ask why you are looking to do this? There are no commands in your bitbucket-pipelines.yml file that interact with the Bitbucket repo for pulling or pushing changes.

If you use an SSH URL for origin and if you plan to add any git commands in your yml file that interact with the remote, you will also need to set up SSH keys. You can find more details here:

There are two options, one is listed in the section "SSH Key pair managed by Bitbucket Pipelines" and the second in the section "SSH Key pair managed with variables".

Please feel free to reach out if you have any questions!

Kind regards,
Theodora

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events