Problem with build trigger when tracking a second branch
Hi, I think this is a bug that I'm reporting. We have some
repository on GitHub with two branches: master
and
staging
On AppHarbor, we have two application, Dev
app that
is set up to track the master
branch (using default,
with "only build tracking branch" unchecked) and the
Staging
app that is set up to track the
staging
branch (with "only build tracking branch"
checked) .
So we make check-ins in the master branch:
commit#1
, commit#2
and
commit#3
. Each will trigger a new build for the
Dev
app. Good. Now if we add the same commits into the
staging
branch, they won't trigger any builds on the
Staging
app. If we make a new commit to the
staging
branch that does not exist in the other
branch, then it will trigger a new build.
Our workaround for now is after we pull changes from
master
into staging
, we make a dummy
check-in at the end to trigger a build on the Staging
app. And then we pull out the dummy commit.
I think when you're tracking a branch, it should always trigger a build every time there is a new commit in that branch, regardless of if that change is in any other branch.
Discussions are closed to public comments.
If you need help with AppHarbor please
start a new discussion.
Keyboard shortcuts
Generic
? | Show this help |
---|---|
ESC | Blurs the current field |
Comment Form
r | Focus the comment reply box |
---|---|
^ + ↩ | Submit the comment |
You can use Command ⌘
instead of Control ^
on Mac
Support Staff 1 Posted by rune on 09 Oct, 2015 02:57 PM
Hi,
Ok I'm not sure this is actually a bug, but I can see why it can be a bit confusing with the "Only build tracking branch" set. Essentially it should work the same way you expect (at least on GitHub), i.e. a push to a branch should trigger a build regardless of whether the commits in the branch are also found in another branch). You mention a scenario where you:
master
branch which triggers a build every time on the Dev app.staging
branch, but this does not trigger a build on the staging app.How do you add the same commits to the staging branch in step 2? Also, do you push to the branch on GitHub after adding the commits (i.e.
git push origin staging
) after adding them?It may be helpful to disable the "Only build tracking branch" while isolating this. It won't change the behavior with regards to automatic deployments, but it'll allow us to see exactly what branch GitHub sends a notification to AppHarbor about where you push. The feature is really just there to avoid having a lot of builds in your build overview.
Also, it'd be great if you can let me know a couple of commit ids where a build should've been triggered so I can take a closer look at why it didn't happen.
Best,
Rune
2 Posted by Finnav on 09 Oct, 2015 04:59 PM
Hi Rune,
I use this command to add commits to
staging
:I've also tried updating
staging
branch locally by rebasing it to themaster
and then pushing that to github, which didn't work either.The behavior is the same with "Only build tracking branch" checked or unchecked.
You can try it for yourself:
origin master
staging
branch is behindmaster
, dogit push origin master:staging
. Even though it updates the branch on GitHub it won't trigger a build on AppHarbor.staging
which does not already exist inmaster
, makingstaging
ahead ofmaster
and that will trigger a build on AppHarbor.3 Posted by Finnav on 09 Oct, 2015 05:21 PM
Trying to push directly to the AppHarbor git address also didn't work:
The command takes too long and it is as if it is trying to copy everything to the remote, and then after about 7 minutes disconnects.
Support Staff 4 Posted by rune on 11 Oct, 2015 09:04 PM
Hi again,
Ok I see what you mean now. The AppHarbor service hook is invoked on the
receive_push
event, but it seems like GitHub doesn't trigger receive action when the branch ref is just updated (which is essentially what thegit push origin staging:master
command does).I think this can be addressed in a few ways, but the simplest solution is to just disable the "Only build tracking branch" feature. This way all your new code pushes will be built on the applications you've connected with the repository, and given your current workflow this would allow you to simply click the "Deploy" button on the
master
branch commits which will also be built on the staging app.Another way to address this would include changing your workflow a bit. For instance you could:
staging
branch. Pushing will trigger builds on the app tracking thestaging
branch, so you can test and verify the application before merging into master.master
and merge thestaging
branch into it, with fast-forward disabled. This will create a merge commit on top of themaster
branch so you don't have to create another "dummy" commit.This approach is that (unlike a fast forward merge) you'll retain historical information about when a branch was merged into master, and the context of those commits. It's similar to the merge commit GitHub make when you create and merge a pull request. I can recommend reading this Stack Overflow answer which discusses the pros and cons of each approach.
An added bonus is that is also make for a better overview of your builds/deployments on AppHarbor, particularly if you start using more more descriptive "feature branch" names. For instance your, production app tracking the
master
branch commit messages might look like this if you push every time you merge a feature branch:This can make it a lot easier to quickly identify what feature/changes were introduced in a merge. With your current approach the commit message is just the last commit message on your branch (like
Remove unused usings
) or similar.I hope this helps, but please don't hesitate to reach out if this raises new questions or there's anything else I can help with.
Best,
Rune
5 Posted by Finnav on 12 Oct, 2015 05:02 PM
Hi Rune,
master
is actually our daily dev branch, we have astaging
branch for internal tests and a separateproduction
repo that we push to it fromstaging
for releases. But I think I understood your suggestions. I think merging with fast-forward disabled would work. You may want to document this known issue somewhere in your wikis.I think this ticket is resolved.
Thanks!
Support Staff 6 Posted by rune on 13 Oct, 2015 01:13 PM
Hi again,
Ok great, let me know if this workflow causes problems for you at some point and I might be able to help out. I also forgot to mention another advantage with non fast-forward merges that I value a lot: Consider a scenario where you're on the
staging
branch and want to integrate and test a new feature (from thedev
branch or another feature branch) you'd:This would create a "Merge branch 'dev' into master" merge commit. Now you can push this to your repo and test how it works, but if you want to roll back the change you can simply delete the merge commit (or, technically, reset the
dev
branch HEAD ref to point to the previous commit) by doing so:With a fast-forward merge your commits would just appear on the same branch, and you'd have to remember what commits you wanted to delete (or the
staging
HEAD before the merge).Also thanks for the feedback about documenting the behavior when pushing to GitHub. I think in this case the solution will be to remove the option to "Build only from tracking branch" option as that can and will cause confusion in many cases. It was initially added since some customers would push builds to several apps tracking different branches, and building each branch on every app would clutter the build/deployment overview on AppHarbor. It was intended to be a temporary stop-gap measure, but can be handled more elegantly in the UI (by filtering builds based on branches). By doing so it should be possible to make this process much more intuitive so (ideally) developers wouldn't have to consult the documentation at all.
Best,
Rune
7 Posted by cottsak on 02 Jan, 2017 12:14 AM
I tried the
--no-ff
workaround to force the "merge commit" and that seems to work. Problem is that it make the other environment/branch build history dirty too. Seems all too much fuss when I can just-On the production site, simply specify a tracking branch
prevent-deploy-branch
which obviously i never create anywhere and this allows that site to build every commit onmaster
but deploy none of them automatically. Like @Rune said, I just manually "Deploy" the commit I want in my production site and I'm golden. Simple!rune closed this discussion on 03 Jan, 2017 05:21 PM.