Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Git.Information doesn't work properly for VSO builds #933

Closed
vlukash opened this issue Sep 1, 2015 · 13 comments
Closed

Git.Information doesn't work properly for VSO builds #933

vlukash opened this issue Sep 1, 2015 · 13 comments

Comments

@vlukash
Copy link
Contributor

vlukash commented Sep 1, 2015

Seems like starting from 4.2.0 version some methods from Git.Information module doesn't work properly for VSO builds any more.
I'm using on-premises build server in VSO and both XAML and vNext builds.
And starting from 4.2.0 methods like getCurrentHash() and showName (".") methods return empty string.

In both cases (XAML and vNext) .git folder is copied into workdirectory during build, so as a workaround I just define
-ev JENKINS_HOME

NOTE:
environVar "BUILD_SOURCEVERSION"
and
environVar "BUILD_NUMBER"
are empty during build.

@forki
Copy link
Member

forki commented Sep 1, 2015

@matthid is this related to #915?

@matthid
Copy link
Member

matthid commented Sep 1, 2015

definitely ... so we need to change that to be a fallback behavior. But why are your environment variables empty? and if you don't have the sha1 hash how do you make sure to get the correct one?

@matthid
Copy link
Member

matthid commented Sep 1, 2015

I try to send a PR as soon as I can.

@vlukash
Copy link
Contributor Author

vlukash commented Sep 1, 2015

@matthid, don't know why environment variables are empty, I'll verify one more time today to be sure.
To get sha1 hash I use getCurrentHash() and I get all info like:
let gitInfo = getCurrentHash() |> showName (".")

@forki
Copy link
Member

forki commented Sep 1, 2015

are the env variables empty afteer you set -ev JENKINS_HOME or also before?

@matthid
Copy link
Member

matthid commented Sep 1, 2015

@vlukash Yes but IIRC the current hash (HEAD) is set in the ".git" folder, which you are copying from somewhere else, so you can't really be sure that the hash you get with getCurrentHash is the one you are building...

@vlukash
Copy link
Contributor Author

vlukash commented Sep 1, 2015

Here are more detailed info for two types of VSO build (both are using on-premises build server):
All using 4.2.0 version.

XAML build:
these variables are empty during build (doesn't matter -ev JENKINS_HOME is defined or no)
BUILD_BUILDNUMBER - empty
BUILD_SOURCEBRANCHNAME - empty
BUILD_SOURCEVERSION - empty

vNext build
Sorry for providing wrong info about vNext builds - in vNext variables aren't empty.
Here is example:
BUILD_BUILDNUMBER - 20150901.25
BUILD_SOURCEBRANCHNAME - develop
BUILD_SOURCEVERSION - 756135e37b9b2de5975bd5397d524b35c309c7d3

Only one difference in getCurrentHash() that in
4.1.0 it was like:
756135
and in 4.2.0 it is all hash like:
756135e37b9b2de5975bd5397d524b35c309c7d3

///////////////////////
So 4.2.0 is really works in vNext build but doesn't work for XAML

@vlukash
Copy link
Contributor Author

vlukash commented Sep 1, 2015

@matthid you are right, got your point about "can't really be sure that the hash you get with getCurrentHash is the one you are building".
Thanks.
I mistakenly thought that `getCurrentHash' will return hash that is currently building.

@matthid
Copy link
Member

matthid commented Sep 1, 2015

Ok I changed the behavior in #937, but it is a really close call.

On the one hand if someone puts so much work into getting the wrong result he should get it...

On the other hand it looks to be a common pitfall to copy the .git directory on TFS Builds to use git commands. Maybe FAKE should at least trigger a warning in this scenario?
@forki What is your opinion on this? Has FAKE similar scenarios where it warns its users or throws errors?

4.1.0 it was like:
756135
and in 4.2.0 it is all hash like:
756135e37b9b2de5975bd5397d524b35c309c7d3

Should we only return the first 6 characters to match the regular call? Does it matter anywhere?

@vlukash
Copy link
Contributor Author

vlukash commented Sep 2, 2015

@matthid Some thoughts about getCurrentHash and relation to actual hash that I'm building.

In the very beginning of build VSO copies (of just synchronizing) .git to build folder on build agent. In both cases (XAML, vNext).
After this VSO checkouts git branch (or specific commit) that was configured for current build (via build definition or "queue new build dialog"). And then VSO explicitly set HEAD to commit that is used for current build.

Based on this, current HEAD hash (and value that getCurrentHash returns) always will be the one I'm building and it is configured by VSO. I've tested this in vNext builds - BUILD_SOURCEVERSION and HEAD from git are always equal even when I set specific commit number to build.

Please correct me if I wrote something wrong

@matthid
Copy link
Member

matthid commented Sep 2, 2015

This would be awesome!
Where is this .git folder? Is this folder generally accessible and the same (at least relative to the current directory?) for all Build Agents?

Should we integrate the copying process into FAKE? Or at least provide a API for it?

@forki forki closed this as completed in f5c051b Sep 2, 2015
forki added a commit that referenced this issue Sep 2, 2015
use TFS variables as fallback, fixes #933
@vlukash
Copy link
Contributor Author

vlukash commented Sep 2, 2015

@matthid Maybe I've explained it not very well, but under "copying" .git folder I meant something like "git clone" command executed by VSO itself.

I use VSO as a repository for git project. and when I trigger new build VSO creates (clones from origin) this local .git folder on build server for me. And then VSO checkouts branch or commit that should be built and set HEAD to specific commit.

So all this functionality is already build-in into VSO+build agent

@vlukash
Copy link
Contributor Author

vlukash commented Sep 2, 2015

@matthid Thanks for fixing this issue!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants