Closed jdshkolnik closed 7 years ago
Hi @jdshkolnik,
Our xml patch task uses XPath to select nodes so you can use tests:
= /items/item[@id='a1']/@something => "true"
Hi @sandorfr,
How to make it look in all subfolders for a target file? If I just put web.config it looks only in root.
In that case you have to use the minimatch and globing syntax. Basically if you want to match all web.config in the hierarchy, you must use:
**/web.config
I can't get this to work. It errors out and it also seems to be hitting 47225 matches. I want to look in every web.config file for a particular connection string (the one named "db" so I can change the value. The web.config xml looks something like this:
<configuration>
<connectionStrings>
<add name="db" connectionString="Data Source=local_dev;Database=Internal_DEV;Type System Version=SQL Server 2012;User ID=someone;Password=something;Persist Security Info=True" providerName="System.Data.SqlClient" />
<add name="example" connectionString="Data Source=xx;Database=xx;Type System Version=SQL Server 2012;User ID=xx;Password=xx;Persist Security Info=True" providerName="System.Data.SqlClient" />
</connectionStrings>
The patch build task is set to:
Target files
**/web.config
Patch content
= /configuration/connectionStrings/add[@name='db']/@connectionString => "Data Source=$(TargetDatabaseServer.Name);Database=$(Solvas.DatabaseName)$(UniqueAppend);User ID=$(DefaultLogin);Password=$(DefaultPassword);Type System Version=SQL Server 2012;Persist Security Info=True"
The build task log shows this:
2017-03-15T00:55:43.4149958Z ##[section]Starting: Update web.config connection 2017-03-15T00:55:43.4189958Z ============================================================================== 2017-03-15T00:55:43.4189958Z Task : Patch XML Files 2017-03-15T00:55:43.4189958Z Description : Patch XML files using XPath and JSON patch syntaxes 2017-03-15T00:55:43.4189958Z Version : 1.2.1999 2017-03-15T00:55:43.4199958Z Author : Geek Learning 2017-03-15T00:55:43.4199958Z Help : More Information (Version 1.2.1999) 2017-03-15T00:55:43.4199958Z ============================================================================== 2017-03-15T00:55:43.7189958Z ##[debug]agent.workFolder=I:\Agent_work 2017-03-15T00:55:43.7229958Z ##[debug]loading inputs and endpoints 2017-03-15T00:55:43.7239958Z ##[debug]loading ENDPOINTAUTH$/ 2017-03-15T00:55:43.7279958Z ##[debug]loading ENDPOINT_AUTHPARAMETER$/_ACCESSTOKEN 2017-03-15T00:55:43.7289958Z ##[debug]loading ENDPOINT_AUTH_PARAMETER_SYSTEMVSSCONNECTION_ACCESSTOKEN 2017-03-15T00:55:43.7289958Z ##[debug]loading ENDPOINT_AUTHSCHEME$/ 2017-03-15T00:55:43.7299958Z ##[debug]loading ENDPOINT_AUTH_SCHEME_SYSTEMVSSCONNECTION 2017-03-15T00:55:43.7299958Z ##[debug]loading ENDPOINT_AUTH_SYSTEMVSSCONNECTION 2017-03-15T00:55:43.7309958Z ##[debug]loading INPUT_JSONPATCHCONTENT 2017-03-15T00:55:43.7309958Z ##[debug]loading INPUT_OUTPUTPATCHFILE 2017-03-15T00:55:43.7309958Z ##[debug]loading INPUT_SYNTAXTYPE 2017-03-15T00:55:43.7319958Z ##[debug]loading INPUT_XMLTARGETFILTERS 2017-03-15T00:55:43.7319958Z ##[debug]loading INPUT_XMLWORKINGDIR 2017-03-15T00:55:43.7319958Z ##[debug]loading SECRET_SERVICEACCOUNTPASSWORD 2017-03-15T00:55:43.7329958Z ##[debug]loading SECRET_SQLPASSWORD 2017-03-15T00:55:43.7329958Z ##[debug]loaded 13 2017-03-15T00:55:43.9069958Z ##[debug]XmlWorkingDir=I:\Agent_work\3\s\Src 2017-03-15T00:55:43.9079958Z ##[debug]JsonPatchContent== /configuration/connectionStrings/add[@name='db']/@connectionString => "Data Source=somewhere;Database=Internal_84893_build9524;User ID=someone;Password=something;Type System Version=SQL Server 2012;Persist Security Info=True" 2017-03-15T00:55:43.9079958Z ##[debug]OutputPatchFile=true 2017-03-15T00:55:43.9079958Z ##[debug]SyntaxType=slick 2017-03-15T00:55:43.9089958Z ##[debug]XmlTargetFilters=**/web.config 2017-03-15T00:55:43.9089958Z ##[debug]Namespaces=null 2017-03-15T00:55:49.5099958Z ##[debug]find I:\Agent_work\3\s\Src 2017-03-15T00:55:49.5099958Z ##[debug]47225 matches. 2017-03-15T00:55:50.1779958Z /configuration/connectionStrings/add[@name='db']/@connectionString was not found 2017-03-15T00:55:50.1779958Z Error: Failed to patch xml file 2017-03-15T00:55:50.1779958Z ##[debug]task result: Failed 2017-03-15T00:55:50.1849958Z ##[error]Error: Failed to patch xml file 2017-03-15T00:55:50.1849958Z ##[debug]Processed: ##vso[task.issue type=error;]Error: Failed to patch xml file 2017-03-15T00:55:50.1849958Z ##[debug]Processed: ##vso[task.complete result=Failed;]Error: Failed to patch xml file 2017-03-15T00:55:50.1959958Z ##[section]Finishing: Update web.config connection
The bad news is that there is no such thing as optional patch line. So if the node is not found the patch will fail.
That said, we had plans to enable the test
before apply
feature which would consist of testing if a patch can be applied before applying it and therefore just log a warning if the test fails. I think this could resolve your issue.
If think the 47225 match is misleading and just counts the number of files which are used as the input for the minimatch filter, I have to improve the debug logs anyway #19, so I'll look into it.
Thanks. A replace shouldn't fail if it doesn't find a match for replacement.
Is there a way to do this with the standard syntax? What is considered standard?
Well, the task is based on JsonPatch spec and if the parent node does not exist it should fail. In your case the parent node (add matching the test expression) does not exist, so it fails.
Le mer. 15 mars 2017 à 14:22, John D. Shkolnik notifications@github.com a écrit :
Thanks. A replace shouldn't fail if it doesn't find a match for replacement.
— You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub https://github.com/geeklearningio/gl-vsts-tasks-file-patch/issues/22#issuecomment-286630143, or mute the thread https://github.com/notifications/unsubscribe-auth/ACiXplglkyxq2G2yUsh5eZ1gjsDG3-mGks5rl1mAgaJpZM4MdUth .
I'm unfamiliar with JsonPatch but, in my opinion, the spec is flawed if that's the case. In just about every language I can think of, the expected behavior for a replace is "if exists".
There are lots of different use case and I don't think judging it's flawed in one single use case is not relevant. There case where silently adding a node would lead to an incomplete node when the patch has been written with node existence in mind. The last thing I want is arguing about the RFC (see Replace Definition), and I want to stick to it as close as possible to provide a consistent and predictable behaviour over our various tasks.
That said, I think we can improve our task in a way which will be compatible with your use case. I believe that a test operation on the existence of the connection string will safely guard against patching wrong web.config and that an option to skip files where patch cannot be applied would be need.
What do you think of this? see #24
How would this test be implemented? A checkbox input field which allows us to choose whether it's treated as error or warning?
Yes that would be it. And an additional checkbox to make the task fail if no file is patched.
Sounds reasonable to me; thanks.
FYI, those improvements have been released
Thank you.
@sandorfr It's not throwing an error but it's not finding matches which I know are there. It doesn't even seem to attempt the second patch. I have a web.config which looks like this (I left out a bunch of elements):
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<connectionStrings>
<add name="db" connectionString="Data Source=local_dev;Database=Internal_DEV;Type System Version=SQL Server 2012;User ID=someone;Password=something;Persist Security Info=True" providerName="System.Data.SqlClient" />
<add name="example" connectionString="Data Source=xx;Database=xx;Type System Version=SQL Server 2012;User ID=xx;Password=xx;Persist Security Info=True" providerName="System.Data.SqlClient" />
</connectionStrings>
<appSettings>
<!-- Specify a super user name, for example
<add key="SuperUser" value="US\jshkolnik" />
-->
<add key="SuperUser" value="" />
</appSettings>
</configuration>
My XML patch task looks like this:
Build log:
Attempt to patch 2files
Attempt patching file : I:\Agent_work\3\s\Src\App.Js\web.config
/configuration/appSettings/add[@key='SuperUser']/@value was not found
Couldn't apply patch to file: I:\Agent_work\3\s\Src\App.Js\web.config
Processed: ##vso[task.issue type=warning;]Couldn't apply patch to file: I:\Agent_work\3\s\Src\App.Js\web.config
Error: Failed to patch xml file
Attempt patching file : I:\Agent_work\3\s\Src\Beta.Js\test\web.config
/configuration/appSettings/add[@key='SuperUser']/@value was not found
Couldn't apply patch to file: I:\Agent_work\3\s\Src\Beta.Js\test\web.config
Processed: ##vso[task.issue type=warning;]Couldn't apply patch to file: I:\Agent_work\3\s\Src\Beta.Js\test\web.config
Error: Failed to patch xml file
0 files patched successfully and 2 errors.
@jdshkolnik I'm sorry but I can't reproduce your issue. I even have added a test for it.
I have one idea about a possible cause for such error. You may have the configuration namespace set in your files (something like xmlns="http://schemas.microsoft.com/.NetConfiguration/v2.0"
). I think it might happen if you have things like Web.Config transforms.
If that's the case, you need to specify the namespace in the namespace map c => http://schemas.microsoft.com/.NetConfiguration/v2.0
and use it in your xpath selector /c:configuration/c:appSettings/c:add[@key='SuperUser']/@value
.
@sandorfr It works on a VSTS hosted agent but not on a private agent even when they're the same version. Is your task depending on something which might not be installed on my servers? It's not even doing the output log.
Below is my web.config file:
<?xml version="1.0" encoding="utf-8"?>
<!-- Uncomment the elmah section at the end of the file turn on ELMAH error logging -->
<!--
For more information on how to configure your ASP.NET application, please visit
http://go.microsoft.com/fwlink/?LinkId=152368
-->
<configuration>
<configSections>
<sectionGroup name="elmah">
<section name="security" requirePermission="false" type="Elmah.SecuritySectionHandler, Elmah" />
<section name="errorLog" requirePermission="false" type="Elmah.ErrorLogSectionHandler, Elmah" />
<section name="errorMail" requirePermission="false" type="Elmah.ErrorMailSectionHandler, Elmah" />
<section name="errorFilter" requirePermission="false" type="Elmah.ErrorFilterSectionHandler, Elmah" />
</sectionGroup>
<section name="rewriter" requirePermission="false" type="Intelligencia.UrlRewriter.Configuration.RewriterConfigurationSectionHandler, Intelligencia.UrlRewriter" />
</configSections>
<connectionStrings>
<add name="db" connectionString="Data Source=local_dev;Database=Internal_DEV;Type System Version=SQL Server 2012;User ID=someone;Password=something;Persist Security Info=True" providerName="System.Data.SqlClient" />
<add name="example" connectionString="Data Source=xx;Database=xx;Type System Version=SQL Server 2012;User ID=xx;Password=xx;Persist Security Info=True" providerName="System.Data.SqlClient" />
</connectionStrings>
<appSettings>
<add key="EnableCache" value="true" />
<add key="webpages:Version" value="1.0.0.0" />
<add key="ClientValidationEnabled" value="true" />
<add key="UnobtrusiveJavaScriptEnabled" value="true" />
<!-- Comet applicaiton Id, used to identify each application in a load balancing scenario -->
<add key="CometApplicationId" value="comet_application_1" />
<add key="ConnectionTimeout" value="0" />
<add key="ExcelExportTimeout" value="1200" />
<!-- Specify a super user name, for example
<add key="SuperUser" value="domain\user" />
-->
<add key="SuperUser" value="" />
<!--
When set to true the middle tier reflects on the stored procedures by querying system tables.
When set to false the middle tier reflects on the stored procecures by querying tables populated during post-deployment.
Set to false when shipping in production.
-->
<add key="SystemTableReflectionEnabled" value="true" />
<!--
Current supported versions are 4.2.2 and 6.0.1.
-->
<add key="ExtJsVersion" value="4.2.2" />
<!--
Ext JS theme. Spported themese are classic (4.2.2 and 6.0.1), gray (4.2.2 only), neptune (4.2.2 and 6.0.1), triton (6.0.1 only), and deloitte (6.0.1 only).
-->
<add key="ExtJsTheme" value="classic" />
</appSettings>
<system.web>
<!--
Pin down the middle-tier culture to en-US to avoid conversion errors when
transforming XML data obtained from SQL Server into JSON data to be sent to the front-end.
-->
<globalization culture="en-US" uiCulture="" />
<!-- Turn on custom MVC errors -->
<!-- Not used yet, but turned on to make sure custom errors work with Elmah -->
<customErrors mode="RemoteOnly" />
<httpRuntime maxRequestLength="20480" maxQueryStringLength="20480" delayNotificationTimeout="30" />
<compilation debug="true" targetFramework="4.0">
<assemblies>
<add assembly="System.Web.Abstractions, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />
<add assembly="System.Web.Helpers, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />
<add assembly="System.Web.Routing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />
<add assembly="System.Web.Mvc, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />
<add assembly="System.Web.WebPages, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />
</assemblies>
</compilation>
<!--
<authentication mode="Forms">
<forms loginUrl="~/Account/LogOn" timeout="2880" />
</authentication>
-->
<authentication mode="Windows"></authentication>
<!-- Force the user to be authenticated -->
<authorization>
<deny users="?" />
</authorization>
<pages>
<namespaces>
<add namespace="System.Web.Helpers" />
<add namespace="System.Web.Mvc" />
<add namespace="System.Web.Mvc.Ajax" />
<add namespace="System.Web.Mvc.Html" />
<add namespace="System.Web.Routing" />
<add namespace="System.Web.WebPages" />
</namespaces>
</pages>
<httpModules>
<add name="UrlRewriter" type="Intelligencia.UrlRewriter.RewriterHttpModule, Intelligencia.UrlRewriter" />
<add name="ErrorLog" type="Elmah.ErrorLogModule, Elmah" />
<add name="ErrorMail" type="Elmah.ErrorMailModule, Elmah" />
<add name="ErrorFilter" type="Elmah.ErrorFilterModule, Elmah" />
</httpModules>
<httpHandlers>
<add verb="POST,GET,HEAD" path="elmah.axd" type="Elmah.ErrorLogPageFactory, Elmah" />
</httpHandlers>
</system.web>
<!-- IIS Configuration -->
<system.webServer>
<validation validateIntegratedModeConfiguration="false" />
<modules runAllManagedModulesForAllRequests="true">
<add name="UrlRewriter" type="Intelligencia.UrlRewriter.RewriterHttpModule" />
<add name="ErrorLog" type="Elmah.ErrorLogModule, Elmah" preCondition="managedHandler" />
<add name="ErrorMail" type="Elmah.ErrorMailModule, Elmah" preCondition="managedHandler" />
<add name="ErrorFilter" type="Elmah.ErrorFilterModule, Elmah" preCondition="managedHandler" />
<remove name="WebDAVModule" />
</modules>
<handlers>
<add name="Elmah" path="elmah.axd" verb="POST,GET,HEAD" type="Elmah.ErrorLogPageFactory, Elmah" preCondition="integratedMode" />
<remove name="WebDAV" />
</handlers>
<!-- Force Internet Explorer to latest HTML standards -->
<httpProtocol>
<customHeaders>
<add name="X-UA-Compatible" value="IE=edge" />
</customHeaders>
</httpProtocol>
</system.webServer>
<runtime>
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
<dependentAssembly>
<assemblyIdentity name="System.Web.Mvc" publicKeyToken="31bf3856ad364e35" />
<bindingRedirect oldVersion="0.0.0.0-3.0.0.1" newVersion="3.0.0.1" />
</dependentAssembly>
</assemblyBinding>
</runtime>
<elmah>
<!-- Uncomment the following line to turn on ELMAH -->
<errorLog type="Elmah.XmlFileErrorLog, Elmah" logPath="~/App_Data/Error_Log" />
<security allowRemoteAccess="yes" />
</elmah>
<rewriter>
<!-- Rewrite URL's which are of the form http://host/db/{database_code}/... -->
<!-- The following rewriter rule will remove the db/{database_code}/ part
and will put the database_code in the HttpContext's Items under key "Rewriter.target_db_code" -->
<if url="~/db/(\w+)/(.*)">
<set property="target_database_code" value="$1" />
<rewrite to="~/$2" />
</if>
</rewriter>
</configuration>
Are you running the new xplat agent, or the legacy one?
When you say you don't have any output log, you mean you have no logs at all (including vsts debug logs)?
Other question do you have node installed on this server and in that case which version? If this is an older version can you consider upgrading to the latest LTS?
This is the agent I'm referring to.
By output log, I mean the web.config content modified by the patch. I noticed it doing that when I tested on hosted agent.
I had node version 4.4.5 which I just upgraded to 6.10.2 and got same result.
There must be something else can you share the debug log of this task in your build?
2017-04-12T00:29:35.7779796Z ##[debug]Evaluating condition for step: 'Update web.config connection'
2017-04-12T00:29:35.7789797Z ##[debug]Evaluating: succeeded()
2017-04-12T00:29:35.7789797Z ##[debug]Evaluating succeeded:
2017-04-12T00:29:35.7789797Z ##[debug]=> (Boolean) True
2017-04-12T00:29:35.7789797Z ##[debug]Expanded: True
2017-04-12T00:29:35.7789797Z ##[debug]Result: True
2017-04-12T00:29:35.7789797Z ##[section]Starting: Update web.config connection
2017-04-12T00:29:35.7899808Z ==============================================================================
2017-04-12T00:29:35.7909809Z Task : Patch XML Files
2017-04-12T00:29:35.7909809Z Description : Patch XML files using XPath and JSON patch syntaxes
2017-04-12T00:29:35.7909809Z Version : 1.2.2007
2017-04-12T00:29:35.7909809Z Author : Geek Learning
2017-04-12T00:29:35.7909809Z Help : [More Information](https://github.com/geeklearningio/gl-vsts-tasks-file-patch/wiki/Patch-XML-Files) (Version 1.2.2007)
2017-04-12T00:29:35.7909809Z ==============================================================================
2017-04-12T00:29:36.1130131Z ##[debug]agent.workFolder=I:\Agent\_work
2017-04-12T00:29:36.1130131Z ##[debug]loading inputs and endpoints
2017-04-12T00:29:36.1130131Z ##[debug]loading ENDPOINT_AUTH_$/
2017-04-12T00:29:36.1160134Z ##[debug]loading ENDPOINT_AUTH_PARAMETER_$/_ACCESSTOKEN
2017-04-12T00:29:36.1170135Z ##[debug]loading ENDPOINT_AUTH_PARAMETER_SYSTEMVSSCONNECTION_ACCESSTOKEN
2017-04-12T00:29:36.1170135Z ##[debug]loading ENDPOINT_AUTH_SCHEME_$/
2017-04-12T00:29:36.1180136Z ##[debug]loading ENDPOINT_AUTH_SCHEME_SYSTEMVSSCONNECTION
2017-04-12T00:29:36.1180136Z ##[debug]loading ENDPOINT_AUTH_SYSTEMVSSCONNECTION
2017-04-12T00:29:36.1180136Z ##[debug]loading INPUT_FAILIFNOPATCHAPPLIED
2017-04-12T00:29:36.1190137Z ##[debug]loading INPUT_JSONPATCHCONTENT
2017-04-12T00:29:36.1190137Z ##[debug]loading INPUT_OUTPUTPATCHFILE
2017-04-12T00:29:36.1200138Z ##[debug]loading INPUT_SKIPERRORS
2017-04-12T00:29:36.1200138Z ##[debug]loading INPUT_SYNTAXTYPE
2017-04-12T00:29:36.1200138Z ##[debug]loading INPUT_XMLTARGETFILTERS
2017-04-12T00:29:36.1210139Z ##[debug]loading INPUT_XMLWORKINGDIR
2017-04-12T00:29:36.1210139Z ##[debug]loading SECRET_SERVICEACCOUNTPASSWORD
2017-04-12T00:29:36.1220140Z ##[debug]loading SECRET_SQLPASSWORD
2017-04-12T00:29:36.1220140Z ##[debug]loaded 15
2017-04-12T00:29:36.2960314Z ##[debug]XmlWorkingDir=I:\Agent\_work\3\s
2017-04-12T00:29:36.2970315Z ##[debug]JsonPatchContent== /configuration/appSettings/add[@key='SuperUser']/@value => "$env:username"
2017-04-12T00:29:36.2970315Z = /configuration/connectionStrings/add[@name='db']/@connectionString => "Data Source=some_server;Database=Internal_160_86557_build10554;User ID=some_user;Password=some_pw;Type System Version=SQL Server 2012;Persist Security Info=True"
2017-04-12T00:29:36.2970315Z ##[debug]OutputPatchFile=true
2017-04-12T00:29:36.2970315Z ##[debug]FailIfNoPatchApplied=false
2017-04-12T00:29:36.2980316Z ##[debug]SkipErrors=true
2017-04-12T00:29:36.2980316Z ##[debug]SyntaxType=slick
2017-04-12T00:29:36.2980316Z ##[debug]XmlTargetFilters=**\web.config
2017-04-12T00:29:36.2980316Z ##[debug]Namespaces=null
2017-04-12T00:29:36.3010319Z ##[debug]find findPath=I:\Agent\_work\3\s, options=undefined
2017-04-12T00:29:36.3020320Z ##[debug] I:\Agent\_work\3\s (directory)
2017-04-12T00:29:36.3030321Z ##[debug] I:\Agent\_work\3\s\$tf (directory)
2017-04-12T00:29:40.0494067Z ##[debug] I:\Agent\_work\3\s\Src\App.Js\web.config (file)
2017-04-12T00:29:40.3444362Z ##[debug] I:\Agent\_work\3\s\Src\App.Web\Views\Web.config (file)
2017-04-12T00:29:40.3454363Z ##[debug] I:\Agent\_work\3\s\Src\App.Web\Web.config (file)
2017-04-12T00:29:40.6294647Z ##[debug] I:\Agent\_work\3\s\Src\Beachcomber.Js\test\web.config (file)
2017-04-12T00:29:43.0777095Z ##[debug]33083 results
2017-04-12T00:29:43.0777095Z ##[debug]Attempt to patch 2files
2017-04-12T00:29:43.0777095Z ##[debug]Attempt patching file : I:\Agent\_work\3\s\Src\App.Js\web.config
2017-04-12T00:29:43.0777095Z /configuration/appSettings/add[@key='SuperUser']/@value was not found
2017-04-12T00:29:43.0837101Z ##[warning]Couldn't apply patch to file: I:\Agent\_work\3\s\Src\App.Js\web.config
2017-04-12T00:29:43.0847102Z ##[debug]Processed: ##vso[task.issue type=warning;]Couldn't apply patch to file: I:\Agent\_work\3\s\Src\App.Js\web.config
2017-04-12T00:29:43.0847102Z ##[debug]Error: Failed to patch xml file
2017-04-12T00:29:43.0847102Z ##[debug]Attempt patching file : I:\Agent\_work\3\s\Src\Beachcomber.Js\test\web.config
2017-04-12T00:29:43.0847102Z /configuration/appSettings/add[@key='SuperUser']/@value was not found
2017-04-12T00:29:43.0847102Z ##[warning]Couldn't apply patch to file: I:\Agent\_work\3\s\Src\Beachcomber.Js\test\web.config
2017-04-12T00:29:43.0847102Z ##[debug]Processed: ##vso[task.issue type=warning;]Couldn't apply patch to file: I:\Agent\_work\3\s\Src\Beachcomber.Js\test\web.config
2017-04-12T00:29:43.0857103Z ##[debug]Error: Failed to patch xml file
2017-04-12T00:29:43.0857103Z ##[debug]0 files patched successfully and 2 errors.
2017-04-12T00:29:43.0857103Z ##[debug]task result: Succeeded
2017-04-12T00:29:43.0877105Z ##[debug]Processed: ##vso[task.complete result=Succeeded;]Files Patched
2017-04-12T00:29:43.0877105Z ##[section]Finishing: Update web.config connection
Are you using git or tfsvc?
In this example it's TFVC.
regarding the latest issue I wonder if it would be related/fixed by https://github.com/geeklearningio/gl-vsts-tasks-file-patch/issues/20 . TFVC marks files as readonly which is really annoying.
@sandorfr Still failing as of v2.0.1002.
@jdshkolnik is there a blank line between your patch lines?
Oh I've found your problem it's not the blank line (It's supported), it's the case sensitiveness of file path !
Please try **/[wW]eb.config
I'll consider adding an option #22
That did the trick although "$env:username" didn't resolve. Any idea how to get that in there?
I'm not sure, but this the not look like a VSTS build variable which should be in the $(variableName) form if you are trying to pull an environment variable you can try $(username). You may want to check VSTS documentation
If you look at that VSTS documentation you just linked, the format for "Environment variable in PowerShell scripts" shows as "$env:BUILD_DEFINITIONNAME".
ah yes for powershell scripts :) this is not powershell scripts :)
If username
is one of your build variables you want to use $(username)
.
It's not a build variable known in advance. It's the service username running the build at that moment.
As I said, this is a VSTS build task, not a powershell script so this is beyond our scope. That said in the documentation I linked they explain how to set a vsts build variable from a powershell script. You can add a powershell step to hydrate a build variable Write-Host "##vso[task.setvariable variable=AgentUserName]$env:username"
.
All VSTS build tasks are either PowerShell or TypeScript and yours is obviously the latter. Hydrating a new variable is a good suggestion; I'll give it a shot. Thanks.
Yes, but even if it's a powershell based task, inputs and variables are coming from the build agent ;) which does not understand powershell syntax.
How would I set something to true for just a1 using slick syntax?