Release management server succeeds manual, but fails automated - visual-studio-2013

I'm trying to configure release management server to deploy to out test server when a specific build configuration on TFS succeeds. Now I have a build definition which runs fine, I use the build process template 'ReleaseTfvcTemplate.12.xaml'.
The 'Release Template' in Release Management Server (RMS) is set to trigger on build.
Now when I set the 'Release Build' property in the Release category to 'False', the build runs fine. Then when I go the Release Management Client and create a release, everything goes fine and my project (a WebAPI) is succesfully published to our testserver.
As soon as I set the 'Release build' property to true (in the build definition) and queue a new build, the build fails.
I receive the following error :
Exception Message: The directory name is invalid (type Win32Exception)
Exception Stack Trace: Server stack trace: at
System.Diagnostics.Process.StartWithCreateProcess(ProcessStartInfo
startInfo) at
Microsoft.TeamFoundation.Build.Workflow.Activities.InvokeProcess.ProcessWrapper.Start()
at
Microsoft.TeamFoundation.Build.Workflow.Activities.InvokeProcess.InvokeProcessInternal.RunCommand(AsyncState
state) at
System.Runtime.Remoting.Messaging.StackBuilderSink._PrivateProcessMessage(IntPtr
md, Object[] args, Object server, Object[]& outArgs) at
System.Runtime.Remoting.Messaging.StackBuilderSink.AsyncProcessMessage(IMessage
msg, IMessageSink replySink)
Exception rethrown at [0]: at
System.Runtime.Remoting.Proxies.RealProxy.EndInvokeHelper(Message
reqMsg, Boolean bProxyCase) at
System.Runtime.Remoting.Proxies.RemotingProxy.Invoke(Object NotUsed,
MessageData& msgData) at System.Func2.EndInvoke(IAsyncResult
result) at
System.Activities.AsyncCodeActivity1.System.Activities.IAsyncCodeActivity.FinishExecution(AsyncCodeActivityContext
context, IAsyncResult result) at
System.Activities.AsyncCodeActivity.CompleteAsyncCodeActivityData.CompleteAsyncCodeActivityWorkItem.Execute(ActivityExecutor
executor, BookmarkManager bookmarkManager)
The build template includes a xcopy step which may cause the "The directory name is invalid", but I don't understand why the process works manually, but not automated.
Any suggestions in the right direction are very welcome!

Make sure you have a RM Client install on the build agent machine.

Sometimes the release template can 'lose' its connection in to the build definition. To check this open the release template and use the Properties link to re-establish the connection to the build definition. In case it helps I have a soup to nuts blog post series on configuring all this - index page here.

Related

SonarQube MSBuild End Analysis Failure - Expected X to be a parent of Y

