|
A build configuration can be made dependent on the artifacts or sources of builds of some other build configurations. For snapshot dependencies, TeamCity will run all dependent builds on the sources taken at the moment the build they depend on starts. For artifact dependencies, before the build is started to run, all artifacts the builds depends on will be downloaded and placed in their configured target locations and then can be used by the build. Configuring Artifact DependenciesThere are two ways to define artifact dependencies:
Using the Web UITo add dependencies to a build configuration:
Using Ant Build ScriptThis solution is more complicated but allows greater flexibility. For example, configuring dependencies in this way will allow you to start a personal build and verify that your build is still compatible with dependencies. To configure dependencies via Ant build script:
2. Add Ivy to the classpath of your build. <ivysettings> <property name='ivy.checksums' value=''/> <caches defaultCache="${teamcity.build.tempDir}/.ivy/cache"/> <statuses> <status name='integration' integration='true'/> </statuses> <resolvers> <url name='teamcity-rep' alwaysCheckExactRevision='yes' checkmodified='true'> <ivy pattern='http://YOUR_TEAMCITY_HOST_NAME/httpAuth/repository/download/[module]/[revision]/teamcity-ivy.xml' /> <artifact pattern='http://YOUR_TEAMCITY_HOST_NAME/httpAuth/repository/download/[module]/[revision]/[artifact](.[ext])' /> </url> </resolvers> <modules> <module organisation='.*' name='.*' matcher='regexp' resolver='teamcity-rep' /> </modules> </ivysettings> 4. Replace YOUR_TEAMCITY_HOST_NAME with the host name of your TeamCity server. <ivy-module version="1.3"> <info organisation="YOUR_ORGANIZATION" module="YOUR_MODULE"/> <dependencies> <dependency org="org" name="BUILD_CONFIGURATION_ID" rev="BUILD_REVISION"> <include name="ARTIFACT_FILE_NAME_WITHOUT_EXTENSION" ext="ARTIFACT_FILE_NAME_EXTENSION" matcher="exactOrRegexp"/> </dependency> </dependencies> </ivy-module> Where:
7. Modify your build.xml file and add tasks for downloading artifacts, for example (applicable for Ant 1.6 and later): <target name="fetchArtifacts" description="Retrieves artifacts for TeamCity" xmlns:ivy="antlib:fr.jayasoft.ivy.ant"> <taskdef uri="antlib:fr.jayasoft.ivy.ant" resource="fr/jayasoft/ivy/ant/antlib.xml"> <classpath> <pathelement location="${basedir}/lib/ivy-2.0.jar"/> <pathelement location="${basedir}/lib/commons-httpclient-3.0.1.jar"/> <pathelement location="${basedir}/lib/commons-logging.jar"/> <pathelement location="${basedir}/lib/commons-codec-1.3.jar"/> </classpath> </taskdef> <ivy:configure file="${basedir}/ivyconf.xml" /> <ivy:retrieve pattern="${basedir}/[artifact].[ext]"/> </target>
Artifacts repository is protected by a basic authentication. To access the artifacts, you need to provide credentials to the <ivy:configure/> task. For example: <ivy:configure file="${basedir}/ivyconf.xml" host="TEAMCITY_HOST" realm="TeamCity" username="USER_ID" passwd="PASSWORD"/> where TEAMCITY_HOST is hostname or IP address of your TeamCity server (without port and servlet context). The properties teamcity.auth.userId/teamcity.auth.password store automatically generated build-unique values whose only intended use is artifacts downloading within the build script. The values are valid only during the time the build is running. Using the properties is preferable to using reall user credentials since it allows the server to track artifacts downloaded by your build. If the artifacts were downloaded by the build configuration artifact dependencies or using the supplied properties, the specific artifacts used by the build will be displayed on the build results page. In addition, the builds which were used to get the artifacts from will not be cleaned up by the clean-up process much like the pinned builds. See Also:
|