a·gen·tic a·gil·i·ty

Maven release perform tries to do a Get to a workspace sub folder in TFS

Explains issues with Maven release perform in TFS workspaces, causes of build failures, and solutions for workspace mapping, concurrency, and label handling during migration.

Published on
5 minute read
Image
https://nkdagility.com/resources/yXZtGRWsXfS
Subscribe

If you are using TFS and specifically switching from SVN to TFS then you might run into the issue that your Maven release perform tries to do a Get to a workspace sub folder. This will not work as TFS has a validation exception to trying to map a sub folder inside an existing workspace. That could be disastrous in a real situation.

Could you imagine if, while in the middle of a compile, another build kicked off and overwrite your files? Worse if that other build was executing an only slightly different version of your codebase and it created a successful compile of goodness knows what disaster waiting to happen. (shiver.)

To be honest I am not really a fan of the whole compile and release in one tool. The problem is that if I have just deployed and validated a version of the code I want that version deployed. Not a new one, which is exactly what I get it if I compile again. Compiled output always have meta data associated with them and that changes every time you build. So your output, while likely extremely code to your previous compile if the code has changes will always be different. No sensible QA manager would ever sign of on that. A more secure and consistent deployment can be gained by [creating a binary release pipeline] that starts at DEV.

Anyway, this issue was about the maven release perform stage where my build that I am trying to configure to use TFS tries to do a GET of the label it just created (what value there is in this I do not know) to a sub folder of the current workspace. This does not error, but does result in a missing folder and thus a missing .pom file.

 1[INFO] Scheme - https
 2[INFO] files: /appl/data/ci-test/jenkins/jobs/TFS-TestProject/workspace
 3[INFO] Command line - /bin/sh -c cd /appl/data/ci-test/jenkins/jobs/TFS-TestProject/workspace && tf checkin -login:hinshelwoodmjh,****** -noprompt '-comment:[maven-release-plugin] prepare for next development iteration' /appl/data/ci-test/jenkins/jobs/TFS-TestProject/workspace/pom.xml /appl/data/ci-test/jenkins/jobs/TFS-TestProject/workspace/TestProjectLibrary/pom.xml /appl/data/ci-test/jenkins/jobs/TFS-TestProject/workspace/TestProjectWeb/pom.xml /appl/data/ci-test/jenkins/jobs/TFS-TestProject/workspace/TestProjectEar/pom.xml /appl/data/ci-test/jenkins/jobs/TFS-TestProject/workspace/TestProjectDistribution/pom.xml
 4[INFO] err -
 5[INFO] Release preparation complete.
 6[INFO]
 7[INFO] --- maven-release-plugin:2.5:perform (default-cli) @ TestProject ---
 8[INFO] Checking out the project to perform the release ...
 9[INFO] scmUrl - https://tfs.comapny.com/tfs/DefaultCollection::$/MainProject/VisualStudioALM/JavaTestProject
