Git Product home page Git Product logo

cols-agent-tasks's Introduction

Colin's ALM Corner Custom Build Tasks

Build Status

Donate

As Scott Hanselman says, "donations pay for tacos" (or low carb equivalent).

Overview

This repo contains custom tasks that meant to be used with Visual Studio Online and Team Foundation Server.

Build and Test

Use yarn to build and test these extensions. All yarn scripts are specified in the package.json file. Run yarn run to get a prompt of all the targets. The most important are:

  1. install: install dependencies in root folder.
  2. install-libs install dependencies in each Task folder (required since each task has to be self-contained).
  3. test to run tests.
  4. debugtest to run tests with verbose logging.
  5. cover to run tests with code coverage.
  6. prepextension to run install and coverage (used to package the extension in the build).

Tasks

The following tasks are available:

  1. Version Assemblies

    This task versions assemblies according to the build number. More...

  2. Replace Tokens

    This task replaces tokens in a file using Environment variables. More...

  3. DacPac Change Report Task

    This task calculates the changes in an SSDT project between builds. More...

  4. Tokenizer

    This task tokenizes a file automatically. More...

  5. Coverage Gate

    This task allows you to fail a release (or build) based of coverage delta. More...

Changing the Code

The easiest way to open the source is to clone the repo and open in VSCode. If you change the .ts files, then run build (ctrl-shift-b) to compile the .js files.

Creating the Extension Package

Help Pages can be found here.

To compile the extension, update the version number in the extension-manifest.json file and run:

tfx extension create --manifest-globs .\vss-extension.json

Upload to the marketplace by singing in to your publisher profile.

cols-agent-tasks's People

Contributors

ad-mca-mk avatar antony77 avatar azure-pipelines[bot] avatar colindabritzviewpoint avatar colindembovsky avatar dbuckingham avatar dependabot[bot] avatar dixu99 avatar eogas avatar erikmourits avatar glaeqen avatar gurucharan94 avatar istairbn avatar joshjohanning avatar lurumad avatar neokushan avatar pascalk avatar runnx avatar scottaddie avatar zsu avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

cols-agent-tasks's Issues

Escaping special characters in ReplaceTokens Secrets

Colin,

Any way to escape the ':' and ';' characters when using Advanced -> Secret Tokens?

Related - does usage of your Secret Tokens feature provide additional security beyond simply not echoing the secrets to logs and masking them in the K:V pair UI? (i.e. does it protect me from more than just eyes over my shoulder / someone with direct access to my VSTS account?)

p.s. sorry for the duplicate issue, I thought maybe this was user error and deleted my first issue on this. (of course, it still may be user error, in which case please correct me!)

Not finding any matches

After the last update the plugin fails to update the version (everything worked perfectly before). Here is the log:

Set workingFolder to default: C:\LR\MMS\Services\Mms\TaskAgentProvisioner\Tools\agents\1.96.3\tasks\VersionAssemblies\0.1.15
[debug]Starting Version Assemblies step
[debug]sourcePath=C:\a\1\s\MyProject\MyProject
[debug]check path : C:\a\1\s\MyProject\MyProject
[debug]sourcePath=C:\a\1\s\MyProject\MyProject
[debug]filePattern=AssemblyInfo.*
[debug]buildRegex=\d+.\d+.\d+.\d+
[debug]buildRegexIndex=0
[debug]replaceRegex=
[debug]replacePrefix=
[debug]failIfNoMatchFound=true
[debug]Build.BuildNumber=1.3.2.0
[debug]sourcePath :C:\a\1\s\MyProject\MyProject
[debug]filePattern : AssemblyInfo.*
[debug]buildRegex : \d+.\d+.\d+.\d+
[debug]buildRegexIndex : 0
[debug]replaceRegex :
[debug]replacePrefix :
[debug]failIfNoMatchFound : true
[debug]buildNumber : 1.3.2.0
[debug]Using \d+.\d+.\d+.\d+ as the replacement regex
[debug]Using 0 as the build regex index regex
Using prefix [] and version [1.3.2.0] in folder [C:\a\1\s\MyProject\MyProject]
[debug]glob C:\a\1\s\MyProject\MyProject\AssemblyInfo.*
[debug]found 0 matches
[warning]No files found
[debug]Leaving Version Assemblies step

AssemblyInfo.cs file is a standard file, not been changed from day zero.

Also flag failIfNoMatchFound is set, but the flag does not do anything - the build does not fail, though no match is found.

Thanks

Tag Build/Release

This task doesn't work when you add it on the release, I need to create a tag only when I release to production using the build, so I can identify builds that went to production with a unique tag

Coverage Gate: Cannot read property 'coverageStats' of undefined

I'm trying out the CoverageGate task on VSTS, and I'm getting an error:

##[error]Cannot read property 'coverageStats' of undefined

I've enabled the OAuth token and I have at least two builds with published Code Coverage stats, so I'm not sure what's wrong.

As requested, here is the attached verbose build log:
1_Build.txt

Secret Variables with special characters

I have a password that contains a special character "%" the password variable it is also hidden, it doesn't get replaced when i Use Replace Tokens step no error just a blank Password=" how could fix this? I change the password to SomePass put it as hidden and it Got Replaced so i am assuming that The "%" character is a problem

Regexp does not parse correctly string

Hello.

Version tasks\ReplaceTokens\1.1.29

In files he have the following format of tokens: @@var@@

Token Regex: @@(\w+)@@

There is a string: '@@CUSTOM_BUILDMAJORNUM@@.@@CUSTOM_BUILDMINORNUM@@.@@CUSTOM_BUILDPATCHNUM@@'

When this task works: it replaces only @@CUSTOM_BUILDMAJORNUM@@ and @@CUSTOM_BUILDPATCHNUM@@, it skips the token in the middle

