Actual branch name available when doing remote-run with git?

Is the branch name and last committer available as a build parameter when doing a remote run launched via a Branch Remote Run Trigger using git?  I do see the root branch (usually master) but not the actual branch the build is based on (remote-run/*).  I don't see last committer at all.

Thanks,
Josh

6 comments
Comment actions Permalink

Hello,
branch name and the last commiter are not available as build parameters. Feel free to create a feature request at http://youtrack.jetbrains.com .
As a workaround you can use an agent-side checkout, in this mode you have .git on the agent so you can retrieve the branch name and the commiter using git command line from your build script.

0
Comment actions Permalink

Dmitry,

I tried your suggested solution (agent-side checkout and use git), but git returns master. TC checks out master (or whichever ref is specified in the VCS confguration) and then applies a series of updates so that it reflects the state on the developers machine. As far as git is concerned, the current branch is still master though, even though the remote run was triggered from a topic branch.

Here's the relevant log:

[VCS Root: Acme] Checking out branch master in Acme in /home/teamcity/build-agents/build-agent-1/work/907d6490e34a8910 with revision 6cfa6b4e73bdaf8c1551cbadfd6eb86978a18756 Abc
Personal changes transferred
Updating sources: personal build patch...
[Updating sources: personal build patch...] Personal changes: replace: '/home/teamcity/build-agents/build-agent-1/work/907d6490e34a8910/app/assets/stylesheets/home.css.less'
[Updating sources: personal build patch...] Personal changes: replace: '/home/teamcity/build-agents/build-agent-1/work/907d6490e34a8910/app/views/layouts/application.html.erb'
[Updating sources: personal build patch...] Personal changes: replace: '/home/teamcity/build-agents/build-agent-1/work/907d6490e34a8910/app/helpers/application_helper.rb'
Publishing internal artifacts
Step 1/5: Git Branch (Command Line)
[Step 1/5] Starting: git branch --no-color
[Step 1/5] in directory: /home/teamcity/build-agents/build-agent-1/work/907d6490e34a8910
[Step 1/5] * master
[Step 1/5] Process exited with code 0



It seems like it's not likely we'll be able to get the current branch on the server. Is there a way to pass that information from the remote-run client and make it available via an environment variable or system property?

Thanks,
Christian
0
Comment actions Permalink

Hey Christian,

This is off topic, but based on your output, it looks ike you're doing some sort of personal build, and using git.  I was under the impression personal builds only worked with svn, perforce, and tfs (at least, that's all that's available via the TeamCity plugin for VS).  Our "personal builds" are simply a trigger that watches for a branch named like "/remote-run/*".  This requires us to create a quick branch, commit, and then push, and eventually go clean out old branches occasionally.

If I'm correct, then I'd say your solution doesn't require one's personal changes to get committed before a build.  How are you doing that?

Thanks,
Josh

0
Comment actions Permalink

Josh,

I've learned a bit since I wrote that reply. So, in that example I was triggering a "remote run outgoing changes" from rubymine on a project that uses git. That triggers a personal build on teamcity, and applies my local changes (committed but not pushed) on the build server. In this case, the git command line will only show whichever branch is configured in the vcs settings (likely master).

When I added a Branch Remote Run Trigger to the project, teamcity triggers a personal build for each push to branches that match a pattern. In this case, git returns the current branch.

The reason why I care in the first place is that our application has a banner that shows which branch is deployed, when the branch is something other than master. This is useful during development.

Cheers,
Christian

0
Comment actions Permalink

I just bought a copy of Rubymine.  I never considered that it's personal build features might offer more than the VS TeamCIty plugin.  I'll check that out.  Thanks for the tip.

We were wanting the branch name for a similar reason.  We use it to construct a little html blurb w/ a link right into the commit on github that goes at the bottom of every page.

Josh

0
Comment actions Permalink

There are different kinds of remote-runs. Remote-run from IDE knows nothing about personal branches, it just create a patch which is applied on top of the main branch. That is why when you remote-run build from IDE you get master branch on the agent.

And remote-run launched via Branch remote-run trigger knows about branches. I just checked: with agent-side checkout you get a personal branch in your working dir, so for example 'git branch' command there will return something like 'refs/heads/remote-run/feature'.

0

Please sign in to leave a comment.