Site icon Developpeur / integrateur web (Growth Hacker)

Bitbucket deploy avec RSYNC

Bitbucket, comme vu dans l’article précédent vous permet de déployer une branche master de votre repository depuis un pipeline. Vous commitez sur une branche x, et cela déploie.
Comment réaliser cela depuis Bitbucket.org et un serveur ionos.fr ou ovh ?

Configuration bitbucket :

pipelines:
  default:
    - step:
        name: Deploy to develop
        deployment: develop
        script:
          - pipe: atlassian/rsync-deploy:0.4.0
            variables:
              USER: $USER
              SERVER: $SERVER
              REMOTE_PATH: $REMOTE_PATH_DEVELOP
              LOCAL_PATH: $LOCAL_PATH
              EXTRA_ARGS: '--exclude-from=bitbucket-pipeline-exclude.txt'

  branches:
    staging:
      - step:
          name: Deploy to staging
          deployment: staging
          script:
            - pipe: atlassian/rsync-deploy:0.4.0
              variables:
                USER: $USER
                SERVER: $SERVER
                REMOTE_PATH: $REMOTE_PATH_STAGING
                LOCAL_PATH: $LOCAL_PATH
                EXTRA_ARGS: '--exclude-from=bitbucket-pipeline-exclude.txt'

    master:
      - step:
          name: Deploy to production
          deployment: production
          script:
            - echo "---- production ----"
      - step:
          name: Manual step FOR PROD
          trigger: manual # Step runs if you click the 'Run' button
          script:
            - pipe: atlassian/rsync-deploy:0.4.0
              variables:
                USER: $USER
                SERVER: $SERVER
                REMOTE_PATH: $REMOTE_PATH_PROD
                LOCAL_PATH: $LOCAL_PATH
                EXTRA_ARGS: '--exclude-from=bitbucket-pipeline-exclude.txt'

#    feature/*:
#      - step:
#          name: Deploy to feature
#          deployment: feature
#          script:
#            - echo "Lance uniquement pour nom de branche qui commence par 'feature/*' (ex. feature/lorem-ipsum)."

NB :
Vous pouvez déployer à partir d’une branche commençant par « feature/xxx », avec xxx qui correspond à votre nom de branche spécifique (préfixé de « feature/ »).

Dans l’exemple ci-dessus, la « prod » le pipeline ne pourra être finalisé que « manuellement ».

Le fichier bitbucket-pipeline-exclude.txt contient :
.git
README.md
bitbucket-pipelines.yml
bitbucket-pipeline-exclude.txt

Configuration Ionos / OVH :

Utiliser le pipeline :

Bitbucket-pipeline.yml que j’ai utilisé.
Simple et efficace.

https://bitbucket.org/atlassian/rsync-deploy
Quitter la version mobile