Remote run not compatible with Maven deploy builds

Hi,

we ran into an issue with some of our builds that do an mvn deploy. the problem is that if you do a remote run with a build configuration that does an mvn deploy, the jar will be deployed, since deploy happens as part of the build. however, the point of the remote run is to not do things like commit or mvn deploy.


is there any way to detect that a build is being run under the guise of remote run? does TC pass a variable to the build so that i can detect, in Maven, when a remote run is happening?

Thanks,
Trevor

5 comments

System property build.is.personal and environment variable BUILD_IS_PERSONAL are provided to a build if it is personal. For regular builds such properties are not set.

--
Pavel Sher

0

i wanted to reply with the solution for other maven users, and possibly for inclusion in the TC :

include this in your pom and you are all set:

${build.is.personal} ]]>

Thats it!

:)

0

that first line should have ended "for inclusion in the TC manual"

0

Trevor, I don't see your solution to this problem.  I used 2 profiles, teamcity and remote-run.  Make sure to leave the goals field blank for the Maven2 runnter.  I placed these profiles in our company POM.

   <profiles>
      <profile>
         <id>teamcity</id>
         <activation>
            <property>
               <name>teamcity.buildType.id</name>
            </property>
         </activation>
         <build>
            <defaultGoal>deploy</defaultGoal>
         </build>
      </profile>
      <!--
         The remote run profile must be listed last to deactivate
         previously listed profiles.
      -->
      <profile>
         <id>remote-run</id>
         <activation>
            <property>
               <name>build.is.personal</name>
               <value>true</value>
            </property>
         </activation>
         <build>
            <defaultGoal>package</defaultGoal>
         </build>
      </profile>
   </profiles>

This works great with single module projects.  However, with multi-module projects this does not work completely.  The dependencies are using the artifacts in the local repository rather than what was produced in the target directory.  Using the "install" goal is an option.  However, the remote-run generated artifacts could be used in other regular deploy builds.

I think the ideal solution is to have 2 local repositories available, one for regular builds and one for remote run builds.  The only way I know how to change the location of the local repository is by using a different settings.xml file.  Is it possible to specify the -s parameter to Maven conditionally based on whether the system property build.is.personal and/or the environment variable  BUILD_IS_PERSONAL is available?  Both personal and history builds should follow this behavior.

0

This request looks like a potential solution
http://youtrack.jetbrains.net/issue/TW-11823

Currently you can try a hack like providing the settings.xml path as say "~/.m2/settings_%system.build.is.personal%.xml".
When build is not personal the path will be exacly "~/.m2/settings_%system.build.is.personal%.xml".
Otherwise "~/.m2/settings_true.xml".

Ugly but may work, if you manage to create a file with % in its name.

0

Please sign in to leave a comment.