Skip to content

Instantly share code, notes, and snippets.

@shankar-bavan
Last active March 16, 2025 10:20
Show Gist options
  • Select an option

  • Save shankar-bavan/ccc0d69e40f958e76aa23777871955f5 to your computer and use it in GitHub Desktop.

Select an option

Save shankar-bavan/ccc0d69e40f958e76aa23777871955f5 to your computer and use it in GitHub Desktop.

Revisions

  1. shankar-bavan revised this gist Mar 4, 2021. 1 changed file with 3 additions and 0 deletions.
    3 changes: 3 additions & 0 deletions bitbucket-pipeline-pull-files.md
    Original file line number Diff line number Diff line change
    @@ -96,6 +96,9 @@ for centos
    for ubuntu
    `#!/bin/bash`

    Bash path must be same than results of:
    $ which bash

    ```
    #!/bin/sh
  2. shankar-bavan revised this gist Nov 23, 2020. 1 changed file with 8 additions and 11 deletions.
    19 changes: 8 additions & 11 deletions bitbucket-pipeline-pull-files.md
    Original file line number Diff line number Diff line change
    @@ -5,25 +5,22 @@ https://support.atlassian.com/bitbucket-cloud/docs/set-up-an-ssh-key/

    or

    ssh-keygen
    `ssh-keygen`
    eval $(ssh-agent)
    ssh-add ~/.ssh/<private_key_file>

    ssh-add ~/.ssh/<private_key_file>

    `ssh-add ~/.ssh/<private_key_file>`

    Go to Bitbucket -> repo -> repo-setting-> -> Pipelines -> Settings
    Enable pipeline

    Go to Bitbucket -> repo -> repo-setting-> Access Keys -> Add Key
    copy public key
    cat ~/.ssh/id_rsa.pub
    `cat ~/.ssh/id_rsa.pub `

    ssh -T [email protected]
    `ssh -T [email protected]`
    The command message tells you which of your Bitbucket accounts can log in with that key.
    If there any issues run below command (Permission denied (publickey))
    ssh-add -l
    ssh-add ~/.ssh/<private_key_file>
    `ssh-add -l`
    `ssh-add ~/.ssh/<private_key_file>`

    Go to Bitbucket -> repo -> repo-setting-> Access Keys -> Known hosts
    Add IP address of the server and click on Fetch and Add Host
    @@ -32,10 +29,10 @@ Add IP address of the server and click on Fetch and Add Host
    ### 2. Update remote url

    Go to project directory
    git remote -v
    `git remote -v`

    set ssh format url
    git remote set-url origin [email protected]:<workspace_ID>/<repo_name>.git
    `git remote set-url origin [email protected]:<workspace_ID>/<repo_name>.git `

    =============================================================

  3. shankar-bavan revised this gist Nov 23, 2020. 1 changed file with 4 additions and 2 deletions.
    6 changes: 4 additions & 2 deletions bitbucket-pipeline-pull-files.md
    Original file line number Diff line number Diff line change
    @@ -89,11 +89,13 @@ pipelines:
    COMMAND: "/var/folder-name/deploy.sh" ```
    ```

    6. Sh script
    ===============================================================

    ### 6. Sh script

    Note:
    for centos
    `#!/bin/sh`
    -----------
    for ubuntu
    `#!/bin/bash`

  4. shankar-bavan revised this gist Nov 23, 2020. 1 changed file with 5 additions and 0 deletions.
    5 changes: 5 additions & 0 deletions bitbucket-pipeline-pull-files.md
    Original file line number Diff line number Diff line change
    @@ -38,6 +38,7 @@ set ssh format url
    git remote set-url origin [email protected]:<workspace_ID>/<repo_name>.git

    =============================================================

    ### 3. Bitbucket pipeline settings (variables)

    Go to Bitbucket -> repo -> repo-setting-> -> Pipelines -> Repository variables
    @@ -48,14 +49,18 @@ Value: 22
    Name:SERVER
    Value: IP address
    untick secured

    ===============================================================

    ### 4. Bitbucket pipeline settings (SSH Keys)

    Go to Bitbucket -> repo -> repo-setting-> -> Pipelines -> SSH Keys
    Click on Generate keys
    Copy public key to ~/.ssh/authorized_keys on the remote host
    (login to server and go to above path and edit file with nano and paste the public key in new line)

    ===============================================================

    ### 5. create file and copy below code.

    ```
  5. shankar-bavan revised this gist Nov 23, 2020. 1 changed file with 4 additions and 4 deletions.
    8 changes: 4 additions & 4 deletions bitbucket-pipeline-pull-files.md
    Original file line number Diff line number Diff line change
    @@ -29,7 +29,7 @@ Go to Bitbucket -> repo -> repo-setting-> Access Keys -> Known hosts
    Add IP address of the server and click on Fetch and Add Host

    =============================================================
    ## 2. Update remote url
    ### 2. Update remote url

    Go to project directory
    git remote -v
    @@ -38,7 +38,7 @@ set ssh format url
    git remote set-url origin [email protected]:<workspace_ID>/<repo_name>.git

    =============================================================
    ## 3. Bitbucket pipeline settings (variables)
    ### 3. Bitbucket pipeline settings (variables)

    Go to Bitbucket -> repo -> repo-setting-> -> Pipelines -> Repository variables
    Name: SSH_USER
    @@ -49,14 +49,14 @@ Name:SERVER
    Value: IP address
    untick secured
    ===============================================================
    ## 4. Bitbucket pipeline settings (SSH Keys)
    ### 4. Bitbucket pipeline settings (SSH Keys)

    Go to Bitbucket -> repo -> repo-setting-> -> Pipelines -> SSH Keys
    Click on Generate keys
    Copy public key to ~/.ssh/authorized_keys on the remote host
    (login to server and go to above path and edit file with nano and paste the public key in new line)
    ===============================================================
    ## 5. create file and copy below code.
    ### 5. create file and copy below code.

    ```
    # This is a sample build configuration for PHP.
  6. shankar-bavan revised this gist Nov 23, 2020. 1 changed file with 5 additions and 1 deletion.
    6 changes: 5 additions & 1 deletion bitbucket-pipeline-pull-files.md
    Original file line number Diff line number Diff line change
    @@ -1,4 +1,5 @@
    ### 1. Setup ssh key on server

    follow this guide
    https://support.atlassian.com/bitbucket-cloud/docs/set-up-an-ssh-key/

    @@ -29,6 +30,7 @@ Add IP address of the server and click on Fetch and Add Host

    =============================================================
    ## 2. Update remote url

    Go to project directory
    git remote -v

    @@ -47,13 +49,15 @@ Name:SERVER
    Value: IP address
    untick secured
    ===============================================================
    ####4. Bitbucket pipeline settings (SSH Keys)
    ## 4. Bitbucket pipeline settings (SSH Keys)

    Go to Bitbucket -> repo -> repo-setting-> -> Pipelines -> SSH Keys
    Click on Generate keys
    Copy public key to ~/.ssh/authorized_keys on the remote host
    (login to server and go to above path and edit file with nano and paste the public key in new line)
    ===============================================================
    ## 5. create file and copy below code.

    ```
    # This is a sample build configuration for PHP.
    # Check our guides at https://confluence.atlassian.com/x/e8YWN for more examples.
  7. shankar-bavan revised this gist Nov 23, 2020. 1 changed file with 22 additions and 3 deletions.
    25 changes: 22 additions & 3 deletions bitbucket-pipeline-pull-files.md
    Original file line number Diff line number Diff line change
    @@ -1,12 +1,19 @@
    ### 1. Setup ssh key on server
    follow this guide
    https://support.atlassian.com/bitbucket-cloud/docs/set-up-an-ssh-key/

    or

    ssh-keygen
    eval $(ssh-agent)
    ssh-add ~/.ssh/<private_key_file>

    ssh-add ~/.ssh/<private_key_file>


    Go to Bitbucket -> repo -> repo-setting-> -> Pipelines -> Settings
    Enable pipeline

    Go to Bitbucket -> repo -> repo-setting-> Access Keys -> Add Key
    copy public key
    cat ~/.ssh/id_rsa.pub
    @@ -17,6 +24,9 @@ If there any issues run below command (Permission denied (publickey))
    ssh-add -l
    ssh-add ~/.ssh/<private_key_file>

    Go to Bitbucket -> repo -> repo-setting-> Access Keys -> Known hosts
    Add IP address of the server and click on Fetch and Add Host

    =============================================================
    ## 2. Update remote url
    Go to project directory
    @@ -27,8 +37,6 @@ git remote set-url origin [email protected]:<workspace_ID>/<repo_name>.git

    =============================================================
    ## 3. Bitbucket pipeline settings (variables)
    Go to Bitbucket -> repo -> repo-setting-> -> Pipelines -> Settings
    Enable pipeline

    Go to Bitbucket -> repo -> repo-setting-> -> Pipelines -> Repository variables
    Name: SSH_USER
    @@ -70,8 +78,19 @@ pipelines:
    #SSH_KEY: $MYKEY
    PORT: $PORT
    COMMAND: "/var/folder-name/deploy.sh" ```
    ```

    6. Sh script
    Note:
    for centos
    `#!/bin/sh`
    -----------
    for ubuntu
    `#!/bin/bash`

    ```
    #!/bin/sh
    repos=(
    "/var/www/project1"
    "/var/www/project2"
  8. shankar-bavan revised this gist Nov 23, 2020. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion bitbucket-pipeline-pull-files.md
    Original file line number Diff line number Diff line change
    @@ -1,4 +1,4 @@
    ## 1. Setup ssh key on server
    ### 1. Setup ssh key on server
    https://support.atlassian.com/bitbucket-cloud/docs/set-up-an-ssh-key/

    ssh-keygen
  9. shankar-bavan revised this gist Nov 23, 2020. 1 changed file with 4 additions and 4 deletions.
    8 changes: 4 additions & 4 deletions bitbucket-pipeline-pull-files.md
    Original file line number Diff line number Diff line change
    @@ -1,4 +1,4 @@
    ####1. Setup ssh key on server
    ## 1. Setup ssh key on server
    https://support.atlassian.com/bitbucket-cloud/docs/set-up-an-ssh-key/

    ssh-keygen
    @@ -18,15 +18,15 @@ ssh-add -l
    ssh-add ~/.ssh/<private_key_file>

    =============================================================
    ####2. Update remote url
    ## 2. Update remote url
    Go to project directory
    git remote -v

    set ssh format url
    git remote set-url origin [email protected]:<workspace_ID>/<repo_name>.git

    =============================================================
    ####3. Bitbucket pipeline settings (variables)
    ## 3. Bitbucket pipeline settings (variables)
    Go to Bitbucket -> repo -> repo-setting-> -> Pipelines -> Settings
    Enable pipeline

    @@ -45,7 +45,7 @@ Click on Generate keys
    Copy public key to ~/.ssh/authorized_keys on the remote host
    (login to server and go to above path and edit file with nano and paste the public key in new line)
    ===============================================================
    ####5. create file and copy below code.
    ## 5. create file and copy below code.
    ```
    # This is a sample build configuration for PHP.
    # Check our guides at https://confluence.atlassian.com/x/e8YWN for more examples.
  10. shankar-bavan renamed this gist Nov 23, 2020. 1 changed file with 0 additions and 0 deletions.
  11. shankar-bavan revised this gist Oct 26, 2020. 1 changed file with 17 additions and 0 deletions.
    17 changes: 17 additions & 0 deletions bitbucket-pipeline-pull-files
    Original file line number Diff line number Diff line change
    @@ -71,3 +71,20 @@ pipelines:
    PORT: $PORT
    COMMAND: "/var/folder-name/deploy.sh" ```

    6. Sh script
    repos=(
    "/var/www/project1"
    "/var/www/project2"
    )

    echo ""
    echo "Getting latest for" ${#repos[@]} "repositories using pull"

    for repo in "${repos[@]}"
    do
    echo ""
    echo "****** Getting latest for" ${repo} "******"
    cd "${repo}"
    git pull
    echo "******************************************"
    done
  12. shankar-bavan revised this gist Oct 26, 2020. 1 changed file with 7 additions and 7 deletions.
    14 changes: 7 additions & 7 deletions bitbucket-pipeline-pull-files
    Original file line number Diff line number Diff line change
    @@ -1,4 +1,4 @@
    <b>1. Setup ssh key on server</b>
    ####1. Setup ssh key on server
    https://support.atlassian.com/bitbucket-cloud/docs/set-up-an-ssh-key/

    ssh-keygen
    @@ -18,15 +18,15 @@ ssh-add -l
    ssh-add ~/.ssh/<private_key_file>

    =============================================================
    <b>2. Update remote url</b>
    ####2. Update remote url
    Go to project directory
    git remote -v

    set ssh format url
    git remote set-url origin [email protected]:<workspace_ID>/<repo_name>.git

    =============================================================
    <b>3. Bitbucket pipeline settings (variables)</b>
    ####3. Bitbucket pipeline settings (variables)
    Go to Bitbucket -> repo -> repo-setting-> -> Pipelines -> Settings
    Enable pipeline

    @@ -39,14 +39,14 @@ Name:SERVER
    Value: IP address
    untick secured
    ===============================================================
    <b>4. Bitbucket pipeline settings (SSH Keys)</b>
    ####4. Bitbucket pipeline settings (SSH Keys)
    Go to Bitbucket -> repo -> repo-setting-> -> Pipelines -> SSH Keys
    Click on Generate keys
    Copy public key to ~/.ssh/authorized_keys on the remote host
    (login to server and go to above path and edit file with nano and paste the public key in new line)
    ===============================================================
    <b>5. create file and copy below code.</b>
    ####5. create file and copy below code.
    ```
    # This is a sample build configuration for PHP.
    # Check our guides at https://confluence.atlassian.com/x/e8YWN for more examples.
    # Only use spaces to indent your .yml configuration.
    @@ -69,5 +69,5 @@ pipelines:
    SERVER: $SERVER
    #SSH_KEY: $MYKEY
    PORT: $PORT
    COMMAND: "/var/folder-name/deploy.sh"
    COMMAND: "/var/folder-name/deploy.sh" ```

  13. shankar-bavan revised this gist Oct 26, 2020. 1 changed file with 5 additions and 5 deletions.
    10 changes: 5 additions & 5 deletions bitbucket-pipeline-pull-files
    Original file line number Diff line number Diff line change
    @@ -1,4 +1,4 @@
    1. Setup ssh key on server
    <b>1. Setup ssh key on server</b>
    https://support.atlassian.com/bitbucket-cloud/docs/set-up-an-ssh-key/

    ssh-keygen
    @@ -18,15 +18,15 @@ ssh-add -l
    ssh-add ~/.ssh/<private_key_file>

    =============================================================
    2. Update remote url
    <b>2. Update remote url</b>
    Go to project directory
    git remote -v

    set ssh format url
    git remote set-url origin [email protected]:<workspace_ID>/<repo_name>.git

    =============================================================
    3. Bitbucket pipeline settings (variables)
    <b>3. Bitbucket pipeline settings (variables)</b>
    Go to Bitbucket -> repo -> repo-setting-> -> Pipelines -> Settings
    Enable pipeline

    @@ -39,13 +39,13 @@ Name:SERVER
    Value: IP address
    untick secured
    ===============================================================
    4. Bitbucket pipeline settings (SSH Keys)
    <b>4. Bitbucket pipeline settings (SSH Keys)</b>
    Go to Bitbucket -> repo -> repo-setting-> -> Pipelines -> SSH Keys
    Click on Generate keys
    Copy public key to ~/.ssh/authorized_keys on the remote host
    (login to server and go to above path and edit file with nano and paste the public key in new line)
    ===============================================================
    5. create file and copy below code.
    <b>5. create file and copy below code.</b>

    # This is a sample build configuration for PHP.
    # Check our guides at https://confluence.atlassian.com/x/e8YWN for more examples.
  14. shankar-bavan revised this gist Oct 26, 2020. 1 changed file with 2 additions and 2 deletions.
    4 changes: 2 additions & 2 deletions bitbucket-pipeline-pull-files
    Original file line number Diff line number Diff line change
    @@ -46,7 +46,7 @@ Copy public key to ~/.ssh/authorized_keys on the remote host
    (login to server and go to above path and edit file with nano and paste the public key in new line)
    ===============================================================
    5. create file and copy below code.
    ```
    # This is a sample build configuration for PHP.
    # Check our guides at https://confluence.atlassian.com/x/e8YWN for more examples.
    # Only use spaces to indent your .yml configuration.
    @@ -70,4 +70,4 @@ pipelines:
    #SSH_KEY: $MYKEY
    PORT: $PORT
    COMMAND: "/var/folder-name/deploy.sh"
    ```
  15. shankar-bavan revised this gist Oct 26, 2020. 1 changed file with 32 additions and 0 deletions.
    32 changes: 32 additions & 0 deletions bitbucket-pipeline-pull-files
    Original file line number Diff line number Diff line change
    @@ -27,6 +27,9 @@ git remote set-url origin [email protected]:<workspace_ID>/<repo_name>.git

    =============================================================
    3. Bitbucket pipeline settings (variables)
    Go to Bitbucket -> repo -> repo-setting-> -> Pipelines -> Settings
    Enable pipeline

    Go to Bitbucket -> repo -> repo-setting-> -> Pipelines -> Repository variables
    Name: SSH_USER
    Value : centos (server username)
    @@ -38,4 +41,33 @@ untick secured
    ===============================================================
    4. Bitbucket pipeline settings (SSH Keys)
    Go to Bitbucket -> repo -> repo-setting-> -> Pipelines -> SSH Keys
    Click on Generate keys
    Copy public key to ~/.ssh/authorized_keys on the remote host
    (login to server and go to above path and edit file with nano and paste the public key in new line)
    ===============================================================
    5. create file and copy below code.
    ```
    # This is a sample build configuration for PHP.
    # Check our guides at https://confluence.atlassian.com/x/e8YWN for more examples.
    # Only use spaces to indent your .yml configuration.
    # -----
    # You can specify a custom docker image from Docker Hub as your build environment.
    image: php:7.1.29

    pipelines:

    branches:
    production:
    - step:
    name: Deploy to production
    deployment: production
    script:
    - echo "Deploying to production environment"
    - pipe: atlassian/ssh-run:0.2.2
    variables:
    SSH_USER: $SSH_USER
    SERVER: $SERVER
    #SSH_KEY: $MYKEY
    PORT: $PORT
    COMMAND: "/var/folder-name/deploy.sh"
    ```
  16. shankar-bavan created this gist Oct 26, 2020.
    41 changes: 41 additions & 0 deletions bitbucket-pipeline-pull-files
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,41 @@
    1. Setup ssh key on server
    https://support.atlassian.com/bitbucket-cloud/docs/set-up-an-ssh-key/

    ssh-keygen
    eval $(ssh-agent)
    ssh-add ~/.ssh/<private_key_file>

    ssh-add ~/.ssh/<private_key_file>

    Go to Bitbucket -> repo -> repo-setting-> Access Keys -> Add Key
    copy public key
    cat ~/.ssh/id_rsa.pub

    ssh -T [email protected]
    The command message tells you which of your Bitbucket accounts can log in with that key.
    If there any issues run below command (Permission denied (publickey))
    ssh-add -l
    ssh-add ~/.ssh/<private_key_file>

    =============================================================
    2. Update remote url
    Go to project directory
    git remote -v

    set ssh format url
    git remote set-url origin [email protected]:<workspace_ID>/<repo_name>.git

    =============================================================
    3. Bitbucket pipeline settings (variables)
    Go to Bitbucket -> repo -> repo-setting-> -> Pipelines -> Repository variables
    Name: SSH_USER
    Value : centos (server username)
    Name: PORT
    Value: 22
    Name:SERVER
    Value: IP address
    untick secured
    ===============================================================
    4. Bitbucket pipeline settings (SSH Keys)
    Go to Bitbucket -> repo -> repo-setting-> -> Pipelines -> SSH Keys