I am encountering the following error on the SonarQube Scanner for MSBuild - End Analysis build task in Visual Studio Team Services.
2017-06-12T14:35:00.1131070Z SonarQube found 7 issues out of which 1 are new
2017-06-12T14:35:00.1131070Z
2017-06-12T14:35:00.1443593Z
2017-06-12T14:35:00.1599853Z ##[error]System.Management.Automation.RuntimeException: Internal Error: expected E:\\CI02\16\s to be a parent of E:\CI02\16\s\path\to\my\file.cs ---> System.Management.Automation.RuntimeException: Internal Error: expected E:\\CI02\16\s to be a parent of E:\CI02\16\s\path\to\my\file.cs
2017-06-12T14:35:00.1599853Z --- End of inner exception stack trace ---
2017-06-12T14:35:00.1599853Z at System.Management.Automation.Runspaces.PipelineBase.Invoke(IEnumerable input)
2017-06-12T14:35:00.1599853Z at System.Management.Automation.PowerShell.Worker.ConstructPipelineAndDoWork(Runspace rs, Boolean performSyncInvoke)
2017-06-12T14:35:00.1599853Z at System.Management.Automation.PowerShell.Worker.CreateRunspaceIfNeededAndDoWork(Runspace rsToUse, Boolean isSync)
2017-06-12T14:35:00.1599853Z at System.Management.Automation.PowerShell.CoreInvokeHelper[TInput,TOutput](PSDataCollection`1 input, PSDataCollection`1 output, PSInvocationSettings settings)
2017-06-12T14:35:00.1599853Z at System.Management.Automation.PowerShell.CoreInvoke[TInput,TOutput](PSDataCollection`1 input, PSDataCollection`1 output, PSInvocationSettings settings)
2017-06-12T14:35:00.1599853Z at Microsoft.TeamFoundation.DistributedTask.Handlers.LegacyVSTSPowerShellHost.VSTSPowerShellHost.Main(String[] args)
2017-06-12T14:35:00.1756102Z ##[error]LegacyVSTSPowerShellHost.exe completed with return code: -1.
2017-06-12T14:35:00.1756102Z ##[section]Finishing: Complete the SonarQube analysis
As you can see from the logs it is failing because E:\\CI02\16\s is not a parent of E:\CI02\16\s\path\to\my\file.cs (note the different number of backslashes after E:).
From looking at the build task's source code I can see that it is expecting the the file path to start with the value of the Build.Repository.LocalPath task context variable. I can't see why there is a difference in the number of slashes though.
This only occurrs when the build is triggered from a pull request. If I queue the build manually it succeeds without issue.
I am using version 2.1.2 of SonarQube for Team Services.
Does anyone know a way around this issue or have any suggestions?
The issue resolved itself. I retriggered the build from a pull request the next morning and it succeeded without issue.

sonar qube begin task failing - Unexpected exit code received from batch file: -532462766

I m getting below error while starting sonar analysis in tfs build task.
Please Help !
*************************************************************************
Starting task: Fetch the Quality Profile from SonarQube
******************************************************************************
Executing the powershell script:
D:\kannappan_sonar\tasks\SonarQubePreBuild\1.0.35\SonarQubePreBuild.ps1 SonarQube Scanner for MSBuild 1.1
Default properties file was found at D:\kannappan_sonar\tasks\SonarQubePreBuild\1.0.35\MSBuild.SonarQube.Runner-1.1\SonarQube.Analysis.xml
Loading analysis properties from D:\kannappan_sonar\tasks\SonarQubePreBuild\1.0.35\MSBuild.SonarQube.Runner-1.1\SonarQube.Analysis.xml
Pre-processing started.
Preparing working directories...
Checking for updates...
Unhandled Exception: System.Net.WebException: The remote server returned an error: (401) Unauthorized.
at System.Net.WebClient.DownloadDataInternal(Uri address, WebRequest& request)
at System.Net.WebClient.DownloadString(Uri address)
at System.Net.WebClient.DownloadString(String address)
at SonarQube.TeamBuild.PreProcessor.WebClientDownloader.Download(String url)
at SonarQube.TeamBuild.PreProcessor.SonarWebService.GetProperties(String projectKey, String projectBranch)
at SonarQube.TeamBuild.PreProcessor.TeamBuildPreProcessor.FetchArgumentsAndRulesets(ISonarQubeServer server, ProcessedArgs args, TeamBuildSettings settings, IDictionary`2& serverSettings, List`1& analyzersSettings)
at SonarQube.TeamBuild.PreProcessor.TeamBuildPreProcessor.DoExecute(ProcessedArgs args)
at SonarQube.TeamBuild.PreProcessor.TeamBuildPreProcessor.Execute(String[] args)
at SonarQube.TeamBuild.PreProcessor.Program.Main(String[] args) SonarQube Scanner for MSBuild Begin Step 2.2 18:11:45.209 Loading analysis properties from D:\kannappan_sonar\tasks\SonarQubePreBuild\1.0.35\MSBuild.SonarQube.Runner-1.1\SonarQube.Analysis.xml 18:11:45.271 Updating build integration targets... 18:11:45.286 Fetching analysis configuration settings... Pre-processing succeeded.
Unexpected exit code received from batch file: -532462766
The crux of this error is: The remote server returned an error: (401) Unauthorized
It is likely that you're trying to analyze a project on which the permissions have been restricted. In both the begin and end steps, you'll need to pass an analysis token from an account with permissions to analyze the project.

