Skip to content
This repository has been archived by the owner on Mar 10, 2024. It is now read-only.

Commit

Permalink
Fix System.ServerType issue (#148)
Browse files Browse the repository at this point in the history
  • Loading branch information
qetza committed Apr 15, 2020
1 parent 7a6a743 commit 73845fc
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 5 deletions.
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,9 @@ If you want to use tokens in XML based configuration files to be replaced during
- replace tokens in your updated configuration file

## Release notes
**New in 3.5.1**
- Fix issue when variable `System.ServerType` is not defined ([#147](https://github.com/qetza/vsts-replacetokens-task/issues/147)).

**New in 3.5.0**
- Add anonymous usage telemetry.
- Ignore spaces between token prefix/suffix and variable name ([#143](https://github.com/qetza/vsts-replacetokens-task/issues/143)).
Expand Down
5 changes: 4 additions & 1 deletion make.js
Original file line number Diff line number Diff line change
Expand Up @@ -190,8 +190,11 @@ updateTelemetryScript = function(instrumentationKey, taskVersion) {
var scriptPath = path.join(binariesPath, 'task', 'telemetry.js');
var script = fs.readFileSync(scriptPath, { encoding: 'utf8' });

if (instrumentationKey)
script = script.replace(/const\s+instrumentationKey\s*=\s*'[^']*'\s*;/, "const instrumentationKey = '" + instrumentationKey + "';")
script = script.replace(/const\s+version\s*=\s*'[^']*'\s*;/, "const version = '" + taskVersion + "';");

if (taskVersion)
script = script.replace(/const\s+version\s*=\s*'[^']*'\s*;/, "const version = '" + taskVersion + "';");

fs.writeFileSync(scriptPath, script);
}
4 changes: 2 additions & 2 deletions task/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -394,7 +394,7 @@ var normalize = function (p: string): string {

async function run() {
let startTime: Date = new Date();
let serverType = tl.getVariable('System.ServerType').toLowerCase();
let serverType = tl.getVariable('System.ServerType');
let telemetryEnabled = tl.getBoolInput('enableTelemetry', true) && tl.getVariable('REPLACETOKENS_DISABLE_TELEMETRY') !== 'true';

let proxyUrl: string = undefined;
Expand All @@ -406,7 +406,7 @@ async function run() {
account: crypto.createHash('sha256').update(tl.getVariable('system.collectionid')).digest('hex'),
pipeline: crypto.createHash('sha256').update(tl.getVariable('system.teamprojectid') + tl.getVariable('system.definitionid')).digest('hex'),
pipelineType: tl.getVariable('release.releaseid') ? 'release' : 'build',
serverType: !serverType || serverType !== 'hosted' ? 'server' : 'services',
serverType: !serverType || serverType.toLowerCase() !== 'hosted' ? 'server' : 'services',
} as TelemetryEvent;

try {
Expand Down
2 changes: 1 addition & 1 deletion task/task.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
"version": {
"Major": 3,
"Minor": 5,
"Patch": 0
"Patch": 1
},
"instanceNameFormat": "Replace tokens in $(targetFiles)",
"minimumAgentVersion": "2.105.0",
Expand Down
2 changes: 1 addition & 1 deletion vss-extension.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"manifestVersion": 1,
"id": "replacetokens",
"name": "Replace Tokens",
"version": "3.5.0",
"version": "3.5.1",
"public": true,
"publisher": "qetza",
"targets": [
Expand Down

0 comments on commit 73845fc

Please sign in to comment.