It looks like Azure Websites can only deploy from a branch when linked to a repository from providers such as Bitbucket. My current workaround is to create the tag as a branch. I have tried the following with no success:
v1.0tags/v1.0refs/tags/v1.0This feature would be especially helpful when having multiple deployment slots within an Azure Website. Thanks for all your hard work :)
Ok, here is the deal. The commands we run to do the fetch look like this:
git remote add -t test external https://github.com/KuduApps/RepoWithMultipleBranches
git fetch external --progress
But if test is a tag and not a branch, it fails with:
fatal: Couldn't find remote ref refs/heads/test
I was hoping it would just work for either, but I guess that's not how git remote add -t works.
If I try refs/tags/test, it fails with:
fatal: Couldn't find remote ref refs/heads/refs/tags/test
We'll need to find a different git sequence to make that work. But note that we want to do a fetch from just that branch/tag, and not for the who remote repo (for perf/space reasons).
We could just do:
git remote add external https://github.com/KuduApps/RepoWithMultipleBranches
git fetch external test
But I seem to recall we had some reason for using the quirkier git remote add -t syntax. I'm just not sure what it was...
Is there any news on this issue? I have a project in GitHub which creates a release as a tag not a branch.
This would be a nice feature to add. When working with Prod environments it's key to have them pointing to a fixed tag. GitHub unfortunately doesn't give me an option to create a release as a branch.
Sorry, short answer is that there hasn't been progress on this. I do hope we will get to it as it is a valid feature.
I'd like to throw in my support for deploy-by-tag instead of by branch.
Hey @davidebbo. I was just wondering if this feature request has been discussed/planned at all?
Still no progress on this one, sorry! I would like to have it addressed, but getting it on the schedule with all the other priorities is the hard part.
Now that we're using libgit2sharp, the code is pretty different from before. Current code is here.
First, we need to have a design. Two choices:
I'd rather do 1., as this will limit the scope of the change. So it's a matter a reworking that code to first check for a branch, and then fall back to a tag.
If someone from the community wants to have a go at it, we would welcome a PR on this one!
Thanks @davidebbo. I'm guessing the majority of code change would be implemented around here? I'll try and have a go at implementing the change.
It's probably a bit more complicated than that. The problem is that to optimize things, we don't do a full fetch, but only fetch the relevant branch:
c#
var refSpec = string.Format("+refs/heads/{0}:refs/remotes/{1}", branchName, trackedBranchName);
var remote = repo.Network.Remotes.Add(_remoteAlias, remoteUrl, refSpec);
repo.Network.Fetch(remote);
If branchname is actually a tag, I think you'll end up fetching nothing at all. And I'm not really sure what this fetch code should become for tags, because tags don't quite work like branches (e.g. they don't have a remote tracking branch).
http://stackoverflow.com/questions/791959/download-a-specific-tag-with-git relates to this, but I think only the second answer is 'optimized'. It claims that git clone --branch my_abc http://git.abc.net/git/abc.git works for tags. Though I don't know what that means in libgit2sharp.
So there are some challenges :)
Thanks @danlister for contributing a fix!
Will the How To info land in docs/wiki?
@danlister, can you please explain how it works?
You stated in #2049:
Navigate to a Web App on management.azure.com
This is https://manage.azure.com/ right? Because management.azure.com is a RESFUL API URL (see https://msdn.microsoft.com/en-us/library/azure/dn832684.aspx)..
Change the "Branch to Deploy" configuration property to a tag
what does that mean? My tag is v7.1 and I have only one branch master (v7.1 is not a branch, but a tag). Locally when I do git clone <url> -b v7.1 or git clone <url> && git checkout refs/tags/v7.1, I get HEAD is now at xxxxxxx...
Does it mean I should go to https://manage.windowsazure.com > My Web App > Configure and set "Branch to deploy" to v7.1? Or does that mean I should set "Branch to deploy" to refs/tags/v7.1 or +refs/tags/v7.1? None of these are working form me when I am syncing the repo through https://manage.windowsazure.com/ > My Web App > Deployments tab but respectively throwing (shows these via SCM):
fatal: Couldn't find remote ref refs/heads/v7.1
fatal: Couldn't find remote ref refs/heads/refs/tags/v7.1
fatal: Couldn't find remote ref refs/heads/+refs/tags/v7.1
@davidebbo, I tested this 5 minutes ago, so I must have the latest instance right? I created this app 2 months ago. Do the updates applied automatically?
@jasonwilliams200OK Sorry, I meant navigate to https://manage.windowsazure.com/. At the minute, it seems you can only change which branch is deployed via the old management site.
In your instance, you should set it refs/tags/v7.1. Can you confirm that you have pushed all your tags or re-push them all please? git push --tags should do the trick.
@danlister I think the issue may be that your new logic only works in the local git scenario, which gives you the option of pushing the tags to Azure. But in the GitHub CI scenario, it's Azure that's fetching from GitHub, and I'm guessing this won't work if you set the branch to a tag. That's what I meant below with my comment starting with "It's probably a bit more complicated than that.".
So at this point the tag support is only partial.
@danlister, @davidebbo, thanks for the confirmation. I can see that the fix was applied to LibGit2SharpRepository but not the GitExeRepository. Can we add the similar fix to GitExeRepository? I am not using CI scenario, my GitHub repo is configured so Kudu triggers the build on push using git.exe.
The reason why we cannot use LibGit2SharpRepository is that we are using SSH URL and we can't do the password authentication due to our shared service account (a bot account).
Reopening issue to mark that what we have only provides a partial solution to the problem, as it only works for the direct Git Push to Azure scenario (aka Local Git).
@davidebbo, so technically if we define SCM_USE_LIBGIT2SHARP_REPOSITORY in Azure Web App's Configure tab to value 1, it supports refs/tags/<tag-name> and if we don't define that, then this implementation is used: https://github.com/projectkudu/kudu/blob/master/Kudu.Core/SourceControl/Git/GitExeRepository.cs (shelling out to git.exe which supports SSH URLs). Is that correct? In which case can we make the similar changes to GitExeRepository (instead of hard-coding refs/heads/)?
No, that will not work. The current fix will only work for the direct git push scenario, and not for any continuous integration scenario like GitHub.
any updates on this?
No update. At this point, we have the partial fix from @danlister.
thx for the info though, would love to see it in the future!
Second this. Not being able to use tags I am forced to create a custom pipeline that uploads a zip file through Kudu.
Please support tags for deployments, otherwise I have to set up multiple (many many of them) git repositories.
for me refs/tags/mytagname doesn't work. How can we support git tags like good netizens? Is this on the roadmap?
This is ridiculous, please add support for pushing tags. Tags are the way to deploy code properly.
Most helpful comment
Please support tags for deployments, otherwise I have to set up multiple (many many of them) git repositories.