TFS Error Publishing Log Files to non existent directory

My Build Server has been running just fine for a couple months and then this week we started getting this problem (see below).
It's almost certainly a permission problem, but no one in IT will admit to having changed a permission somewhere.
Also, it's trying to publish a log file to a location that doesn't exist!
to '#/416/logs/msbuild/agent-2'
If I knew where this location was, I would happily fix it or turn this specific publish off. All the other logs are present and accessible (obviously I'm able to view the log of these errors).
using Visual Studio 2013 & TFS2013.
This is the same issue, but changing the drop folders didn't fix it:
TFS Error publishing log files to #/198/logs/msbuild/agent-2
Other Errors and Warnings
3 error(s), 0 warning(s)
Exception Message: TF270016: An error occurred publishing log files from
'C:\Builds\2\AppName\AppName\src\AppName\AppName.log'
to '#/416/logs/msbuild/agent-2'. Details: An error occurred while
sending the request. (type PublishLogFileException) Exception Stack
Trace: at
System.Activities.Statements.Throw.Execute(CodeActivityContext
context) at
System.Activities.CodeActivity.InternalExecute(ActivityInstance
instance, ActivityExecutor executor, BookmarkManager bookmarkManager)
at
System.Activities.Runtime.ActivityExecutor.ExecuteActivityWorkItem.ExecuteBody(ActivityExecutor
executor, BookmarkManager bookmarkManager, Location resultLocation)
Inner Exception Details:
Exception Message: An error occurred while sending the request. (type
HttpRequestException) Exception Stack Trace: at
Microsoft.TeamFoundation.Build.Workflow.Activities.FileContainerDropProvider.CopyDirectory(String
sourceDirectory, String targetDirectory) at
Microsoft.TeamFoundation.Build.Workflow.Activities.FileContainerDropProvider.CopyDirectory(String
sourceDirectory, String targetDirectory, String[] renameIfExists)
at
Microsoft.TeamFoundation.Build.Workflow.Activities.PublishLogFile.Execute(CodeActivityContext
context)
Inner Exception Details:
Exception Message: Unable to connect to the remote server (type
WebException)Exception Stack Trace: at
System.Net.HttpWebRequest.EndGetResponse(IAsyncResult asyncResult)
at System.Net.Http.HttpClientHandler.GetResponseCallback(IAsyncResult
ar)
Inner Exception Details:
Exception Message: No connection could be made because the target
machine actively refused it [::1]:8080 (type SocketException)
Exception Stack Trace: at
System.Net.Sockets.Socket.EndConnect(IAsyncResult asyncResult) at
System.Net.ServicePoint.ConnectSocketInternal(Boolean connectFailure,
Socket s4, Socket s6, Socket& socket, IPAddress& address,
ConnectSocketState state, IAsyncResult asyncResult, Exception&
exception)
An error occurred while copying diagnostic activity logs
to the drop location. Details: An error occurred while sending the
request.
An error occurred while copying diagnostic activity logs to
the drop location. Details: An error occurred while sending the
request.
Update 12/29/2015
I've been able to confirm with IT that our main TFS instance was updated to 2013 Update 5.
Our build server is running TFS 2013 Update 4. My next priority will be getting the build server updated.
You can try to create a new build agent to see whether the issue persists.
The issue had nothing to do with TFS.
On the build server machine, we had a copy of Visual Studio installed (necessary for MSBuild and MSTest). The license we used had expired, and as a result Visual Studio installed in trial mode.
I don't know why this mattered, but reinstalling Visual Studio using a valid license fixed the issue.

git-tfs returns "(401) unauthorized" error when cloning a repository

I used git-tfs to work with a TFVC repository. I started working on other project and the project's code is hosted on a different server.
Now I get errors when I try to clone the repository.
git tfs clone http://tfs-server:8080/tfs $/CompanyName/Dev
It prompts me to enter the credentials twice. Then it shows an error.
TF30063: You are not authorized to access http://tfs-server:8080/tfs.
The remote server returned an error: (401) Unauthorized.
I've double checked it is a correct url. I can connect with Visual Studio and with a browser.
I've double checked it is a correct password and username. I can log in with this credentials in a browser.
I am able to clone the code from a different server on my machine.
The server is Visual Studio Team Foundation Server 2013. My git-tfs version is
git-tfs version 0.21.0.0 (TFS client library 12.0.0.0 (MS)) (64-bit)
I've found a few questions with a similar error and tried the answers. So these are things I tried to do:
Logging off from this server in Visual Studio's browser;
Cleaning Internet Explorer cache
Deleting C:\Users\UserName\AppData\Local\Microsoft\Team Foundation\5.0\Cache folder;
Adding tfs server to local intranet security zone in Internet Explorer.
This is the debug output:
git tfs clone http://tfs-server:8080/tfs $/CompanyName/Dev --debug
Command run:git tfs clone http://tfs-server:8080/tfs $/CompanyName/Dev --debug
No authors file used.
git-tfs version 0.21.0.0 (TFS client library 12.0.0.0 (MS)) (64-bit)
git command: Starting process: git init
Initialized empty Git repository in C:/Users/UserName/Dev/.git/
git command time: [00:00:00.0660000] init
System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation. ---> Microsoft.TeamFoundation.TeamFoundationServerUnauthorizedException: TF30063: You are not authorized to access http://tfs-server:8080/tfs. ---> System.Net.WebException: The remote server returned an error: (401) Unauthorized.
at System.Net.HttpWebRequest.GetResponse()
at Microsoft.TeamFoundation.Client.Channels.TfsHttpWebRequest.SendRequestAndGetResponse(HttpWebRequest webRequest, WebException& webException)
--- End of inner exception stack trace ---
at Microsoft.TeamFoundation.Client.Channels.TfsHttpWebRequest.ReadResponse(HttpWebResponse webResponse, WebException webException)
at Microsoft.TeamFoundation.Client.Channels.TfsHttpWebRequest.SendRequest()
at Microsoft.TeamFoundation.Client.Channels.TfsHttpRequestChannel.Request(TfsMessage message, TimeSpan timeout)
at Microsoft.TeamFoundation.Client.Channels.TfsHttpClientBase.Invoke(TfsClientOperation operation, Object[] parameters, TimeSpan timeout, Object[]& outputs)
at Microsoft.TeamFoundation.Framework.Client.RegistrationProxy.GetRegistrationEntries(String toolId)
at Microsoft.TeamFoundation.Framework.Client.RegistrationService.GetInstanceId()
at Microsoft.TeamFoundation.Framework.Client.RegistrationService.get_InstanceClientCacheDirectory()
at Microsoft.TeamFoundation.Framework.Client.RegistrationService..ctor(TfsTeamProjectCollection tfsObject)
at Microsoft.TeamFoundation.Client.TfsTeamProjectCollection.CreateServiceProxy(Type serviceType)
at Microsoft.TeamFoundation.Client.TfsConnection.GetService(Type serviceType)
at Microsoft.TeamFoundation.Framework.Client.PreFrameworkServerDataProvider.FindServiceLocation(String serviceType, String toolId)
at Microsoft.TeamFoundation.Framework.Client.PreFrameworkServerDataProvider.LocationForCurrentConnection(String serviceType, Guid serviceIdentifier)
at Microsoft.TeamFoundation.Client.TfsConnection.EnsureProviderConnected()
at Microsoft.TeamFoundation.Client.TfsConnection.EnsureAuthenticated()
at Sep.Git.Tfs.VsCommon.TfsHelperBase.EnsureAuthenticated()
at Sep.Git.Tfs.Core.GitTfsRemote.EnsureTfsAuthenticated()
at Sep.Git.Tfs.Core.GitRepository.CreateTfsRemote(RemoteInfo remote, String autocrlf, String ignorecase)
at Sep.Git.Tfs.Commands.Init.Run(String tfsUrl, String tfsRepositoryPath)
at Sep.Git.Tfs.Commands.Clone.Run(String tfsUrl, String tfsRepositoryPath, String gitRepositoryPath)
--- End of inner exception stack trace ---
at System.RuntimeMethodHandle.InvokeMethod(Object target, Object[] arguments, Signature sig, Boolean constructor)
at System.Reflection.RuntimeMethodInfo.UnsafeInvokeInternal(Object obj, Object[] parameters, Object[] arguments)
at System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture)
at Sep.Git.Tfs.Util.GitTfsCommandRunner.Run(GitTfsCommand command, IList`1 args)
at Sep.Git.Tfs.GitTfs.Main(GitTfsCommand command, IList`1 unparsedArgs)
at Sep.Git.Tfs.Program.Main(String[] args)
TF30063: You are not authorized to access http://tfs-server:8080/tfs.
The remote server returned an error: (401) Unauthorized.
What can I do to get my git-tfs flow back?
I've added collection name to the server's url and it worked.
The correct command was:
git tfs clone http://tfs-server:8080/tfs/collectionName $/CompanyName/Dev
Although the command in the question worked for the previous server.