10[INFO] Scheme - https
11[INFO] Command line - /bin/sh -c cd /appl/data/ci-test/jenkins/jobs/TFS-TestProject/workspace/target/checkout && tf get -login:hinshelwoodmjh,********** -recursive -force -version:LTestProject-1.4.10 /appl/data/ci-test/jenkins/jobs/TFS-TestProject/workspace/target/checkout
12[INFO] err -
13[INFO] Executing goals 'javadoc:jar deploy'...
14[INFO] [INFO] Scanning for projects...
15[INFO] [INFO] ------------------------------------------------------------------------
16[INFO] [INFO] BUILD FAILURE
17[INFO] [INFO] ------------------------------------------------------------------------
18[INFO] [INFO] Total time: 0.100s
19[INFO] [INFO] Finished at: Fri May 23 14:42:40 CEST 2014
20[INFO] [INFO] Final Memory: 5M/10M
21[INFO] [INFO] ------------------------------------------------------------------------
22[INFO] [ERROR] The goal you specified requires a project to execute but there is no POM in this directory (/appl/data/ci-test/jenkins/jobs/TFS-TestProject/workspace/target/checkout). Please verify you invoked Maven from the correct directory. -> [Help 1]
23[INFO] [ERROR]
24[INFO] [ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
25[INFO] [ERROR] Re-run Maven using the -X switch to enable full debug logging.
26[INFO] [ERROR]
27[INFO] [ERROR] For more information about the errors and possible solutions, please read the following articles:
28[INFO] [ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MissingProjectException
29[INFO] ------------------------------------------------------------------------
30[INFO] Reactor Summary:
31[INFO]
32[INFO] Test Project ...................................... FAILURE [42.119s]
33[INFO] Test Project - Common Library ..................... SKIPPED
34[INFO] Test project - Web Application .................... SKIPPED
35[INFO] Test Project - Enterprise Application for web application  SKIPPED
36[INFO] Test project - Distribution project ............... SKIPPED
37[INFO] ------------------------------------------------------------------------
38[INFO] BUILD FAILURE
39[INFO] ------------------------------------------------------------------------
40[INFO] Total time: 43.130s
41[INFO] Finished at: Fri May 23 14:42:40 CEST 2014
42[INFO] Final Memory: 14M/31M
43[INFO] ------------------------------------------------------------------------

This understandably results in a failed build/release. Not only did this one take a while to understand I had to consult with an awesome Java expert in the form of Corstijan Kortsmit who identified the solution in about three seconds. It was one of those “Oh… that… you just…” sort of answers.

Maven release perform tries to do a Get to a workspace sub folder in TFS

If you head over to the configuration of your build and look for a section entitled “Build Environment”. Here there are two important sections. We have a couple of boxs to put additional command line parameters for the maven release plugin. We need to add at least a “-DworkingDirectory” parameter with a specific folder for where to do the get.

-Dresume=false release:prepare release:perform -DworkingDirectory=/appl/data/temprelease -Dgoals=clean install

The additional issues to think about are around multiple users as well as multiple builds working simultaneously and multiple users.

Multiple builds is solved by adding parameters for something unique to the instance. In Team Build each ‘Agent’ can only run one build at a time but you can run multiple agents on a single server. Each agent gets a unique ID and by default TFS created a distinct workspace for each instance that can be shared across instances of the same build. This makes the second build potentially faster on any given agent as you don’t need to always clean workspaces as you can sync them. Here I could not see an agent ID so we went with the Build Instance ID. The down side to this is that you have to do a full get for every build and it might be slower.

Multiple users is an easier issue to solve. We added pre-build commands to create a workspace in the folder above and we made it ‘public’ meaning that any user can use it. By default a workspace is created as ‘private’ and another user can’t use that folder. With a ‘public’ workspace we can have the first user create it and then reuse it time again for other users.

This got the build working. Our only outstanding issue now is that build from SVN have a Tag created. In TFS this is done as a label, however labels are mutable. They can be changed after the fact with no audit record. We will likely solve this by creating a read-only branch instead of a label.

Let me know how you get on with your migrations to TFS.

Troubleshooting Software Development
Subscribe

Related blog

Related videos

Connect with Martin Hinshelwood

If you've made it this far, it's worth connecting with our principal consultant and coach, Martin Hinshelwood, for a 30-minute 'ask me anything' call.

Our Happy Clients​

We partner with businesses across diverse industries, including finance, insurance, healthcare, pharmaceuticals, technology, engineering, transportation, hospitality, entertainment, legal, government, and military sectors.​

Schlumberger Logo

Schlumberger

Microsoft Logo

Microsoft

ProgramUtvikling Logo

ProgramUtvikling

Slaughter and May Logo

Slaughter and May

Lean SA Logo

Lean SA

Teleplan Logo

Teleplan

New Signature Logo

New Signature

NIT A/S

Illumina Logo

Illumina

Flowmaster (a Mentor Graphics Company) Logo

Flowmaster (a Mentor Graphics Company)

Graham & Brown Logo

Graham & Brown

Sage Logo

Sage

SuperControl Logo

SuperControl

Alignment Healthcare Logo

Alignment Healthcare

Higher Education Statistics Agency Logo

Higher Education Statistics Agency

YearUp.org Logo

YearUp.org

DFDS Logo

DFDS

Boeing Logo

Boeing

New Hampshire Supreme Court Logo

New Hampshire Supreme Court

Nottingham County Council Logo

Nottingham County Council

Department of Work and Pensions (UK) Logo

Department of Work and Pensions (UK)

Ghana Police Service Logo

Ghana Police Service

Royal Air Force Logo

Royal Air Force

Washington Department of Enterprise Services Logo

Washington Department of Enterprise Services

DFDS Logo

DFDS

Genus Breeding Ltd Logo

Genus Breeding Ltd

Healthgrades Logo

Healthgrades

Big Data for Humans Logo

Big Data for Humans

Workday Logo

Workday

NIT A/S