Introduction
This collection only fork and migrate to newer Node.js v16 (because of Node 6 deprecation) without any modifications of the following task packs:
1. Variables Tasks Pack
Build & Release tasks to manipulate variables. This extensions is comprised of eight tasks
Configuration
After you install the extension in your account (see Get extensions for Visual Studio Team Services to learn how to install extensions) you are ready to use the task on your build or release defintions on the account(s) you have installed the extension into.
It may take a while until the tasks are available to be used.
Tasks
When you add a new step to your build or release template, you can chose the task from the Utility category, each task has a different set of purposes and parameters.
Set Variable
This task allows to set/change the value of a variable, it has three parameters (transformations may have additional parameters:
- Variable Name The name of the variable to set
- Variable new value The value to set
- Transformation Applies a transformation to the value
- upper case the result will be all upper cased
- lower case the result will be all lower cased
- replace replace a string with another (a regular expression may be used, use regular expression replace for more advanced replacement scenarios)
- sub set transformation gets a subset of the value
- regular expression match match a part of the new value using a regular expression
- regular expression replace replaces the new value string using a regular expression replacement
The sub set transformation allows you to get a part of a string. It has two extra parameters:
- Index start The index of the string sub set (zero based index)
- Index end The index end of the string sub set. No value means the rest of the string after Index start
Allows you to get a part of of the string using a regular expression. It has four extra parameters:
- Regular expression The regular expresion to match. (You can use capturing groups to match a subset of the regular expression)
- Match group number 0 (zero) to get the entire regular expression match or a value different than zero to match a capturing group. (1 based index. 1 for first group,2 for second,etc)
- Case Insensitive Case insensitive matching
- Fail if no match If no match is found the task should fail (thus failing the build/release unless you have enabled Continue on error option)
The task with the following parameters
will set the value 1 into the myVar variable
The regular expression replace transformation is much more powerful than the replace transformation, allows you to better control how the replacement is made.
It has the following extra parameters:
- Regular expression The regular expresions used for the replacement
- replacement value Replacement value, you can use the following special replacement patterns:
- $$ Inserts a $
- $& Matched substring
- $` the portion of the string that precedes the matched string
- $n where n is a number that represents the matching sub group (starts at 1)
- Case Insensitive Case insensitive matching
- Replace all should all matches be replaced or just the first
The task with the following parameters
will set the value 3 matches three two one Entire Match = one two three 3 strings into the myVarReplacedValue variable
Set Variables with Credential
This task sets the username/password stored on a generic connection. This task can be used to centrally store a username/password and pass them to tasks that require a username/password without having to have the credentials replicated all over build/release definitions, with this task you can have single copy which can be centrally managed and change it centrally.
This task has three parameters:
- Connection The connection
- Username variable name
- Password variable name
In your can register service endpoints to store your reusable username/password to use in other tasks.
You need to create a Credential endpoint to store the user name and password.
The credental endpoint has the following parameters
- Connection Name The name of the connection, this is just a name for your reference. This name will be visible in the connection dropdown selection in the task
- username (optional) for this credential
- Password for this credential, you can use it with other secrets like tokens or such.
- Expiration Date (optional) You can see an expiration date on the credential. If you set a credential the build will fail if you try to use an expired credential. Ten days before expiration the task will issue warnings about expiration.
- Comment (optional)
Note You need to be member of "Endpoint Creators" group to create service endpoints.
Sets variable with value from JSON
Extracts a value from JSON (either a file or a variable) using a JSON path expression and sets the value to a variable.
If the result is a primitive type (boolean, number,string) that value will be set. If it's an array all values will be set (comma separated), all other types will be set as a JSON string.
The task has the following parameters
- Variable Name The name of the variable to set
- JSONPath expression The expression will be used to extract the value from the JSON (more info on JSONPath)
- JSON content The JSON content (if you don't specify a JSON content, you will need to specify a JSON file) where the value will be extracted from.
- JSON file The file with JSON content and where the value will be extracted from.
Sets variable with value from XML
Extracts a value from XML (either a file or a variable) using a XPath expression and sets the value to a variable.
Only node text or attributes are supported.
The task has the following parameters
- Variable Name The name of the variable to set
- XPath expression The expression will be used to extract the value from the XML
- XML content The XML content (if you don't specify a XML content, you will need to specify a XML file) where the value will be extracted from.
- XML file The file with XML content and where the value will be extracted from.
Update Build Number
Sets the build number with the passed value. Allows to you set the build number with a different number than the one it was initially assigned on queue.
Useful when you want to set the build number using a number with values which build number formatting settings don't support out of the box.
The task has a single parameter
- New Build Number The value of the new build number
Update Release Name
Sets the release name with the passed value. Allows to you set the releaze name with a different name than the one it was initially assigned on queue.
The task has a single parameter
- New Release Name The value of the new release name
Increment Version
Increments a build version in the semver format.
Allows you to increment by one number the following version components; major, minor or patch.
It can also clear the release or the build.
The task has the following parameters
- Version The version number to increment
- Increment Component Which version component to increment
- Major
- Minor
- Patch
- Clear Release If the version has a release component then clear it (eg: 1.1.0-alpha becomes 1.1.1 (assuming it was incrementing the patch))
- Clear Build If the version has a build component then clear it (eg: 1.1.0+20160101 becomes 1.1.1 (assuming it was incrementing the patch))
Adds one or more tags to a b uild
The task has a parameter
- Tag(s) The tag(s) you want to add to the build. One tag per line.
2. Rest Call
This extension provides a build task to call a web service.
This extension installs the following components:
- A build task to call a web service over HTTP management endpoint.
Create a generic Connection to your web service
- Make sure your webservice interface is exposed and can be reached over the network.
- Open the Services page in your Visual Studio Team Services Control Panel
- In the New Service Endpoint list, choose "Generic"
- Specify your webservice URL, and optionnaly username and password (if you want to use a PAT instead of username/password, set the PAT as password).
Add the Rest Call task to your build or release
Edit the build or release you want to update
Select the build task "Rest Call" available in the "Utility" category.
Set the parameters :
WebService endpoint: set the endpoint you previously defined.
Relative url to call on endpoint: set the url end part of the url.
e.g. if your endpoint target a webservice at "http://domain/", you may have to define the relative url to "api/targetedRessource/action".
Http method: Get, Post, Put or Delete. Depending on this choice, the following "body" field will be available or not.
Body (if Http method set to Post or Put): allows you to set a body if needed (json or whatever you want).
Content-type: defines the corresponding http-headers. It has only been tested with "application/json"...
save response to file: allows you to save the http response to a file. If checked, the following "output path" parameter will be available.
Output file path: defines the path of the file you want to save the http request to.
Telemetry
The tasks send anonymous telemetry so we can get a hold of task usage and errors.
No user data or task parameters are ever collected under any circunstances. Only data that allows anonymous usage collection.
The data is deleted after 7 days.