TFS Error publishing log files to #/198/logs/msbuild/agent-2

I installed TFS 2013 and am having a problem with the build system. I don't use a drop folder, one solution being built, pretty simple config. I am getting the following error which fails the build (some names replaced with AppName to protect the app's identity):
Exception Message: TF270016: An error occurred publishing log files from 'S:\Builds\2\NCSoftware\AppName\src\Solutions\AppName\AppName.log' to '#/198/logs/msbuild/agent-2'. Details: Internal Server Error (type PublishLogFileException) Exception Stack Trace: at System.Activities.Statements.Throw.Execute(CodeActivityContext context) at System.Activities.CodeActivity.InternalExecute(ActivityInstance instance, ActivityExecutor executor, BookmarkManager bookmarkManager) at System.Activities.Runtime.ActivityExecutor.ExecuteActivityWorkItem.ExecuteBody(ActivityExecutor executor, BookmarkManager bookmarkManager, Location resultLocation) Inner Exception Details: Exception Message: Internal Server Error (type VssServiceResponseException) Exception Stack Trace: at Microsoft.TeamFoundation.Build.Workflow.Activities.FileContainerDropProvider.CopyDirectory(String sourceDirectory, String targetDirectory) at Microsoft.TeamFoundation.Build.Workflow.Activities.FileContainerDropProvider.CopyDirectory(String sourceDirectory, String targetDirectory, String[] renameIfExists) at Microsoft.TeamFoundation.Build.Workflow.Activities.PublishLogFile.Execute(CodeActivityContext context)
An error occurred while copying diagnostic activity logs to the drop location. Details: Internal Server Error
An error occurred while copying diagnostic activity logs to the drop location. Details: Internal Server Error
Where is this "#/198/logs/msbuild/agent-2" path that obviously is the cause of this problem?
Thank you.
Check your DropLocation variable in your build template.
Simplest way to find where this path is set is to look into your build template and search for e.g. "log".
In my case I found only one Activity that assigning logs path to variable. Then you can backtrack all variables in your template to original sources of data.
Something like this:
<Assign x:TypeArguments="x:String"
DisplayName="Initialize LogFile Drop Location" To="[logFileDropLocation]"
Value="[If (platformConfiguration.IsEmpty
Or BuildSettings.PlatformConfigurations.Count = 1,
BuildDropProvider.CombinePaths(DropLocation, "logs"), If
(platformConfiguration.IsPlatformEmptyOrAnyCpu,
BuildDropProvider.CombinePaths(DropLocation, "logs",
platformConfiguration.Configuration),
BuildDropProvider.CombinePaths(DropLocation,
"logs", platformConfiguration.Platform,
platformConfiguration.Configuration)))]"
mtbwt:BuildTrackingParticipant.Importance="Low" />

Resources