I checked pattern here https://regex101.com/#javascript against the line above and it matches correctly

2016-09-22T10:25:54.6611829Z Starting regex replacement in [package.ps1]
2016-09-22T10:25:54.6767828Z ##[debug]CUSTOM_BUILDMAJORNUM=1
2016-09-22T10:25:54.6767828Z ##[debug]Replaced token [CUSTOM_BUILDMAJORNUM]
2016-09-22T10:25:54.6767828Z ##[debug]CUSTOM_BUILDPATCHNUM=0
2016-09-22T10:25:54.6767828Z ##[debug]Replaced token [CUSTOM_BUILDPATCHNUM]
2016-09-22T10:25:54.6767828Z ##[debug]tokens=undefined
2016-09-22T10:25:54.6767828Z ##[warning]Token [tokens] does not have an environment value

Could you please help?

Thanks

Replace changes the file encode to ASCII

When i try to replace token from a file with ANSI enconde, after replace it converted to UTF-8. This is very bad for files which contains special characters.

String "Versão"

Before (ANSI)
image

After (UTF-8)
image

Replace Tokens does not replace User ID token for web.config connection string

I have ran the Replace Tokens task many times for my config files and a common issue that ALWAYS happens is the task will not replace the user Id token in the connection string.

e.g. Data Source=dbServer;Initial Catalog=dbName;User=dbUser;Password=dbPassword

In this example, all tokens get replaced EXCEPT dbUser. There is nothing special with the user name and this happens 100% on all my projects. It only happens with the user id token as well.

I have tried renaming, using different token patterns with no luck. It is ONLY that token (after User Id =).

Does anyone know why this is happening? I am getting around it by hard-coding just the username but i would prefer to know why the user id doesn't get replaced.

Error when running task

Got this in error in the TFS 2015 Update 2 Release Management:

2017-03-01T16:17:39.3689667Z C:\Build Agents\default\tasks\JSONTokenizer\0.0.83\tokenizer.js:10

2017-03-01T16:17:39.3689667Z const tl = require("vsts-task-lib/task");

2017-03-01T16:17:39.3699665Z ^^^^^

2017-03-01T16:17:39.3699665Z SyntaxError: Use of const in strict mode.

2017-03-01T16:17:39.3709639Z at exports.runInThisContext (vm.js:73:16)

2017-03-01T16:17:39.3709639Z at Module._compile (module.js:443:25)

2017-03-01T16:17:39.3719623Z at Object.Module._extensions..js (module.js:478:10)

2017-03-01T16:17:39.3719623Z at Module.load (module.js:355:32)

2017-03-01T16:17:39.3729622Z at Function.Module._load (module.js:310:12)

2017-03-01T16:17:39.3729622Z at Function.Module.runMain (module.js:501:10)

2017-03-01T16:17:39.3739615Z at startup (node.js:129:16)

2017-03-01T16:17:39.3739615Z at node.js:814:3

Version Assemblies: Whitespace in Source Path

Version Assemblies task does't seem to respect whitespaces in the "Source Path", e. g.:

  • Source Path: $/Omega/ABC Manager.Droid/Properties
  • File Pattern: AndroidManifest.xml

This will produce the following log:
##[debug]glob "C:\a\1\s\ABC Manager.Droid\Properties"\AndroidManifest.xml
##[debug]found 0 matches
##[warning]No files found

Search fails when source path includes a space

The path is quoted, but the search parameters are then appended, resulting in the following glob always failing to match:

Source path: C:\vsts_agent_work\874a330a4\build name has a space\drop
Search Parameter: App.SetParameters.xml

Result:

[debug]glob "C:\vsts_agent_work\874a330a4\build name has a space\drop"App.SetParameters.xml

Not the quotes before the parameter that breaks the copy.

Cannot read property 'toLowerCase' of undefined

Here is the log

