Child pages
  • Gaya 8.0 EAP (build 27147) Release Notes

Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

Meta-runner is a Build Runner which acts acting as a combination of one or more build runners and has user interface targeted to user domain. For example, it is possible to configure build step based on Ant to upload some file to ftp. You can move this build step in some template, replace host, user and password with parameter references (%host%, %user%), and then you can define one or more build steps in some build configuration to solve some specific task. However, if you need to reuse this set of steps, there is no easy way to do it. Yes, you can generalize these steps, i.e. replace some hard coded values with parameter references and create a template with this set of steps. Then you can reuse this template in several build configurations. This approach gives some flexibility, but due to template nature this approach is still not very user friendly. Isn't it better to have a dedicated build runner for this task with specific user interface? This is what Meta-runner aboutflexible enough. It would be great to be able to see this set of build steps as a dedicated runner with own web interface, and this is where Meta-runner comes into play.

Let's see how it works. Sometimes during the build process we need to replace some pattern in several files before making a distribution package. For example, if you build a TeamCity plugin you need to provide build number in teamcity-plugin.xml file bundled with the plugin. Let's try to create a build runner based on Ant ReplaceRegExp task with So this build runner should have the following parameters in user interface:

  • pattern to search in files
  • replacement string
  • patterns for files where replacement must be performed

First of all I need to create a build configuration with Ant build step and with replace target that will . I will use Ant built-in replaceregexp task to do all the work. I'll use the following custom build xml:

Code Block
<project default="replace" name="ReplaceRegExp">

<target name="replace">

<touch>
  <fileset dir="%basedir%">
    <include name="%files_to_include%"/>
    <exclude name="%files_to_exclude%"/>
  </fileset>
</touch>

<replaceregexp flags="g">
  <regexp pattern="%pattern_to_replace%"/>
  <substitution expression="%substitution%"/>
  <fileset dir="%basedir%">
    <include name="%files_to_include%"/>
    <exclude name="%files_to_exclude%"/>
  </fileset>
</replaceregexp>

</target>

</project>

...

  • %pattern_to_replace% - regexp pattern to search in files
  • %substitution% - substitution string
  • %basedir% - base directory where to perform replacement
  • %files_to_include% and %files_to_exclude% - Ant include / exclude patterns for files

In a the build configuration where this Ant build step is defined I will see these parameter references as undefined parameters on Build parameters tab, because no one provided values for them.
screenshot

Now we need to associate labels and descriptions for with these parameters, this can be done through regular parameter editing dialog.
screenshot

...

Definitions of meta runners are stored under TeamCity Data Directory/config/_meta_runners/ directory. Here is complete definition for Replace in Files build runner (I added validation regexp for parameter values and reordered parameters):

Code Block
<?xml version="1.0" encoding="UTF-8"?>
<meta-runner name="Replace by Pattern">
  <description>Replace in files by pattern</description>
  <settings>
    <parameters>
      <param name="basedir" value="" spec="text display='normal' regexp='.+' label='Directory where to perform replacement:'" />
      <param name="pattern_to_replace" value="" spec="text display='normal' regexp='.+' label='Pattern to replace:'" />
      <param name="substitution" value="" spec="text display='normal' regexp='.+' label='Substitution:'" />
      <param name="files_to_include" value="" spec="text display='normal' regexp='.+' label='Files to include (Ant patterns):'" />
      <param name="files_to_exclude" value="" spec="text display='normal' label='Files to exclude (Ant patterns):'" />
    </parameters>
    <build-runners>
      <runner id="RUNNER_16" name="" type="Ant">
        <parameters>
          <param name="build-file"><![CDATA[<project default="replace" name="ReplaceRegExp">

<target name="replace">

<touch>
  <fileset dir="%basedir%">
    <include name="%files_to_include%"/>
    <exclude name="%files_to_exclude%"/>
  </fileset>
</touch>

<replaceregexp flags="g">
  <regexp pattern="%pattern_to_replace%"/>
  <substitution expression="%substitution%"/>
  <fileset dir="%basedir%">
    <include name="%files_to_include%"/>
    <exclude name="%files_to_exclude%"/>
  </fileset>
</replaceregexp>

</target>

</project>]]></param>
          <param name="build-file-path" value="build.xml" />
          <param name="teamcity.coverage.emma.include.source" value="true" />
          <param name="teamcity.coverage.emma.instr.parameters" value="-ix -*Test*" />
          <param name="teamcity.coverage.idea.includePatterns" value="*" />
          <param name="teamcity.step.mode" value="default" />
          <param name="use-custom-build-file" value="true" />
        </parameters>
      </runner>
    </build-runners>
  </settings>
</meta-runner>

In order to install this build runner in your TeamCity installation you need to save this definition to a file under TeamCity Data Directory/config/_meta_runners/ directory. File should have name like:
<runner id>.xml, where <runner id> is unique identifier of this build runner. Server will detect this definition and will load it on the fly.

Current limitations:

  • when meta-runner is extracted from web interface there is no way to specify which steps you want to extract which you don't want
  • extract meta-runner interface does not allow to reorder parameters, you have to open extracted file and change order manually
  • meta runner definitions are global for the server, there is no way to store them in some project only

Queued build page

Dependencies progress has been added on queued build page, you can now see estimates for all dependencies in one place.

...