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

Use pipeline to only deploy changed files

finnruijter July 15, 2021

Hi there!

I'm using the following .yml file to push the repo to WPengine. Problem with these commands is that it deploys all. Is it possible to only deploy the changed files in the commit? What should the commands be?

pipelines:
branches:
master:
- step:
name: Deploy to production
deployment: production
script:
- git filter-branch -- --all
- git push --force git@git.wpengine.com:production/XXX.git master
- echo "Pushed to Production"


dev:
- step:
name: Deploy to dev production
deployment: dev
script:
- git filter-branch -- --all
- git push --force git@git.wpengine.com:production/XXX.git dev
- echo "Pushed to Dev Production"

 

Thanks in advance!

1 answer

0 votes
Theodora Boudale
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
July 21, 2021

Hi @finnruijter,

I suspect (although I'm not entirely sure) that this may have to do with the use of --force option to push, as this option will force the remote repo (in this case the WPengine repo) to take the version of the branch that exists in Pipelines.

Just to understand the issue a bit better before I proceed with suggestions, where exactly and how do you see that all files are being deployed, instead of only the files in the last commit?

Kind regards,
Theodora

finnruijter July 21, 2021

Hi @Theodora Boudale !

 

Thank you for your answer. Removing --force sadly results into a failed deployment. I'm using this document from WPengine to configure the deployment: https://wpengine.com/support/deploying-code-with-bitbucket-pipelines-wp-engine/.

Screenshot at Jul 21 14-12-56.png

Theodora Boudale
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
July 26, 2021

Hi @finnruijter ,

Thank you for the info.

The first question I would like to ask is whether you are pushing changes to master branch of this WPengine repo from elsewhere, e.g. if there is anyone from your team or another Pipelines step, or if you have a script or tool that pushes to master branch of this repo. This is one possible cause for this error.

If the above is not the case, i.e. if only this Pipelines step pushes to master, then I suspect the command

git filter-branch -- --all

may be the culprit. I have tried testing your scenario by pushing to another Bitbucket repo, as I don't have a WPengine repo to test. Bitbucket repo 2 where I was trying to push is a fork of the repo where I was running Pipelines. Push without --force would fail when the above command was included in the yaml file, but it would succeed without it.

Is that command necessary for WPengine? I don't see it in the guide you linked here. My suggestion would be to try removing the above command, and also do a full clone in your Pipelines step, as I believe it is needed for pushing to the WPengine repo, see here: https://community.atlassian.com/t5/Bitbucket-questions/Pipeline-issue-with-wp-engine/qaq-p/1667433

master:
- step:
name: Deploy to production
deployment: production
clone:
depth: full
script:
- git push git@git.wpengine.com:production/XXX.git master
- echo "Pushed to Production"

Is this something that works for you?

Please do let me know about the question I asked initially as well, whether there is another Pipelines step, a script, a tool, or anyone from your team pushing to master branch of the WPengine repo. If this is the case, the above won't work, and we'll need to look into different options.

Kind regards,
Theodora

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events