Stage Options provide a way to customise how stages behave within your build pipeline.
Stage options can be accessed by double clicking on a stage arrow from the 'Stages' workflow section. A dialog showing options for the respective stage will be displayed:
The name of the stage
Should the stage be considered when running a build.
Conditions which result in this stage being skipped.
Specify the logical operator that should be applied to the automatic promotion conditions above.
Determines if this stage should be automatically promoted once it has completed executing, or if it should await manual promotion.
Once a stage has completed, the options on this tab determine whether the build automatically continues onto the next stage. If this option is not ticked the 'Auto-promote conditions' come into effect to determine if the build should continue. Please note that the Auto-promote Conditions are joined together with a logical AND. As a result, if any of the lines evaluate to false, the stage status will be set to 'Stage Pending Promotion'.
Determines how long a the build should wait for promotion to the next stage. If this is ticked then the build will be marked as completed once the Timeout Duration is reached. This will allow the build to be cleaned up, but will prevent the build from being promoted.
Length of time (in hours) this stage should await manual promotion.
Conditions which control automatic promotion.
Specify the logical operator that should be applied to the automatic promotion conditions above.
Clicking on the Promote button will trigger the next stage.
Workspace rules allow you to control which files in the workspace are synced or not synced between the server and the agent. Workspace rules are not used to move files from external locations into the workspace. For getting files into your workspace, use the Copy Action or Repository Rules. Rules are split into include rules and exclude rules:
Include rules allow you to specify which files should be copied between the agent and server. These rules use the following syntax: <server_pattern> <operator> <agent_pattern>
Every rule must follow this syntax with the <server_pattern> to the left of the operator and the <agent_pattern> to the right, regardless of whether you are copying from either the agent or the server.
The operator specifies the direction of the rule and the action to take when moving the file. The table below lists the operators and their behaviour:
Operator | Direction | Behaviour |
---|---|---|
> | Server to Agent | Match files on the server using the server_pattern and copy them to the destination specified by the agent_pattern. Preserves paths. |
-> | Server to Agent | Match files on the server using the server_pattern and copy them to the destination specified by the agent_pattern. Doesn't preserve paths. |
>> | Server to Agent | Match files on the server using the server_pattern and copy them to the destination specified by the agent_pattern. Empties the destination directory before copying the files. |
< | Agent to Server | Match files on the agent using the agent_pattern and copy them to the destination specified by the server_pattern. Preserves paths. |
<- | Agent to Server | Match files on the agent using the agent_pattern and copy them to the destination specified by the server_pattern. Doesn't preserve paths. |
<< | Agent to Server | Match files on the agent using the agent_pattern and copy them to the destination specified by the server_pattern. Empties the destination directory before copying the files. |
The server pattern is always to the left of the operator and the agent pattern is always to the right. When using a Server to Agent operator, the server pattern is the source and the agent pattern is the destination. When using an Agent to Server pattern, the server pattern is the destination and the agent pattern is the source.
The destination is not treated as a pattern and should not contain wildcards - it is purely a directory in which the matched files from the source pattern are copied. The source pattern is used to find files in the source location, therefore this pattern must always contain a wildcard. The wild cards used are:
Wildcard | Behaviour |
---|---|
** | Matches anything in any directory |
* | Matches any files in the directory |
? | Matches a single character in a filename/directory |
Scenarios and examples of workspace include rules can be found on the Workspace Rules page.
More information about pattern wildcards can be found on the Ant Pattern Usage page.
An exclude rule is defined by putting a dash ( - ) at the start of the rule. An exclude rule only needs to specify an operator (for direction) and a source pattern. The operator type doesn't matter, as long as the direction of it correct. The destination pattern is irrelevant because the exclude source pattern is applied to all files captured by all include patterns.
Scenarios and examples of workspace exclude rules can be found on the Workspace Rules page.
Write the file name of each file copied to the Build Log.
A repository rule is used to get files out of the repositories attached to the Configuration and into the agent's workspace. Repository rules look and function similar to workspace rules but have a few extra constraints.
In addition to explicitly specifying a repository using query syntax, e.g. $Source.MyRepo$, you can also specify all repositories attached a Configuration by using the syntax $Source$. Take note of where the repositories will be placed when using this syntax though, if your rule is $Source$ > Repos, then your repository will be placed in Repos<repository_name>. As you can see, the destination directory you specify in the rule is created, then another directory with the name of your repository is created and the repositories' files are placed into that directory.
You can also take advantage of wildcards when specifying a repository rule. For example, your rule can look something like this: $Source.MyRepo$\WebProject\** > MyRepoWeb. Here, we've specified the repository MyRepo but in addition also specified a directory within the repository. This rule will only copy the contents of that directory rather than the entire repository into destination directory MyRepoWeb.
Important: When creating your workflow and adding actions, you may want to use the $Source.MyRepo$ syntax to reference something in your repository. That syntax will only work in your action if you have specified a simple repository rule, e.g. $Source$ > Source or**$Source.MyRepo$ > MyRepo**. It will not work when you use a pattern to specify parts of a repository, e.g. $Source.MyRepo$\WebProject\** > MyRepoWeb. If you want to use files in MyRepoWeb then reference it as if you were referencing anything else in the workspace, e.g.$Workspace$/MyRepoWeb/file.xml.
Scenarios and examples of repository rules can be found on the Repository Rules page.
More information about pattern wildcards can be found on the Ant Pattern Usage page.
When a build starts and the workspace is initially created on the server, the contents of that build's workspace contain no trace of any repositories. Instead, the server will process the repository rules and determine which repositories need to be synced to the agent. The agent will then take note of those repositories and update its repository cache. The agent then runs the repository rules against the repository in its repository cache. This eliminates the need for the server to deal with any copying of repositories. It also has the advantage of making subsequent builds a lot quicker. Instead of having to copy the repository from the server to the agent for each build, the agent simply does a local copy from its repository cache into the workspace directory.
Write the file name of each file copied to the Build Log.
Artifacts are a way to register important files with Continua CI. When a file is registered as an artifact, it will be listed on the Artifacts page with details of the file and the ability to download and possibly view that artifact, all through the Continua CI UI. All viewable artifacts can be viewed in their raw format which leaves the rendering of that artifact up to the browser you're using. Alternatively, you can specify a view type for that artifact which will use Continua's custom renderer to display the file.
Artifact rules are how you specify which files should be marked as artifacts. An artifact rule is purely a file or a pattern with a type tagged on the end of it. There's no concept of a source, destination or even a direction. It uses the same wildcards as workspace/repository rules but that's about all they have in common. Artifact rules are just a way of registering files as artifacts.
When registering an artifact, each file can have a type explicitly associated with it. These types tell Continua CI how certain files should be rendered on the artifacts page. The list of view types are: variable, image, and nunit. You need not worry about the variable type as that is for viewing the variable output files that are generated every build and automatically registered as artifacts. If you're registering an image as an artifact, use the image type when specifying an artifact rule. For nunit xml output files, specify nunit as the view type. If none of your artifacts match a view type then you don't need to specify one, just specify the file/pattern.
When specifying a view type, put it at the start of the rule followed by a vertical bar ("|") character then the pattern. Eg. nunit | **test*.xml. This will match all files in the workspace that contain the word "test" and have a xml file extension.
Important: Artifact registration only happens on the server side, therefore, the patterns are run against the workspace on the server. When writing your workspace rules, make sure you sync back the files you want registered as artifacts. For subsequent stages, make sure you don't delete artifacts registered in previous stages from the workspace on the server. One possible way of doing this without knowing is to create a rule that syncs files from the agent to the server and specifying that the destination directory (which would be on the server) be empty. In this case you would empty the directory with the artifact in it.
Scenarios and examples of registering can be found on the Artifact Rules page.
Write the file name of each file copied to the Build Log.
Agent requirements are a set of conditions that must be met before the stage will execute on a particular agent. In addition to using variables as condition values, you can also use the $Agent$ descriptor which gives you access to agent details like hostname, port and all property collector values. Note that these conditions give you fine grain control over the configuration and stages. It's possible to make the entire Configuration execute on a single agent, but having agent requirements allows you to force one stage to run on a specific agent while letting Continua decide which is the best agent to run the other stages on. If the rules are left blank then Continua CI will determine which agent should run that stage.
Here are some scenarios where you could make use of agent requirements.
The “Agent Priority” field determines the sequence in which agents with equal capacity are chosen to execute a particular stage. This field should contain a property that is unique to each agent.
By default, new stages will include the expression $Agent.Priority.Value$, which refers to an agent property collector. This collector defines a numerical "Priority.Value" property for each agent, with a default value of 0. To assign priority to an agent for this stage, modify the ‘Priority.Value’ property for that agent. If you need to set a different priority for a stage or group of stages, consider adding a new agent property collector.
The priority expression can evaluate to either a number or a string:
You can reverse this order by selecting the “Select agent in reverse order of priority” option.
Please note that agent selection is primarily based on capacity, which is calculated by subtracting the number of running stages from the Concurrent Stage Limit. For instance, if two agents have a concurrent stage limit of 2 and one stage is running on Agent A while no stages are running on Agent B, Agent B will be chosen to run the stage regardless of the agent priority value. However, you can override this by selecting the “Priority overrides capacity” option. With this setting enabled, an available agent with a higher priority value will be selected first, regardless of how many stages are currently running on it.