- 
                Notifications
    
You must be signed in to change notification settings  - Fork 19
 
Description
TL;DR: Please git pull the branch before pushing it, to avoid clashes of parallel usage
Developers of our solution team are big fans of gitopscli and create-preview.
A consequence of that is, that there is a a lot of activity in our config-repo, as each push to a branch creates a preview environment to run tests against it.
Unfortunately parallel preview creation is currently crashing many times.
Because while Job A is cloning the repo (takes 30-40 seconds), Job B may commit its preview configs onto master.
Then when Job A wants to push its changes, a git error appears like this: "Updates were rejected because the remote contains work that you do have locally"
10:43:43  + gitopscli create-preview --git-provider-url https://bitbucket.balgroupit.com/ --git-user customer-contact-devops-user --git-email ****@balgroupit.com --organisation CIP --repository-name mybaloise-api --preview-id 93b81dce3a794ca0d3aca4ae2fb8bb5a24d85c22_CI --git-hash 23140757b95b0f8da8dabbf3c056a1db4efa69e9
10:44:07  INFO clone: Cloning repository: https://bitbucket.balgroupit.com/scm/dplcaast01/customer-contact-non-prod.git
10:44:17  INFO __create_preview_from_template_if_not_existing: Create new folder for preview: mybaloise-api-65c6c2dc-preview
....
10:44:18  INFO push: Pushing branch: master
10:44:18  ERROR main: Error pushing branch 'master' to origin: 
10:44:18    stderr: 'To https://bitbucket.balgroupit.com/scm/dplcaast01/customer-contact-non-prod.git
10:44:18   ! [rejected]            master -> master (fetch first)
10:44:18  error: failed to push some refs to 'https://bitbucket.balgroupit.com/scm/dplcaast01/customer-contact-non-prod.git'
10:44:18  hint: Updates were rejected because the remote contains work that you do
10:44:18  hint: not have locally. This is usually caused by another repository pushing
10:44:18  hint: to the same ref. You may want to first integrate the remote changes
10:44:18  hint: (e.g., 'git pull ...') before pushing again.
Proposal is to add "git pull --no-rebase" to this line here:
https://github.com/baloise/gitopscli/blame/0e9b8de52d29812990337e3d85d978e899a2706e/gitopscli/commands/create_preview.py#L104