2017-02-09T21:35:07.0855146Z ##[section]Starting: Replace tokens in BikeSharing360_MobileApps/src/BikeSharing.Clients.Core/.
2017-02-09T21:35:07.1167734Z ==============================================================================
2017-02-09T21:35:07.1167734Z Task : Replace Tokens
2017-02-09T21:35:07.1167734Z Description : Replaces tokens in a file using RegEx. Values come from any variable defined in the current Environment.
2017-02-09T21:35:07.1167734Z Version : 1.1.63
2017-02-09T21:35:07.1167734Z Author : Colin Dembovsky (colinsalmcorner.com)
2017-02-09T21:35:07.1167734Z Help : More Information
2017-02-09T21:35:07.1167734Z ==============================================================================
2017-02-09T21:35:07.3355787Z ##[debug]agent.workFolder=C:\buildagent3_work
2017-02-09T21:35:07.3355787Z ##[debug]loading inputs and endpoints
2017-02-09T21:35:07.3355787Z ##[debug]loading ENDPOINT_AUTH_3f54bb33-193e-45f4-a2af-83b76d02c66b
2017-02-09T21:35:07.3355787Z ##[debug]loading ENDPOINT_AUTH_PARAMETER_3f54bb33-193e-45f4-a2af-83b76d02c66b_ACCESSTOKEN
2017-02-09T21:35:07.3355787Z ##[debug]loading ENDPOINT_AUTH_PARAMETER_SYSTEMVSSCONNECTION_ACCESSTOKEN
2017-02-09T21:35:07.3355787Z ##[debug]loading ENDPOINT_AUTH_SCHEME_3f54bb33-193e-45f4-a2af-83b76d02c66b
2017-02-09T21:35:07.3355787Z ##[debug]loading ENDPOINT_AUTH_SCHEME_SYSTEMVSSCONNECTION
2017-02-09T21:35:07.3355787Z ##[debug]loading ENDPOINT_AUTH_SYSTEMVSSCONNECTION
2017-02-09T21:35:07.3355787Z ##[debug]loading INPUT_FILEPATTERN
2017-02-09T21:35:07.3355787Z ##[debug]loading INPUT_SECRETTOKENS
2017-02-09T21:35:07.3355787Z ##[debug]loading INPUT_SOURCEPATH
2017-02-09T21:35:07.3355787Z ##[debug]loading INPUT_TOKENREGEX
2017-02-09T21:35:07.3355787Z ##[debug]loaded 10
2017-02-09T21:35:07.3512078Z ##[debug]Starting Replace Tokens task
2017-02-09T21:35:07.3512078Z ##[debug]sourcePath=C:\buildagent3_work\5\s\BikeSharing360_MobileApps\src\BikeSharing.Clients.Core
2017-02-09T21:35:07.3512078Z ##[debug]check path : C:\buildagent3_work\5\s\BikeSharing360_MobileApps\src\BikeSharing.Clients.Core
2017-02-09T21:35:07.3512078Z ##[debug]filePattern=GlobalSettings.cs
2017-02-09T21:35:07.3512078Z ##[debug]tokenRegex=YOUR_PROFILE_SERVICE
2017-02-09T21:35:07.3512078Z ##[debug]secretTokens=bikesharing-services-profileseh7q7oryxj6yk
2017-02-09T21:35:07.3512078Z ##[debug]secretTokens: found [0] tokens
2017-02-09T21:35:07.3668362Z ##[debug]sourcePath: [C:\buildagent3_work\5\s\BikeSharing360_MobileApps\src\BikeSharing.Clients.Core]
2017-02-09T21:35:07.3668362Z ##[debug]filePattern: [GlobalSettings.cs]
2017-02-09T21:35:07.3668362Z ##[debug]tokenRegex: [YOUR_PROFILE_SERVICE]
2017-02-09T21:35:07.3668362Z ##[debug]Using [GlobalSettings.cs] as filePattern
2017-02-09T21:35:07.3668362Z ##[debug]glob C:\buildagent3_work\5\s\BikeSharing360_MobileApps\src\BikeSharing.Clients.Core\GlobalSettings.cs
2017-02-09T21:35:07.3668362Z ##[debug]found 1 matches
2017-02-09T21:35:07.3668362Z ##[debug]matches:
2017-02-09T21:35:07.3668362Z ##[debug]C:/buildagent3/_work/5/s/BikeSharing360_MobileApps/src/BikeSharing.Clients.Core/GlobalSettings.cs
2017-02-09T21:35:07.3668362Z Starting regex replacement in [C:/buildagent3/_work/5/s/BikeSharing360_MobileApps/src/BikeSharing.Clients.Core/GlobalSettings.cs]
2017-02-09T21:35:07.3668362Z ##[debug]task result: Failed
2017-02-09T21:35:07.3824661Z ##[error]Cannot read property 'toLowerCase' of undefined
2017-02-09T21:35:07.3824661Z ##[debug]Processed: ##vso[task.issue type=error;]Cannot read property 'toLowerCase' of undefined
2017-02-09T21:35:07.3824661Z ##[debug]Processed: ##vso[task.complete result=Failed;]Cannot read property 'toLowerCase' of undefined
2017-02-09T21:35:07.3824661Z ##[debug]Leaving Replace Tokens task

Tokenizer json files with arrays

Hi,

I have an autofac.json like this:

{
  "defaultAssembly": "WebApi",
  "modules": [
    {
      "type": "WebApi.Infrastucture.ContainerModules.DataModule, WebApi",
      "parameters": {
        "connectionString": "",
        "defaultSchema": ""
      }
    },
    {
      "type": "WebApi.Infrastucture.ContainerModules.MediatorModule, WebApi"
    }
  ]
}

Can I tokenize modules array? connectionString and defaultSchema?

Regards

Variables and Data Types

Hi, we are replacing tokens in a JSON configuration file and one of the properties expect a boolean. The issue is that when the token is replaced, it is being set as a string (i.e. "false") rather than false. We can possible change the code to correctly parse, but rather not. Is there a way to specify a data type to replace it?

Tokenizer doesn't install

I installed the package from marketplace and all the build tasks show up except the Tokenizer task. I've uninstalled and reinstalled with no luck.

skip options?

Can you add options to skip deleting certain folders/files?

Use of const in strict mode

Trying to run the replaceToken task in TFS 2015 (on prem) I get this:

2017-01-18T13:56:01.3148978Z const tl = require('vsts-task-lib/task');
2017-01-18T13:56:01.3148978Z ^^^^^
2017-01-18T13:56:01.3148978Z SyntaxError: Use of const in strict mode.

Build server is running Node:
> node -v
v6.9.4

Am I missing something? Known issue? Anything else I can add to assist with debugging?

Thanks

Cannot find module 'vso-task-lib'

Installed the extension from the VSTS marketplace (no mentions of dependencies), got the following error message the first time I tried to use it:
2016-02-19T19:07:05.1093348Z Set workingFolder to default: D:\Agent\tasks\ReplaceTokens\0.0.3
2016-02-19T19:07:05.3121387Z module.js:338
2016-02-19T19:07:05.3121387Z throw err;
2016-02-19T19:07:05.3121387Z ^
2016-02-19T19:07:05.3121387Z Error: Cannot find module 'vso-task-lib'
2016-02-19T19:07:05.3121387Z at Function.Module._resolveFilename (module.js:336:15)
2016-02-19T19:07:05.3121387Z at Function.Module._load (module.js:278:25)
2016-02-19T19:07:05.3121387Z at Module.require (module.js:365:17)
2016-02-19T19:07:05.3121387Z at require (module.js:384:17)
2016-02-19T19:07:05.3121387Z at Object. (D:\Agent\tasks\ReplaceTokens\0.0.3\replaceTokens.js:1:72)
2016-02-19T19:07:05.3121387Z at Module._compile (module.js:460:26)
2016-02-19T19:07:05.3121387Z at Object.Module._extensions..js (module.js:478:10)
2016-02-19T19:07:05.3121387Z at Module.load (module.js:355:32)
2016-02-19T19:07:05.3121387Z at Function.Module._load (module.js:310:12)
2016-02-19T19:07:05.3121387Z at Function.Module.runMain (module.js:501:10)

