microsoft / vso-agent

Visual Studio Team Services and TFS agent for Mac OSX and Linux
MIT License
131 stars 56 forks source link

Mac agent with External git doesn't build with fresh environment #286

Closed bc3tech closed 8 years ago

bc3tech commented 8 years ago

We've got a Mac build agent provisioned as a build server and we've tied the build definition to an External Git repo.

When we do builds, we've found that we get the git clean -fdx error message, but we've then noticed that it does the entire build against an old version of the source - this is to say that _work/s only has one directory under it (in our case "2") and it's reused between builds.

This seems like bad practice; I would prefer each build gets done in its own "clean" space and we maintain _work/s/# up to the retention policy limit.

nigurr commented 8 years ago

There's an option for this. Open your build job -> Repository -> Change "Clean" option to true. That will do refresh the repo for every build

bc3tech commented 8 years ago

yup, that's actually selected - trying to do this is what's causing the git clean -fdx error I pointed out above...

bryanmacfarlane commented 8 years ago

It doesn't do the build against the old version of the source. That's not correct.

Clean checkbox will do git clean -fdx and reset hard, then it will fetch the commit of the source from the build. ~ line 119 here https://github.com/Microsoft/vso-agent/blob/master/src/agent/scm/git.ts

So, checking clean means it will (1) discard anything not in the repo and reset the state back to what was in the repo and then (2) pull new source changes up to the commit the build is being run for.

there's another variable you can set on the definition which is build.clean=delete I believe. But, I want to set the record state that what's being asserted is not true.

bc3tech commented 8 years ago

hm. well if it's not building against old i'm not sure how I could explain that we check a file in to master, tell it to build master, and what shows up on the build agent under _work/#/s of the build that's running is not the version we checked in... it seems that somehow it's either not fetching, or fetching the wrong commit.

bryanmacfarlane commented 8 years ago

What version of the agent do you have ? (in package.json in the root of the agent).

The build summary should have the commit it built.

If you look at the build console, you will see exactly what commands we run live while we run it. For example, I just kicked off a build to confirm. Here's my console output:

git clean -fdx
Removing Tasks/ANT/anttask.js
...

git reset --hard HEAD
HEAD is now at 97477b5 delete old cocoa pods bash impl.  handler not supported anymore

git fetch origin

git checkout 97477b56ddd3ed79127f8421819f22a8af8cbf06
HEAD is now at 97477b5... delete old cocoa pods bash impl.  handler not supported anymore

I then looked at the build at the end of the build and it has on the summary page: Associated changes

Commit 97477b5 Authored by Bryan MacFarlane delete old cocoa pods bash impl. handler not supported anymore

I checked the package built and uploaded, it has the change I just checked in.

bryanmacfarlane commented 8 years ago

Still can't repro

https://github.com/Microsoft/vsts-agent