Skip to content
Kannan Ekanath edited this page Dec 17, 2019 · 8 revisions

EnvInject Teamcity Plugin

Purpose

An EnvInject plugin for Teamcity. The inspiration is from https://wiki.jenkins-ci.org/display/JENKINS/EnvInject+Plugin. For teams/companies that have their environment variables in some properties files which should be initialized on Builds. This plugin provides a runner for this purpose

Download/Usage

The latest version is 1.0 which is available from https://github.com/calmstorm/teamcity-envinject-plugin/releases/tag/1.0

Features

  • Ability to load/configure parameters on a Teamcity build from either a properties file (that is visible to the agent) or directly using a text area provided.
  • Properties are specified as key value pairs
  • Ability to configure system/environment/configuration parameters in Teamcity
  • Ability to compose property values from existing system/environment/configuration parameters.
  • From Version 1.1 empty lines or lines beginning with "#" (for comments) will be ignored.

When this plugin is installed there will be a new "Runner" i.e, when you edit your build type/job you will see a runner named "Inject Environment Variables". You can use this to provide properties from a file or directly inlined into the text area.

Example

If you place the following in a properties file and configure the path in the build step

foo={system.build.number}bar
system.bug=xyz
env.abc={env.JDK_17}XXXX123

In the above cases

  • A configuration parameter called foo will be set with a value of 13bar where "13" is the build.number system property
  • A system parameter called bug will be set to a value of "xyz"
  • An environment variable called abc will be set to C:\Java\bin\javaXXX123 with the JDK_!7 env var expanded

Development Guide

  1. The project was built using Java 1.7, Maven 3.0.3 for Teamcity 9.0.4 (build 32407). In general it should work for any JDK 1.7, Maven 3.x.
  2. To build this project you can simply sync the code and run "mvn install package" which will produce the plugin zip.

Performing a new release

  1. Create a zip file by running mvn -Dtcpluginversion=7.0 install package. The 7.0 is the release version and this will create a zip file under target directory of the root.
  2. Go to the releases page in Github and simply create a new release and add the zip as an artifact.
  3. Developer needs to manually ensure that all sources are checked in and pushed at that point in time.