The removal of the PowerShell execution and problems updating the assembly.cs file using Node

Hi,

As of the latest update, all of our build are now failing both hosted and on our own build server. What I have needed to do is to put the powershell back in place though with the two additional advanced parameters. The reason is that the execution of the JS falls over trying to update the physical files, I think due to some level of permissions as the files are readonly having just got the latest from source control. It seems Powershell though is able to write to the files and hence update the version numbers correctly.

This has resolved our build though we now need to ensure we execute all builds on our own build server as the hosted server with Microsoft is no longer an option. Hence if the PowerShell can be re-introduced otherwise the permission issue needs to be resolved in the Node execution. The specific error is (note I have removed the actual full working folder myself to '...' which is correct at execution time):

2016-03-03T11:09:31.8058929Z shell.js: internal error
2016-03-03T11:09:31.8215181Z Error: EPERM, operation not permitted 'C:\Agents\Work_1\...\Properties\AssemblyInfo.cs'
2016-03-03T11:09:31.8215181Z     at Error (native)
2016-03-03T11:09:31.8215181Z     at Object.fs.openSync (fs.js:500:18)
2016-03-03T11:09:31.8215181Z     at Object.fs.writeFileSync (fs.js:1099:15)
2016-03-03T11:09:31.8215181Z     at Object._sed (C:\Agents\tasks\VersionAssemblies\0.1.3\node_modules\shelljs\src\sed.js:39:8)
2016-03-03T11:09:31.8215181Z     at Object.sed (C:\Agents\tasks\VersionAssemblies\0.1.3\node_modules\shelljs\src\common.js:186:23)
2016-03-03T11:09:31.8215181Z     at Object.<anonymous> (C:\Agents\tasks\VersionAssemblies\0.1.3\versionAssemblies.js:44:16)
2016-03-03T11:09:31.8215181Z     at Module._compile (module.js:460:26)
2016-03-03T11:09:31.8215181Z     at Object.Module._extensions..js (module.js:478:10)
2016-03-03T11:09:31.8215181Z     at Module.load (module.js:355:32)
2016-03-03T11:09:31.8215181Z     at Function.Module._load (module.js:310:12)

Note it took a little time as the task actually initially hadn't updated as the copy we had before the recent update was already in a version 0.1.3 folder so there may also be a versioning issue to the task though that's not my main concern at the moment. hence the task fell over regarding a missing parameter before even getting the task started. Resolved by deleting the task folder from our build server at which point the latest version was downloaded and this more critical issue was found...

Thanks
Mark

Virus warning

When I download the repro as a ZIP I get this message from Windows Defender, anyone else?

Category: Trojan

Description: This program is dangerous and executes commands from an attacker.

Recommended action: Remove this software immediately.

Items:
containerfile:C:\ProgramData\Microsoft\Windows Defender\Scans\FilesStash\7C3ABA63-688B-0EE1-2B8A-09AD80F61ECB_1d25198276f6eb9
containerfile:C:\Users\tschi\Downloads\cols-agent-tasks-master.zip
file:C:\ProgramData\Microsoft\Windows Defender\Scans\FilesStash\7C3ABA63-688B-0EE1-2B8A-09AD80F61ECB_1d25198276f6eb9->(MPLC)->cols-agent-tasks-master/Tasks/CoverageGate/coverageGate.js
file:C:\Users\tschi\Downloads\cols-agent-tasks-master.zip->cols-agent-tasks-master/Tasks/CoverageGate/coverageGate.js
webfile:C:\ProgramData\Microsoft\Windows Defender\Scans\FilesStash\7C3ABA63-688B-0EE1-2B8A-09AD80F61ECB_1d25198276f6eb9|https://codeload.github.com/colindembovsky/cols-agent-tasks/zip/master|browser_broker.exe
webfile:C:\Users\tschi\Downloads\cols-agent-tasks-master.zip|https://codeload.github.com/colindembovsky/cols-agent-tasks/zip/master|browser_broker.exe

Consider changing default regular expression

Would you consider changing the default regular expression for replace tokens from (\w+) to ([a-zA-Z0-9.:]+)_ . Increasingly seeing .net apps (especially azure stuff) using app:setting e.g. ida:ClientId which the current regex doesn't pick up.

Tags textbox doesn't resolve variables

Terrific tools Colin!
However, the Tags textbox of the Tag Build task does not recognize variables. I want to tag builds with the reason for the build. VSTS provides it via $(Build.BuildReason). However when I input $(Build.BuildReason) in the Tags textbox, the tag set is '$(Build.BuildReason)' instead of the resolved build reason value. Is this fixable?

Not replacing $(Build.BuildNumber)

I'am trying to replace some variables but it's not working.

This is my javascript file

