You are viewing an old version of this page. View the current version.

Compare with Current View Page History

« Previous Version 13 Next »




What are they?

Expressions are a mechanism for the auto-completion of values which may not be known until build execution time (for example the current build number).  They can also be used to autocomplete variables.

Where can I use them?

Expressions can be utilised in several dialog fields throughout Continua (they are especially useful within stage actions, and build event handlers).  

The expansion icon (below) denotes fields that have expression capabilities. Note is some areas, such as configuration variables, you can click on this icon to disable expressions

 

Expression Expansion

To initiate an expansion, simply type the dollar symbol '$' and the expression auto complete will present (note: not all objects are available in all fields).



Available Expression Objects

Different expression objects are available for each expandable field depending on which stage in the build process the expression will be evaluated at, and whether it will be evaluated on the server or an agent.

Agent-side expression objects

Stage Actions, Workspace Rules, and Expression Variables

Expandable fields on Action dialogs, and the Workspace Rules tab of the Stage Options dialog in the Stages step of the configuration wizard, and the Edit Variable dialog in various areas, support the following root expression objects.

  • Workspace
  • Build
  • Configuration
  • Agent
  • Stage
  • Project
  • Source
  • Server
  • Utils

Server-side expression objects

Triggers and Repositories

Most expandable fields on the Edit Repository dialog and the Edit Trigger dialog, except for the Variables and Artifacts tabs for Build Completed triggers, support the following root expression objects.

  • Server
  • Utils

Variables and Artifacts for Build Completed Triggers

Expandable fields on the Variables and Artifacts tabs for Build Completed triggers, support the following root expression objects.

Version Format

The Version Format field on the Stages step of the configuration wizard, supports the following root expression objects. 

  • Build
  • Source
  • Server
  • Utils

Variables  

Expandable fields on the Edit Variable dialog (for variable types other than Expression) , support the following root expression objects.

  • Configuration
  • Project
  • Server
  • Utils

Configuration Conditions, Build Event Handlers and Agent Conditions

Expandable fields when editing Configuration Conditions in the Conditions step of the configuration wizard, in the Edit Build Event Handlers dialog, and in Agent Conditions on the Agent page under Administration, support the following root expression objects.

  • Workspace
  • Build
  • Configuration
  • Project
  • Source
  • Server
  • Utils

Agent Requirements

Expandable fields on the Agent Requirements tab of the Stage Options dialog in the Stages step of the configuration wizard, support the following root expression objects.

  • Workspace
  • Build
  • Agent
  • Source
  • Server
  • Utils

Stage Gate, Promote Conditions and Skip Conditions

Expandable fields on the Edit Stage Gate dialog, Promote Conditions and Skip Conditions tabs of the Stage Options dialog in the Stages step of the configuration wizard, support the following root expression objects.

  • Stage
  • Build
  • Server
  • Utils

Reports

Expandable fields on the Edit Report dialog, support the following root expression objects.

  • Workspace
  • Build
  • Configuration
  • Project
  • Server
  • Utils



$Workspace

NameDescriptionTypeUsage Examples
N/ARepresents the full path of a build's workspace folder.String$Workspace$\testfolder"D:\ContinuaAgent\Ws\19\"

$Build

NameDescriptionTypeUsage Example
BuildNumberA zero-based auto-incremented integer allocated to this build (the first build will be build 0, the second build 1, etc)Integer$Build.BuildNumber$100
Duration



FirstSharedResourceLabel



HasErroredStages



HasFailedStages



HasNewChangesDoes this build contain changesets which have not been associated with a previous build?Boolean$Build.HasNewChanges$true
HasSuccessfulStages



HasWarnings



IdA unique Integer allocated automatically to this buildString$Build.Id$"10"
IsFeatureBranchBuildUtilised via build triggers. This expression is set to true when a build is triggered on a non-default branchBoolean$Build.IsFeatureBranchBuild$true
LastSharedResourceLabel



LinkUrlBuild details URLString$Build.LinkUrl$"http:\\SERVERNAME\New_Project_1\ci\builds\view\123" 
MetricsA reference object to the metrics associated with this build (as defined below).Metrics$Build.Metrics$N/A
SharedResourceLabels



SharedResources



