Issue in merging files from stag barnch to prod branch ignoring certain files using the bitbucket-pipelines.yml file

I have a use case. I have two branches “stag” and “prod”. The stag branch contains three files appspec.yml, buildspec.yml, commonfile.txt, and scripts folder.

The prod branch also contains files named the same appspec.yml, buildspec.yml, commonfile.txt, and scripts folder.

My use-case:

Here, I make a lot of changes in the files of the stag branch and then merge those on the prod branch. However, I want that every time I merge the stag branch with the prod branch, the files named buildspec.yml, appsepc.yml, and scripts folders remain the same on both branches and the changes to these files and folders are ignored every time a merge is done from the stag to the prod branch and vice versa.

I have accomplished this task locally using the “ours” merge driver. But I want this to happen using the bitbucket pipeline so that every time a pull request is made, a merge is done automatically (with manual intervention) and ignoring the appspec.yml, buildsepc.yml, and scripts folder.

This is my current bitbucket-pipelines.yml file:

pipelines:
  pull-requests:
    "**": # Matches all pull requests on any branch
      - step:
          name: Merge Pull Request Source into Target
          image: atlassian/default-image:latest
          script:
            # Output source and target branch details
            - echo "Pull Request triggered. Source Branch:$BITBUCKET_PR_SOURCE, Target Branch:$BITBUCKET_PR_DESTINATION"

            # Clone the repository
            - echo "Cloning the repository"
            - git clone https://$BITBUCKET_USERNAME:[email protected]/des*******/de*********.git
            - cd deshMergeRepo/
            
            # Fetch the branches involved in the PR
            - git fetch origin $BITBUCKET_PR_SOURCE
            - git fetch origin $BITBUCKET_PR_DESTINATION

            # Checkout the target branch
            - echo "Checking out the target branch:$BITBUCKET_PR_DESTINATION"
            - git checkout $BITBUCKET_PR_DESTINATION

            # Configure Git
            - echo "Setting up Git configuration..."
            - git config --global user.email "de*****@gmail.com"
            - git config --global user.name "de*****"

            # Merge the source branch into the target branch without committing
            - echo "Merging $BITBUCKET_PR_SOURCE into $BITBUCKET_PR_DESTINATION"
            - git merge --no-commit origin/$BITBUCKET_PR_SOURCE || true

            # Check for merge conflicts
            - echo "Checking for conflicts"
            - git diff --name-only --diff-filter=U || true # Check for conflicts

            # Resolve conflicts if any
            - echo "Resolving conflicts (if any) by keeping the destination branch version for specific files"
            - git checkout --ours appspec.yml buildspec.yml scripts/ || true
            - git add appspec.yml buildspec.yml scripts/ || true

            # Commit the merge
            - echo "Committing the merge"
            - git commit -m "Merged $BITBUCKET_PR_SOURCE into $BITBUCKET_PR_DESTINATION, resolving conflicts as necessary" || true

            # Push changes to the destination branch
            - echo "Pushing changes to $BITBUCKET_PR_DESTINATION"
            - git push origin $BITBUCKET_PR_DESTINATION

            - echo "Merge completed successfully for pull request."

But every time the pipeline shows the error:

Have anyone gone through this use case.

This is what I am trying to achieve:

  1. A pull request is made from stag to prod branch
  2. The bitbucket pipeline will sense that and start the run
  3. There will be a manual approval before the main merge (The developer will check the changes and trigger the manual approval for the actual merge)
  4. The pipeline will move ahead with doing the actual merge and ignoring the appspec.yml, buildspec.yml file and scripts folder.

Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa Dịch vụ tổ chức sự kiện 5 sao Thông tin về chúng tôi Dịch vụ sinh nhật bé trai Dịch vụ sinh nhật bé gái Sự kiện trọn gói Các tiết mục giải trí Dịch vụ bổ trợ Tiệc cưới sang trọng Dịch vụ khai trương Tư vấn tổ chức sự kiện Hình ảnh sự kiện Cập nhật tin tức Liên hệ ngay Thuê chú hề chuyên nghiệp Tiệc tất niên cho công ty Trang trí tiệc cuối năm Tiệc tất niên độc đáo Sinh nhật bé Hải Đăng Sinh nhật đáng yêu bé Khánh Vân Sinh nhật sang trọng Bích Ngân Tiệc sinh nhật bé Thanh Trang Dịch vụ ông già Noel Xiếc thú vui nhộn Biểu diễn xiếc quay đĩa Dịch vụ tổ chức tiệc uy tín Khám phá dịch vụ của chúng tôi Tiệc sinh nhật cho bé trai Trang trí tiệc cho bé gái Gói sự kiện chuyên nghiệp Chương trình giải trí hấp dẫn Dịch vụ hỗ trợ sự kiện Trang trí tiệc cưới đẹp Khởi đầu thành công với khai trương Chuyên gia tư vấn sự kiện Xem ảnh các sự kiện đẹp Tin mới về sự kiện Kết nối với đội ngũ chuyên gia Chú hề vui nhộn cho tiệc sinh nhật Ý tưởng tiệc cuối năm Tất niên độc đáo Trang trí tiệc hiện đại Tổ chức sinh nhật cho Hải Đăng Sinh nhật độc quyền Khánh Vân Phong cách tiệc Bích Ngân Trang trí tiệc bé Thanh Trang Thuê dịch vụ ông già Noel chuyên nghiệp Xem xiếc khỉ đặc sắc Xiếc quay đĩa thú vị
Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa
Thiết kế website Thiết kế website Thiết kế website Cách kháng tài khoản quảng cáo Mua bán Fanpage Facebook Dịch vụ SEO Tổ chức sinh nhật