title: perform maven release of child project using git repository and jenkins
body: <h2>Setup</h2>
  <p>I have a project with a child project and want to do a maven release of the child (Project B):</p>
  <pre><code>Project-A/
    pom.xml
    Project-B/
      pom.xml
      src/
  </code></pre>
  <p>The folder of Project-A is at the same time my git repository, which I clone from our central git server.</p>
  <p>For our release we use the jenkins as build server with the Jenkins Maven Release Plug-in to start the release build.</p>
  <p>So after the jenkins Job (called JobB) is started it will checkout the Project-A folder into the following place: <code>/Users/titan/.jenkins/jobs/JobB/workspace</code>.</p>
  <p>Due to the way how git is working I can only clone the top level of my structure. So this means I need to set the pom I want to build in jenkins to Project-B/pom.xml which then will change the working directory maven uses for doing its work.</p>
  <p>This creates a lot of issues with git as the maven release plugin tries to commit to the wrong directory (it assumes that Project-A/Project-B/ is a valid git repository). I could solve all such issues (by deactivating the pushes to the remote repo when doing the release and specifying the correct scm url when doing the release.)</p>
  <p>This is the value of the <code>Release goals and options</code> field in the jenkins JobB configuration:</p>
  <pre><code>-X -DpreparationGoals=&quot;clean install&quot; 
  -DpushChanges=false 
  -DconnectionUrl=scm:git:file:///Users/titan/.jenkins/jobs/JobB/workspace 
  release:prepare release:perform
  </code></pre>
  <p>The file url for the connectionUrl is needed because I do not push the changes to the git remote server and the clone which is done at the beginning of maven:perform would not find the tag from which it needs to checkout.</p>
  <h2>Issue</h2>
  <p>And after all this here is my issue which I'm not able to solve:</p>
  <p>The maven:prepare step runs through and does all its work (changing version numbers in pom, creating release tag).
  Then the <code>maven:perform</code> step starts, clones the content from the git repository, checkouts tag into the target folder, and then invokes the deploy command.</p>
  <p>But here is the issue the invoked deploy command is invoked on the top level so it is deploying Project-A instead of the Project-B. The job itself is running through without any errors it is just building and deploying the wrong thing.</p>
  <p>Here is the command maven generates to execute the deploy:</p>
  <pre><code>[INFO] Executing goals 'deploy'...
  [DEBUG] Using ${maven.home} of: '/usr/share/java/maven-3.0.3'.
  [DEBUG] Executing: /bin/sh -c cd /Users/titan/.jenkins/jobs/jobB/workspace/Project-B/target/checkout &amp;&amp; /usr/share/java/maven-3.0.3/bin/mvn -B -X -D maven.repo.local=/Users/titan/.m2/repository -s /Users/titan/.m2/settings.xml -D performRelease=true deploy
  </code></pre>
  <p>So it is invoking the pom file inside the checkout directory instead inside checkout/Project-B. Interestingly the maven:prepare step does execute on the correct pom.</p>
  <h2>What I tried so far</h2>
  <ul>
  <li><p>Not using jenkins, and invoking the mvm command directly from the shell. This gives me the same outcome. So I assume that jenkins is not the issue.</p>
  </li>
  <li><p>Changing the path for the pom with the <code>-Darguments=&quot;-f sword-packaging-wbf/pom.xml&quot;</code> and with  <code>-Darguments=&quot;-DpomFileName=sword-packaging-wbf/pom.xml&quot;</code></p>
  <p>Both methods do not change anything in the outcome. And looking at the output I see that the <code>-f &lt;path&gt;</code> is ignored in the generated commands where as the <code>-DpomFileName</code> is visible but does not change anything in the outcome.</p>
  </li>
  </ul>