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

It's not the same without you

Join the community to find out what other Atlassian users are discussing, debating and creating.

Atlassian Community Hero Image Collage

Using pipe variables in other parts of the script

Edited

Hi, I just set up a pipeline with rsync pipe. The code looks like this:

pipelines: 

  branches:

    master:

      - step:

        script:

          - pipe: atlassian/rsync-deploy:0.4.2

            variables:

              USER: 'myuser'

              SERVER: 'www.mysite.com'

              REMOTE_PATH: '/someuri/htdocs'

              LOCAL_PATH: '$BITBUCKET_CLONE_DIR/htdocs/*'

              EXTRA_ARGS: '-avz'

          - apt-get update -y

          - apt-get install -y ssh 

          - ssh myuser@www.mysite.com "sudo chmod -R 755 /someuri/htdocs/ && sudo chmod -R 775 /someuri/htdocs/wp-content/ && sudo chown -R myuser:group /someuri/htdocs/"

I have 2 issues here and ask for your kind advice:

1. As the USER and SERVER variables are already declared above, is there a way to use them in ssh statement below?

2. For some reason, rsync changes owner and permissions to my files in the remote host. I thought passing EXTRA_ARGS: -avz would help, but it did not. Any thoughts?

 

1 answer

Q1 - I don't know of a way of using the variables from within the pipe, but you could define your variables before the call to the pipe and re-use them that way:

# ...
- step:
script:
- USER='myuser'
- SERVER='www.mysite.com'
- URI='/someuri/htdocs'
- pipe: Atlassian/rsync-deploy:0.4.2
variables:
USER: $USER
SERVER: $SERVER
# ...
# ...
- ssh $USER@$SERVER "sudo chmod -R 755 $URI/ && sudo chmod -R 775 $URI/wp-content/ && sudo chown -R myuser:group $URI/

Q2 - I don't know.

Suggest an answer

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

New improvements to user management in Bitbucket Cloud 👥

Hey Community! We’re willing to wager that quite a few of you not only use Bitbucket, but administer it too. Our team is excited to share that we’ll be releasing improvements throughout this month of...

3,785 views 10 16
Read article

Community Events

Connect with like-minded Atlassian users at free events near you!

Find an event

Connect with like-minded Atlassian users at free events near you!

Unfortunately there are no Community Events near you at the moment.

Host an event

You're one step closer to meeting fellow Atlassian users at your local event. Learn more about Community Events

Events near you