angular.module('app') .service('Configs', [function () { this.App = { Id: "xxxxx", Name: "xxxxx", Version: "__$(Build.BuildNumber)__", VersionDate: "__$(Day:dd)__/__$(Month:MM)__/__$(Year:yyyy)__", BaseUrl: window.location.origin + "#/", Services: { Backend: { ServiceURL: "__ApiUrl__", }} ////ApiUrl is replaced during release }; }]);

I also tryed the following using a variable Version with value $(Build.BuildNumber), and still not working:

angular.module('app') .service('Configs', [function () { this.App = { Id: "xxxxx", Name: "xxxxx", Version: "__Version__", VersionDate: "__VersionDate__", BaseUrl: window.location.origin + "#/", Services: { Backend: { ServiceURL: "__ApiUrl__", }} ////ApiUrl is replaced during release }; }]);

What I am doing wrong?

DacPac Change Report Task not in Task List

DacPac Change Report Task looks like a great task. I am using TFS 2015.3 and just added Colin's ALM Corner Custom Build Task v1.1.40. I edit my build definition and try to add the task but in to not in the list of available tasks.

I have performed an update, uninstalled and reinstalled but still no luck. Any ideas?

Thanks

Web deploy task does not handle cmd path with spaces

Thanks for creating such an awesome package. I've noticed that if my branch names have spaces in them, the cmd file will fail to run. Here is an example log from VSTS Online:

2016-04-05T16:03:22.0212411Z cmd /c C:\a\0f79b84a2\xxx - Feature (xxxx) build\drop\rest\of\path /Y "/M:https://xxx.scm.azurewebsites.net:443/msdeploy.axd" "/u:$xxx" "/p:*****" /a:Basic

2016-04-05T16:03:22.0442412Z ##[error]'C:\a\0f79b84a2\xxx' is not recognized as an internal or external command,

I think the only change that needs to be made is on line 91. The $cmdfile argument should be explicitly quoted.

Version Assemblies task no longer does multiline matches (due to update to sed in shelljs)

tldr: Version Assemblies had per-file matches previously, but now has per-line matches in the latest version. Workaround for some cases: collapse settings into single lines.

Thanks much for the excellent and useful task library!

We've been using the versioning task for iOS mobile Info.plist versioning for some time now. The "Version Assemblies" task has been working for a while with version 2.0.86, but just recently stopped working in 2.2.117. We have tracked this down to a change in sed in shelljs upstream.

Issue Analysis

By default, for iOS the Info.plist file has keys and values on separate lines, which is awkward in terms of XML structure, but worked fine. Our replacement is a little odd because of this.

We're replacing these lines:

	<key>CFBundleVersion</key>
	<string>2.16.2.0</string>

and using the settings as outlined in our readme contribution for iOS:
https://github.com/colindembovsky/cols-agent-tasks/blob/master/Tasks/VersionAssemblies/readme.md

Including the replacement pattern: <key>CFBundleVersion</key>\s*<string>.*</string>

The script log reports that it found one instance, and replaced it, and the displayed values look correct for regex, build number, and replacements.

2017-04-24T11:19:56.6690231Z ==============================================================================
2017-04-24T11:19:56.8721473Z Using prefix [<key>CFBundleVersion</key><string>] and version [2.16.2.64] and postfix [</string>] in folder [C:\agent\_work\14\s\FieldViewMobile.iOS]
2017-04-24T11:19:56.9815246Z Changing version in C:\agent\_work\14\s\FieldViewMobile.iOS\Info.plist
2017-04-24T11:19:56.9815246Z 1 matches for regex [<key>CFBundleVersion</key>\s*<string>.*</string>] found in file C:\agent\_work\14\s\FieldViewMobile.iOS\Info.plist
2017-04-24T11:19:56.9815246Z Processed 1 files
2017-04-24T11:19:56.9971450Z ##[section]Finishing: Version iOS info.plist (full version)

system.debug = True in variables doesn't appear to offer better information.

2017-04-24T17:06:10.4037584Z ##[debug]608 results
2017-04-24T17:06:10.4037584Z ##[debug]found 608 paths
2017-04-24T17:06:10.4037584Z ##[debug]applying include pattern
2017-04-24T17:06:10.4037584Z ##[debug]adjustedPattern: 'C:\agent\_work\14\s\FieldViewMobile.iOS\**\info.plist'
2017-04-24T17:06:10.4193833Z ##[debug]1 matches
2017-04-24T17:06:10.4193833Z ##[debug]1 final results
2017-04-24T17:06:10.4193833Z Changing version in C:\agent\_work\14\s\FieldViewMobile.iOS\Info.plist
2017-04-24T17:06:10.4193833Z 1 matches for regex [<key>CFBundleVersion</key>\s*<string>.*</string>] found in file C:\agent\_work\14\s\FieldViewMobile.iOS\Info.plist
2017-04-24T17:06:10.4193833Z Processed 1 files
2017-04-24T17:06:10.4193833Z ##[debug]Leaving Version Assemblies step
2017-04-24T17:06:10.4350096Z ##[section]Finishing: Version iOS info.plist (full version)

Checking the file on disk shows no replacement occurred.

Suspected cause

I believe this was exposed when shelljs was updated from version 0.5.3 to 0.7.7 in this changeset:

14816af

This change in shelljs is in 0.7.7, but not in 0.5.3:
shelljs/shelljs@1ee696d

and it fairly explicitly converts the regex replacement in sed to use split('\n'), and become a per-line editor (as sed generally is by default). The function has been changed further since, but this was when the 'whole file' behavior became 'per line'.

I did not see an option to change the behavior of sed in this case, so I am unsure how to proceed. For the versioning task, it might be helpful to add an option for multi-line matching vs single line matching.

Encrypted Password

Hi, is there a way to Replace the Password token in the connection string so that it will be encrypted as ******? (In my setParameters file i have the password argument showing as normal i want to be encrypted)

Tokenizer fails on JSON comments

I am trying to tokenize a json that contains /* comment */ and // comment style comments. Tokenize fails though:

Unexpected token / in JSON at position 1090

Would be nice if tokenize would handle comments.

two tokens on the same line

Should it be possible to tokenize two variables on the same line? On one line I have "APL__app__X__env__". This generates the error: "##[warning]Token [app__X__env] does not have an environment value".

ReplaceTokens toLowerCase error

Hello I have a problem with Replace Tokens Task on Mac Build Agent...
The build in vsts raise error when replacing tokens...

Unhandled: Cannot read property 'toLowerCase' of undefined

Can you help me pls??

Bump up the version number.. Possible?

Hi Colin,

I am using your extension in one of my build definitions. I have Build number formatting 1.0.0$(rev:.r).

The plugin picks up d+ from the last revision of build number if I am not wrong. How do we handle the version bump i.e. 1.0.0.1 to 2.0.0 or 2.0.0.1 for my app (in case of total revamp etc).

How can I do that? I am quite confused. Is there any provision for that?

ReplaceTokensTask: Cannot read property 'split' of null

Since you updated this task today, we are getting the error "Cannot read property 'split' of null " if we do not specify any value for the 'secretTokens' property.

This happens on line 15 with the undefined check:
if (typeof secretTokenInput !== "undefined") {

All I did was to add a null check before to get our releases going again.

if (secretTokenInput != null && typeof secretTokenInput !== "undefined") {

Not sure if this is 100% correct, but it got our releases going, so that is all that mattered for me.

log said success but file not change

I am using the replace token task in VS team service. The log said it's success but I check the artifact and the file is not changed. I selected the source using the '...' button and select the folder from the linked artifact. Does the release download the artifact to another place before it executes the tasks. If so where can I see the downloaded artifact on vs team service?
Below is the log:
2016-05-05T18:31:44.0162790Z Set workingFolder to default: C:\LR\MMS\Services\Mms\TaskAgentProvisioner\Tools\agents\1.99.0\tasks\ReplaceTokens\0.0.15

2016-05-05T18:31:44.3692766Z ##[debug]Starting Replace Tokens task

2016-05-05T18:31:44.3702762Z ##[debug]sourcePath=C:\a\7bad7eace\WebFrameworkMVC_Dev\drop

2016-05-05T18:31:44.3702762Z ##[debug]check path : C:\a\7bad7eace\WebFrameworkMVC_Dev\drop

2016-05-05T18:31:44.3702762Z ##[debug]sourcePath=C:\a\7bad7eace\WebFrameworkMVC_Dev\drop

2016-05-05T18:31:44.3712774Z ##[debug]filePattern=/WebFramework.Web.SetParameters.xml

2016-05-05T18:31:44.3712774Z ##[debug]tokenRegex=(\w+)

2016-05-05T18:31:44.3722766Z ##[debug]secretTokens=SmtpPassword:********

2016-05-05T18:31:44.3732764Z Secret token input found [smtppassword]

2016-05-05T18:31:44.3732764Z ##[debug]secretTokens: found [1] tokens

2016-05-05T18:31:44.3742768Z ##[debug]sourcePath: [C:\a\7bad7eace\WebFrameworkMVC_Dev\drop]

2016-05-05T18:31:44.3742768Z ##[debug]filePattern: [/WebFramework.Web.SetParameters.xml]

2016-05-05T18:31:44.3752765Z ##[debug]tokenRegex: [(\w+)]

2016-05-05T18:31:44.3752765Z ##[debug]Using [/WebFramework.Web.SetParameters.xml] as filePattern

2016-05-05T18:31:44.3762761Z ##[debug]glob C:\a\7bad7eace\WebFrameworkMVC_Dev\drop/WebFramework.Web.SetParameters.xml

2016-05-05T18:31:44.3782767Z ##[debug]found 1 matches

2016-05-05T18:31:44.3792767Z ##[debug]matches:

2016-05-05T18:31:44.3818587Z ##[debug]C:/a/7bad7eace/WebFrameworkMVC_Dev/drop/WebFramework.Web.SetParameters.xml

2016-05-05T18:31:44.3822757Z Starting regex replacement in [C:/a/7bad7eace/WebFrameworkMVC_Dev/drop/WebFramework.Web.SetParameters.xml]

2016-05-05T18:31:44.3822757Z ##[debug]Replaced token [SmtpPassword] with a secret value

2016-05-05T18:31:44.3832759Z ##[debug]SourceBranch=undefined

2016-05-05T18:31:44.3892747Z ##[warning]Token [SourceBranch] does not have an environment value

2016-05-05T18:31:44.3902761Z ##[debug]SourceVersion=undefined

2016-05-05T18:31:44.3912760Z ##[warning]Token [SourceVersion] does not have an environment value

2016-05-05T18:31:44.3912760Z Writing new values to file

2016-05-05T18:31:44.3922761Z ##[debug]Leaving Replace Tokens task

VSTS Pull Requests

I am attempting to use the Gated Coverage plugin for a gated build. It appears however the plugin compares the build against the source branch, not the target branch when ran on a VSTS pull request. Is there a way to make this use the target branch or a specific branch for historical coverage?

Thanks!

Disable no match warnings in Version Assemblies?

We've been seeing the following warnings in our build summary since we've updated to the newest version of the Version Assemblies task.

screenshot-visualstudio com

The assembly.info files in the screenshot above seem to be added by NuGet restore and since we don't use any of these dll's we'd like to be able to disable warnings for these files.

Maybe a radical solution is to just be able to disable these warnings?
Or is there a way for me to fix this with a specific file pattern?

Here's an overview of the settings we're using:

screenshot-visualstudio com2

20-08-2017 Update: Added a pull request with a possible "fix".

ReplaceTokens fails with space in path

Recently the ReplaceTokens task fails if the path contains a space. It worked with version 0.0.3 on the 26th february, but fails today with version 0.0.4.

Error message:

2016-03-07T19:33:02.2330283Z ##[error]Could not find file "D:\BuildAgent\_work\d5b03417b\Some Folder\Debug\SomeProject.Web.SetParameters.xml"

AssemblyVersion: any chance of specifying alternate env variable?

Because of the way the versionCode works on Android and how it's disconnected from versionName, and because of the way the $(rev:.r) variable works in VSTS, it's very difficult to use a $(Build.BuildNumber) that is somehow based on a scheme that could change daily (like 2016.06.08.r), which would reset "r" when the date changes.

So, is there any chance of being able to specify an alternate environment variable from which to draw this versionCode value? even if we were to maintain the version numbers and names in the project, and just use a "static" $(Build.BuildNumber), eventually the build numbers would become meaningless because they would just be 1.0.0.1, 1.0.0.2, 1.0.0.3 with very little context.

Am I totally off base?

Thanks.

Extension Install fails with Application Event Message

I downloaded the package for Visual Studio Market Place and installed it in TFS 2015 Update 3.

The install did not throw any errors.
No Steps were added.
Found this in the Application Event Log

TF53010: The following error has occurred in a Team Foundation component or extension:
Date (UTC): 6/5/2017 5:43:13 PM
Machine: IVPTFS
Application Domain: /LM/W3SVC/2/ROOT/tfs-1-131411579076200198
Assembly: Microsoft.TeamFoundation.Framework.Server, Version=14.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a; v4.0.30319
Service Host: c0b051f3-21ce-48aa-af34-fcf7aeaed433 (TEAM FOUNDATION)
Process Details:
Process Name: w3wp
Process Id: 1344
Thread Id: 4336
Account name: TQL\TFSAdmin

Detailed Message: TF30065: An unhandled exception occurred.

Web Request Details
Url: http://ivptfs:8080/tfs/_gallery/items/colinsalmcorner.colinsalmcorner-buildtasks?targetId=7cad50fc-953d-424a-8ab8-640dcfb0a0b4 [method: GET]
User Agent: Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 6.2; WOW64; Trident/6.0; .NET4.0E; .NET4.0C; .NET CLR 3.5.30729; .NET CLR 2.0.50727; .NET CLR 3.0.30729)
Headers: not available
Path: /tfs/_gallery/items/colinsalmcorner.colinsalmcorner-buildtasks
Local Request: True
Host Address: fe80::ed94:b859:e9b:fa94%12
User: TQL\TFSAdmin [authentication type: NTLM]

Exception Message: This request has been blocked because sensitive information could be disclosed to third party web sites when this is used in a GET request. To allow GET requests, set JsonRequestBehavior to AllowGet. (type InvalidOperationException)
Exception Stack Trace: at System.Web.Mvc.JsonResult.ExecuteResult(ControllerContext context)
at System.Web.Mvc.ControllerActionInvoker.<>c__DisplayClass1a.b__17()
at System.Web.Mvc.ControllerActionInvoker.InvokeActionResultFilter(IResultFilter filter, ResultExecutingContext preContext, Func1 continuation) at System.Web.Mvc.ControllerActionInvoker.InvokeActionResultFilter(IResultFilter filter, ResultExecutingContext preContext, Func1 continuation)
at System.Web.Mvc.ControllerActionInvoker.InvokeActionResultFilter(IResultFilter filter, ResultExecutingContext preContext, Func1 continuation) at System.Web.Mvc.ControllerActionInvoker.InvokeActionResultFilter(IResultFilter filter, ResultExecutingContext preContext, Func1 continuation)
at System.Web.Mvc.ControllerActionInvoker.InvokeActionResultWithFilters(ControllerContext controllerContext, IList`1 filters, ActionResult actionResult)
at System.Web.Mvc.Async.AsyncControllerActionInvoker.<>c__DisplayClass25.b__22(IAsyncResult asyncResult)
at System.Web.Mvc.Controller.<>c__DisplayClass1d.b__18(IAsyncResult asyncResult)
at System.Web.Mvc.Async.AsyncResultWrapper.<>c__DisplayClass4.b__3(IAsyncResult ar)
at System.Web.Mvc.Controller.EndExecuteCore(IAsyncResult asyncResult)
at System.Web.Mvc.Async.AsyncResultWrapper.<>c__DisplayClass4.b__3(IAsyncResult ar)
at System.Web.Mvc.Controller.EndExecute(IAsyncResult asyncResult)
at System.Web.Mvc.MvcHandler.<>c__DisplayClass8.b__3(IAsyncResult asyncResult)
at System.Web.Mvc.Async.AsyncResultWrapper.<>c__DisplayClass4.b__3(IAsyncResult ar)
at System.Web.Mvc.MvcHandler.EndProcessRequest(IAsyncResult asyncResult)
at System.Web.HttpApplication.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute()
at System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously)

Dacpac report Task - Cannot find path because it does not exist

I am copying my dacpac to stagingdirectory/dacpac and publishing it as artifact in build definition.

Screenshot of task

https://drive.google.com/file/d/0B9i7hBHv-vrtVVFmMUtCVll2NWM/view?usp=sharing

Logs

Line 1 : 2016-08-20T10:43:33.3657395Z ##[debug]Using sqlPackage path C:\Program Files (x86)\Microsoft Visual Studio 14.0\Common7\IDE\Extensions\Microsoft\SQLDB\DAC\130\SqlPackage.exe

2: 2016-08-20T10:43:33.5615345Z ##[debug]Found build @{_links=; plans=System.Object[]; id=186; buildNumber=20160820.11; status=completed; result=succeeded; queueTime=2016-08-20T10:25:59.5985544Z; startTime=2016-08-20T10:26:02.559936Z; finishTime=2016-08-20T10:30:02.6561743Z; url=https://agileguru.visualstudio.com/07aab20c-d4f0-4164-a801-ff94df9636fc/_apis/build/Builds/186; definition=; buildNumberRevision=11; project=; uri=vstfs:///Build/Build/186; sourceBranch=refs/heads/Dev; sourceVersion=7ce7fe2005ad99e3195ec2cbf4cfdb4aad07eac9; queue=; priority=normal; reason=manual; requestedFor=; requestedBy=; lastChangedDate=2016-08-20T10:30:04.367Z; lastChangedBy=; parameters={"system.debug":"false","BuildConfiguration":"release","BuildPlatform":"any cpu"}; orchestrationPlan=; logs=; repository=; keepForever=False; retainedByRelease=False} for compare

3: 2016-08-20T10:43:33.6235342Z ##[debug]Downloading drop https://agileguru.visualstudio.com/07aab20c-d4f0-4164-a801-ff94df9636fc/_apis/build/builds/186/artifacts?artifactName=Dacpac&%24format=zip

4:2016-08-20T10:43:45.8649529Z ##[debug]Expand-Archive does not exist. Using System.IO.Compression.ZipFile

**5:**2016-08-20T10:43:46.0269528Z ##[error]Cannot find path 'C:\LR\MMS\Services\Mms\TaskAgentProvisioner\Tools\agents\1.104.1\tasks\DacPacReport\0.0.1\SourceDrop' because it does not exist.

Version Assemblies: DIfferent versions types & different version source

Hi!

I'm going to implement some additional functionality in your script and was wondering if you were interested. If you are, I'll make a pull request. It probably does not really fit within the scope of the task, but I figured I could at least ask.

I'm going to add the following things:
-Specify a version source.
This means that the build task has an extra input field that specifies what version value will be used. Default value can be $(Build.BuildNumber) to make sure the task uses the same values it currently does.
-Different versions for different assembly attributes.
This adds to the previous addition. Instead of a single field, there will be 3: AssemblyVersion, AssemblyFileVersion and AssemblyInformationVersion. Especially handy with libraries, because AssemblyVersion should only be updated for breaking changes and AssemblyFileVersion is updated for every build.

Let me know! :)

TokenReplace on Web.Config

Hi,

Maybe I've misunderstood how this is supposed to work so let me explain....

I am using the TokenReplace task to replace some tokens in my web.config file before deployment (TFS 2015 Release Defintion).

The TokenReplace task produces the error:

[error]Could not find files with glob [\\sevstfs\_work\2\a\_PublishedWebsites\Starlight\*.config].

However, I have confirmed that the file is and was, there.

My Environment variables in the definition are: image

And my web.config tokens are here:
image

Not sure if it is because I cannot use the web.config or whether it's something else.

Any help appreciated.

thanks,

KS

Missing vso-task-lib running in VSTS Release Management

I'm using the ReplaceTokens task in a simple release definition in VSTS. It's configured exactly as the task's readme describes.

I receive the following log output which complains of a missing vso-task-lib. I've seen (but not used) a vsts-task-lib and was wondering if that is the library tasks should consume now? If so can we get a new extension deployed to VSTS soonish?

Log output:
2016-02-04T21:46:03.7720831Z Set workingFolder to default: C:\LR\MMS\Services\Mms\TaskAgentProvisioner\Tools\agents\default\tasks\ReplaceTokens\0.0.3 2016-02-04T21:46:06.6180311Z module.js:338 2016-02-04T21:46:06.6180311Z throw err; 2016-02-04T21:46:06.6180311Z ^ 2016-02-04T21:46:06.6180311Z Error: Cannot find module 'vso-task-lib' 2016-02-04T21:46:06.6180311Z at Function.Module._resolveFilename (module.js:336:15) 2016-02-04T21:46:06.6180311Z at Function.Module._load (module.js:278:25) 2016-02-04T21:46:06.6180311Z at Module.require (module.js:365:17) 2016-02-04T21:46:06.6180311Z at require (module.js:384:17) 2016-02-04T21:46:06.6180311Z at Object.<anonymous> (C:\LR\MMS\Services\Mms\TaskAgentProvisioner\Tools\agents\default\tasks\ReplaceTokens\0.0.3\replaceTokens.js:1:72) 2016-02-04T21:46:06.6180311Z at Module._compile (module.js:460:26) 2016-02-04T21:46:06.6180311Z at Object.Module._extensions..js (module.js:478:10) 2016-02-04T21:46:06.6180311Z at Module.load (module.js:355:32) 2016-02-04T21:46:06.6180311Z at Function.Module._load (module.js:310:12) 2016-02-04T21:46:06.6180311Z at Function.Module.runMain (module.js:501:10)

ReplaceTokens: Secret tokens with semicolon

I'm using the Replace Tokens task to update the web.config on different environments. Because we uses Oracle we have several database connection strings in our Web.config. I want to replace them on every environment, but not showing the connection string in release manager variables.

So I uses secret tokens, but the replace tokens task doesn't likes the semicolon in the database connection string and stops after one semicolon. Is it possible to change the key/value pair delimiter to one that doesn't interfere with the value in the secret token or is there a way to escape the semicolon in the value?

TokenReplace: Cannot replace a token with an empty value

When running the replace tokens task, if a release variable exists, but is an empty string, the token replace fails. Some of our environments have configuration values that are not required, but are required in others, so we leave the value blank.

Recursive file search

Hi.

I have problem to handle this situation.
When i building solution i use buildNumber as folder name so i have structure like this:

drop\Folder\Folder_{XXX}\app.config
Where XX is dynamic numbering.

When i am releasing i am using your task to replace tokens. I do not know how to navigate to 'Folder_XX'
Please can you implement scenario to set start folder (current example drop\Folder) from where will token replacer search all files defined in box 'Target file pattern'

Thanks for your help.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.