StartComment



StartedByThe username of the user who initiated the buildString$Build.StartedBy$"peter.toms@finalbuilder.com"
VersionA reference object for the build version (as defined below).Version$Build.Version$N/A

$Configuration

NameDescriptionTypeUsage Examples
Description



InitialisingBuildCountThe number of currently initialising buildsInteger$Configuration.InitialisingBuilds$1
InitialisingOrQueuedBuildCount



LastBuild



LastFinishedBuild



NameName of the configuration (as defined within the Configuration details page)String$Configuration.Name$"New Configuration 1"
PendingPromotionBuildCount



QueuedBuildCountThe number of currently queued buildsInteger$Configuration.QueuedBuilds$1
RunningBuildCountThe number of currently running buildsInteger$Configuration.RunningBuilds$1

$Agent

NameDescriptionTypeUsage Example
PortThe port number used for agent communicationString$Agent.Port$"9000"
HostnameThe agents host nameString$Agent.Hostname$"AGENTMACHINE"
NowThe current date and time given as local to the agentDateTime$Agent.Now$"2014 4:51:44 PM"
NowUTCThe current date and time given as UTCDateTime$Agent.NowUtc$"2014 6:52:25 AM"
InstallPathThe installation path of the agentString$Agent.InstallPath$"C:\Program Files\VSoft Technologies\ContinuaCIAgent\"
GetUserEnvironmentVariableGets the specified Windows user environment variable (relative to the agent machine's service user, and relative to the agent machine)String$Agent.GetUserEnvironmentVariable("TEMP")$"%USERPROFILE%\AppData\Local\Temp"
GetMachineEnvironmentVariableGets the specified Windows machine environment variable (relative to the agent machine) String$Agent.GetMachineEnvironmentVariable("NUMBER_OF_PROCESSORS")$"8"
N/AWithin the Agent object is a list of the current agent property collectorsProperty Collector$Agent.NuGet.Default.Path$"C:\Program Files\NuGet\NuGet.exe"

$Project

NameDescriptionTypeUsage Example
NameThe name of the project the current configuration is a part of (as provided on the Project details page)String$Project.Name$"New Project 1"
DescriptionThe description of the project the current configuration is a part of (as provided on the Project details page)String$Project.Description$"This is a description for new project 1"
SlugA shortened version of the project name which is safe to use within URLs and other whitespace sensitive identifiers.String$Project.Slug$"New_Project_1"

$Source

NameDescriptionTypeUsage Example
N/AA list of repositories associated with the current configurationRepository$Source.Reponame$"Mercurial_Test_1"

$Server

NameDescriptionTypeUsage Example
HostnameThe Continua server hostnameString$Server.Hostname$"SERVERMACHINE"
InstallPathThe Continua server install pathString$Server.InstallPath$"C:\Program Files\VSoft Technologies\ContinuaCI\"
NowThe current date and time given as local to the serverDateTime$Server.Now$"01/01/2014 5:03:18 PM"
NowUtcThe date and time given as UTCDateTime$Server.NowUtc$"01/01/2014 7:04:01 AM"
UrlThe web service URLString$Server.Url$"http:\\SERVERNAME:8080"

$Utils

NameDescriptionTypeUsage Example
GetBoolean



GetDate



GetDateTime



GetNumber



GetString



NewGuidCreate a new randomly generated GUIDGuid$Utils.NewGuid$"da47b2d6-3580-48ed-b27a-f152da2345e6"
RandomNumber

Generate a new random integer value

If one parameter is provided it designates a random number in the range of greater than or equal to zero and the number provided will be generated

If two parameters are provided they designate the range for the generated number.

If no parameters are provided a 32-bit integer greater than or equal to zero and less than Int32 max value (2,147,483,647) will be generated.

Integer

$Utils.RandomNumber("1", "10")$

$Utils.RandomNumber("10")$

$Utils.RandomNumber$

5

2

1906529119 

Repository (used by $Source )

NameDescriptionTypeUsage Example
BranchThe full name of the branch associated with the build for the given repositoryString$Source.RepoName.Branch$"/branches/a_test_branch"
BranchNameThe branch name of the branch associated with the build for the given repositoryString$Source.RepoName.BranchName$"a_test_branch"
BuiltChangesetA reference object to the changeset information related to the changeset which is being built for the given repository (as defined below)Changeset$Source.RepoName.BuildChangeset.TagNames$"tag1,tag2,tag3"
CommitsSinceLatestTagThe number of commits listed in the changeset history for the current branch of the given repository since the latest tagInteger$Source.RepoName.CommitsSinceLatestTag$3
LatestChangesetA reference object to the changeset information related to the most recent changeset for the given repository (as defined below).Changeset$Source.RepoName.LatestChangeset.Comment$"a comment from the last commit"
LatestTagNameThe latest tag name (if one exists) listed in the changeset history for the current branch of the given repositoryString$Source.RepoName.LatestTagName$"tag3"
LatestTriggeringChangesetA reference object to the changeset information related to the latest changeset for the given repository which triggerred this build (as defined below)Changeset$Source.RepoName.BuildChangeset.BranchName$"master"
PathThe disk location of the source associated with the build for the given repositoryString$Source.RepoName.Path$"C:\ContinuaAgent\Ws\44\Source\"
TagThe tag name (if one exists) associated with the build for the given repositoryString$Source.RepoName.Tag$"v3-release"
TypeThe repository product being usedString$Source.RepoName.Type$"Mercurial"
UrlThe URL of the repository in question (as defined within the repository preferences)String$Source.RepoName.Url$"https://github.com/VSoftTechnologies/Delphi-Mocks.git"

Changeset (used by $Source)

NameDescriptionTypeUsage Example
IdA unique identifier given to this changesetString$Source.RepoName.BuiltChangeset.Id$"a4ae66dffe5342e47c3aaf987bced4e9a320559e"
CommentThis comment associated with this changesetString$Source.RepoName.BuiltChangeset.Comment$"This is a test commit"
RepositoryUsernameThe username of the repository user who committed this changesetString$Source.RepoName.BuiltChangeset.RepositoryUsername$"Peter Toms"
BranchThe full branch path of the latest changeset associated with this repositoryString$Source.RepoName.BuiltChangeset.Branch$"/branches/a_test_branch"
BranchNameThe branch name of the latest changeset associated with this repositoryString$Source.RepoName.BuiltChangeset.BranchName$"a_test_branch"
CreatedThe date and time when the changeset was committed or created within the source repositoryDateTime$Source.RepoName.BuiltChangeset.Created$"11/09/2014 1:48:36 AM"
FileCountThe number of file changes associated with this commitInteger$Source.RepoName.BuiltChangeset.FileCount$1
CommitterUserNameThe username of the Continua User who committed this changeset (if one exists based on user repository mappings )String$Source.RepoName.BuiltChangeset.CommitterUserName$"peter.toms@finalbuilder.com"
CommitterFullNameThe full name of the Continua user who committed this changeset (if one exists based on user repository mappings)String$Source.RepoName.BuiltChangeset.CommitterFullName$"Peter Toms"
FirstTagNameThe name of the first (or earliest) tag associated with this changesetString$Source.RepoName.BuiltChangeset.FirstTagName$"tag1"
LatestTagNameThe name of the latest tag associated with this changesetString$Source.RepoName.BuiltChangeset.LatestTagName$"tag3"
TagNamesA comma-delimited list of tags associated with this changesetString$Source.RepoName.BuiltChangeset.TagNames$"tag1,tag2,tag3"
ChangedTagNameThe name of the tag which was changed by this changesetString$Source.RepoName.LatestTriggeringChangeset.ChangedTagName$"tag3"

Stage (used by $Build)

NameDescriptionTypeUsage Example
NameThe stage name as defined within the workflow editorString$Build.Stage.Name"this is a test stage"
MetricsA reference object to the metrics associated with this build (as defined below).Metrics$Build.Stage.MetricsN/A

Metrics (used by $Build)

NameDescriptionTypeUsage Example
Compiler.WarningThe total number of compiler warnings for the current build (eg MSBuild or Visual Studio build warnings)Integer$Build.Metrics.Compiler.Warning$5
Compiler.ErrorThe total number of compiler errors for the current build (eg MSBuild or Visual Studio build errors)Integer$Build.Metrics.Compiler.Error$5
UnitTestsA reference object for the unit test metric details (as defined below)UnitTests$Build.Metrics.UnitTestsN/A

UnitTests (used by $Build.Metrics)

NameDescriptionTypeUsage Example
FixtureCountThe total number of test fixturesInteger$Build.Metrics.UnitTests.FixtureCount$5
CaseCountThe total number of test casesInteger$Build.Metrics.UnitTests.CaseCount$5
PassedThe number of passed testsInteger$Build.Metrics.UnitTests.Passed$10
FailedThe number of failed testsInteger$Build.Metrics.UnitTests.Failed$5
ErrorThe number of tests in errorInteger$Build.Metrics.UnitTests.Error$1
NotRunThe number of tests not runInteger$Build.Metrics.UnitTests.NotRun$1
InconclusiveThe number of inconclusive testsInteger$Build.Metrics.UnitTests.Inconclusive$1
IgnoredThe number of ignored testsInteger$Build.Metrics.UnitTests.Ignored$1
InvalidThe number of invalid testsInteger$Build.Metrics.UnitTests.Invalid$1
SkippedThe number of skipped testsInteger$Build.Metrics.UnitTests.Skipped$1

Version (used by $Build.Version)

NameDescriptionTypeUsage Example
DefaultA reference object for the default versionDefault$Build.Version.DefaultN/A
DotNetA reference object for the .Net versionDotNet$Build.Version.DotNetN/A

Default (used by $Build.Version.Default)

NameDescriptionTypeUsage Example
MajorThe version major portion of the version numberInteger$Build.Version.Default.Major$"1" (given "1.2.3.4")
MinorThe version minor portion of the version numberInteger$Build.Version.Default.Minor$"2" (given "1.2.3.4")
BuildThe version build portion of the version numberInteger$Build.Version.Default.Build$"3" (given "1.2.3.4")
RevisionThe version revision portion of the version numberInteger$Build.Version.Default.Revision$"4" (given "1.2.3.4")

DotNet (used by $Build.Version.DotNet)

NameDescriptionTypeUsage Example
MajorThe version major portion of the version numberInteger$Build.Version.DotNet.Major$"1" (given "1.2.0.1287")
MinorThe version minor portion of the version numberInteger$Build.Version.DotNet.Minor$"2" (given "1.2.0.1287")
BuildThe version build portion of the version numberInteger$Build.Version.DotNet.Build$"0" (given "1.2.0.1287")
RevisionThe version revision portion of the version numberInteger$Build.Version.DotNet.Revision$"1287" (given "1.2.0.1287")

String Properties and Functions

Name and ParametersDescriptionReturn TypeUsage Example
Append(string value)Returns a new string with the specified string added to the endstring$Configuration.Name.Append(" ").Append($Build.Version$)$"Build Config 1.2.3" (given "Build Config", and "1.2.3")
Contains(string value [, bool ignoreCase])Returns a value indicating whether the specified string occurs within the current text. Use ignoreCase parameter is false by defaultboolean

Insert(int startIndex, string value)Returns a new string in which a specified string is inserted at a specified index position in the current textstring

LengthReturns the number of characters in the textinteger

PadLeft(int totalWidth [, char paddingChar])Returns a new string that right-aligns the characters in the current text by padding them on the left with a specified character, for a specified total lengthstring


PadRight(int totalWidth [, char paddingChar])Returns a new string that left-aligns the characters in the current text by padding them on the right with a specified character, for a specified total lengthstring


Remove(int startIndex [, int count])Returns a new string in which a specified number of characters in the current text beginning at a specified position have been deletedstring


Replace(string oldValue, string newValue)Replaces all occurrences of the first specified string in the current string with the second specified stringstring
$Configuration.Name.Replace("v.", "version" )$"Test Config version 10" (given "Test Config v. 10")
Replace(string pattern, string replacement, ignoreCase)Returns a new string in which all matches of the specified regular expression pattern in the current text are replaced with a specified replacement string


Split(string separators, [bool trimWhitespace,] [bool removeEmptyEntries])Splits a string into substrings separated by any of the characters in separator parameterstring array

SplitWithQuotes(string separators [, string quotetype] [, bool trimQuotes] [, bool trimWhitespace] [, bool removeEmptyEntries])Splits a string into substrings separated by any of the characters in separator parameter. Separators within quotes are ignored. The quoteType parameter can be "single" or "double" and defaults to "double"string array

Substring(int startIndex [, int length])Returns a substring of the current text starting at a specified character position with an optional specified lengthstring

ToBoolean()Parses text to a boolean, allowing boolean operations and functionsboolean

ToLower()Converts a string to lowercasestring
$Source.RepoName.Branch.ToLower$"version 1.5" (given "Version 1.5")
ToNumber()Parses text to a number, allowing numeric operations and functionsnumber

ToUpper()Converts a string to uppercasestring
$Project.Name.ToUpper$"PROJECT X" (given "Project X")
TrimStart([string trimChars])Returns a new string with all leading occurrences of white space or a specified set of characters removedstring


Trim([string trimChars])Returns a new string with all leading and trailing occurrences of white space or a specified set of characters removed
string

$Build.Version.Trim$

$Build.Version.Trim(".,")$

"a b c d" (given " a b c d  ")

"a.b.c.d" (given ",a.b.c.d.")

TrimEnd([string trimChars])"Returns a new string with all trailing occurrences of white space or a specified set of characters removedstring


Number Functions

NameDescriptionParametersReturn TypeUsage Examples
AddAdds the specified number to the current number and returns the result
number

CeilingReturns the smallest integer greater than or equal to the current decimal number
number

DecrementDecrements the current number by one
number

DivideDivides the current number by the specified number and returns the result
number

FloorReturns the largest integer less than or equal to the current decimal number
integer

IncrementIncrements the current number by one
number

IntegerDivideDivides the current integer by the specified integer and returns an integer result
integer

ModulusReturns the remainder after dividing the current number by the specified number
number

MultiplyMultiplies the current number by the specified number and returns the result
number

RoundRounds the current decimal number to the nearest integer
integer

SubtractSubtracts the specified number from the current number and returns the result
number

ToStringParses current number to a string, allowing string operations and functions
string



















Boolean Functions

NameDescriptionParametersReturn TypeUsage Examples
AndReturns logical AND of current boolean value with specified value
boolean

OrReturns logical OR of current boolean value with specified value
boolean

NotNegates current boolean value
boolean

ToStringParses current boolean to a string, allowing string operations and functions
string







DateTime Properties and Functions

NameDescriptionParametersReturn TypeUsage Examples
Day

string array

DayOfWeek




DaysAgo




FormatFormats a date or time value using standard or custom .Net formatting strings
String$Server.Now.Format("hh:mm")$"23:55" (given the date time "31/12/2000 23:55:333")
Hour




HoursAgo




Local




Millisecond




Minute




MinutesAgo




Month




Second




SecondsAgo




ToLongDateString




ToLongTimeString




ToShortDateString




ToShortTimeString




UTC




Year










Date Properties and Functions

NameDescriptionParametersReturn TypeUsage Examples
Day

string array

DayOfWeek




DaysAgo




FormatFormats a date or time value using standard or custom .Net formatting strings
String$Server.Now.Format("hh:mm")$"23:55" (given the date time "31/12/2000 23:55:333")
Month




ToLongDateString




ToShortDateString




Year










DateTime Properties and Functions

NameDescriptionParametersReturn TypeUsage Examples
FormatFormats a date or time value using standard or custom .Net formatting strings
String$Server.Now.Format("hh:mm")$"23:55" (given the date time "31/12/2000 23:55:333")
Hour




HoursAgo




Millisecond




Minute




MinutesAgo




Second




SecondsAgo




ToLongTimeString




ToShortTimeString




Year










TimeSpan Properties and Functions

NameDescriptionParametersReturn TypeUsage Examples
FormatFormats a date or time value using standard or custom .Net formatting strings
String$Server.Now.Format("hh:mm")$"23:55" (given the date time "31/12/2000 23:55:333")
FullAbreviatedText




Hours




LongText




Milliseconds




Minutes




Seconds




ShortAbbreviatedText




ShortText




ShortTextPadding




Text




TotalHours




TotalMilliseconds




TotalMinutes




TotalSeconds















  • No labels