Determine if workspace exists on build server - msbuild

Is it possible to determine whether a workspace exist on the server given the local path using tf.exe?
This can be done using the TFS API but that would require me to build the task source code before using it which is not possible because I don't have a workspace yet. Checking binaries into source control is not an option.
Any ideas?

If you run the tf.exe workfold command passing in the local directory, it will either return an error if the folder is not mapped, or it will return the workspace information. You can (in a hacky fashion) determine if an error occurred by redirecting the stderr to a text file, then checking to see if the file is empty. For example:
tf.exe workfold c:\some\mapping\folder\path 2> error.txt
You may also be able to check the exit code from the command. Based on research, it looks like the exit code is set to 100 if there's an error. Not sure what you can do in the task, but in a CMD file you can check ERRORLEVEL.
To see this in action, try:
tf.exe workfold "C:\program files" 2> error.txt
echo %ERRORLEVEL%

Related

How do I specify JRE when creating a Bamboo sidekick agent for their per-build-container plug-in?

Trying to get the sidekick image built and having some issues. Is there any documentation other than the README.md file?
My current problem is with getting the JRE requirement working but there are others. The page says "download Oracle JRE and place it inside the working directory. Optionally if you have a company wide distribution url, use that one at a later step." and the help says "Java (JRE) download url or path inside working directory". Have not been able to get this to work.
I went to the JRE link provided and was presented with options to download a rpm file or a tar.gz file. Which is expected (was unable to get either one working)?
It says to place the file in the "working directory" but not sure where exactly. Tried in sidekick folder and in sidekick/jre both without success no matter what I used after the -j command. Is this just the path or should the filename be included as well? Can I get an example?
I'm running this script using my login but noticed the output folder is being created with root user and group. I see no indication that this should be run with sudo. What is the correct way to run this script?
Using debug, I see the function "download if not cached". Can I save these files (JRE, Bamboo jar file, etc.) somewhere so I don't have to worry about downloading them? If so, where should they go? Looks like I might have a problem with the wget to d/l the jar file so would like to just be able to place all these in a folder and be done with it.
It looks like the major problem is the script didn't clean up after itself if it fails. The issue was the first time it failed then that caused subsequent issues as the output folder was already there. Removing this directory between each attempt help.
As for the correct syntax for the -j JRE option I manually downloaded the JRE and placed in a folder called per-build-container/sidekick/stuff/. For the command line it is not just the path but the file name as well (the tar.gz and not the RPM). For my case it was
-j stuff/jre-8u251-linux-x64.tar.gz
Note I also ran the script as sudo. Wasn't stated but seemed to work OK.
Another issue I ran into was the download of the agent jar file. There is a redirect in the wget file that was not working for us. I ended up editing the script and replacing the Altassian based url with the redirected one.
This addresses all the issues I ran into with the initial question.

A plugin to open a terminal in a particular directory selected from the project tree

I use git bash for my terminal configuration and it has --cd option where I can pass the path to open terminal in:
I have pretty deeply nested directory structure and thought it would be very convenient to open terminal in the directory I select in the tree:
Is there a plugin that can do that? If not, how hard will it be to write my own simple plugin?
It will probably be very basic:
read the currently selected folder path
run "open terminal" action supplied the command line string with the concatenated path
Thanks
there are no such plugins, please vote for IDEA-116724 and linked tickets.
You can try opening sh as External tool instead, like:
Program: C:\Windows\System32\cmd.exe
Parameters: /C "start sh.exe"
Working directory: $FileDir$
the only issue is that it will be opened as external window, not inside IDE

Yii2 archive installation symbolic link issue

I am trying to install Yii framework via archive file in Windows 7...after downloading the file I tried extracting it into a folder in my C:\wamp\www\bid location, however, I encounter an error saying this:
! C:\wamp\www\bid\yii-basic-app-2.0.2.tgz: Cannot create symbolic link C:\wamp\www\bid\basic\vendor\bin\markdown
A required privilege is not held by the client.
! C:\wamp\www\bid\yii-basic-app-2.0.2.tgz: Cannot create symbolic link C:\wamp\www\bid\basic\vendor\bin\yii
A required privilege is not held by the client.
I thought that perhaps Winrar can't extract tgz files so I downloaded 7-zip...Using 7-zip it extracted into a tar file and the tar file was extracted with no errors...For some reason though I do not seem to have the framework folder that seem to be in other people's directory structure...Moreover after trying create my own framework folder and performing this command:
yiic webapp C:\wamp\www\bid
It states that yiic is not recognized as an internal or external command
Can someone tell me what I'm doing wrong...I've tried setting this up numerous times and failed
You need to run 7-Zip File Manager in administrator mode.
Right-click the icon of 7-Zip File Manager, and then click "Run as administrator".
you need to call the command with php since it is actually a external command, i do it like this
php ./yiic webapp NameOfApp
This way your terminal understand that yii is a program that runs with php.
Another solution is to add the yii path to your environmental variable, regards

Team City build agent work dir not getting changed

I want to change the build dir of team city build agent to:
E://MY_PROJECT_SVN
While installing the build agent I set the same but it diaplays C://buildAgent/work in TeamCity web ui due to which my build fails.
My buildAgent.properties file shows
workDir=E\:\\MY_PROJECT_SVN
And buildAgent.dist.properties file shows
workDir=E://MY_PROJECT_SVN
But I get following error when I run team city
Failed to start MSBuild.exe. Failed to find project file at path:
C:\BuildAgent\work\3ac16e0b4e3af05b\Modules\SIM5.sln
Because of wrong working dir
The buildAgent.dist.properties is indeed just an example, but the solution is something you almost had; you need to put this into the buildAgent.properties:
workDir=E:/MY_PROJECT_SVN
Update:
It should be noted that on TeamCity 7.0 the workDir seemingly can't be on a separate disk; it runs most of the way through the build and then fails. However, using a junction to point from the local (default) folder to the E: drive will work. The tempDir can be pointed to a remote disk though.
The file buildAgent.dist.properties is not used, it is just an example. So don't worry about the contents of that file.
What you have set in buildAgent.properties is what matters. What is happening for you is the agent is reverting to the default location for the working directory.
This means that for some reason it is not able to read or parse the buildAgent.properties file. Make 100% certain that the entire file has no errors in it.
https://confluence.jetbrains.com/display/TCD8/Build+Agent+Configuration
Making any change to this file and saving it should cause the build agent to reboot automatically and reload the new config once it has restarted.
http://blog.jetbrains.com/teamcity/2007/10/configuration-files-editing-without-teamcity-restart/
To build on paul-f-wood's answer:
Teamcity 9.1.6 also has the "feature" where the work directory cannot be on a different drive. I tried several permutations of the temp and work dir, and the only ones that stuck were with the work dir on the same drive as the root teamcity folder. However as paul said, using a junction works like a charm.
cmd: rm C:\BuildAgent\work
cmd: mklink /J C:\BuildAgent\work E:\MY_PROJECT_SVN

Space in Directory Parameter of svcutil.exe

I'm attempting to download metadata for a WCF service using svcutil but I'm running into issues with the /directory:<> parameter. The directory I want to save to has a space in it:
C:\Service References\Logging
so when I execute /t:metadata I receive the following error:
Error: The directory 'C:\Program Files (x86)\Microsoft SDKs\Windows\v8.0A\bin\NETFX 4.0 Tools\References\Logging' could not be found. Verify that the directory exists and that you have the appropriate permissions to read it.
It looks to me like the space in "Service References" is causing the issue. From my understanding of command shell (which is very little) spaces act as delimiters for an executable. So I tried escaping the space with a carrot
Service^ References
and surrounding the path in double quotes
"C:\Service References\Logging"
but neither of those seem to be working, as the /directory: parameter doesn't recognize them as valid characters in the value. I haven't been able to find any direction in regards to this and svcutil, so I'm at a loss right now.
I could download the files to a temp folder and then move them, but I would prefer not to take that approach.
I would appreciate any direction that could be given on trying to resolve this.
Thanks in advance.
-- EDIT --
this is the full command that I'm trying to run. if you try it yourself, you'll have to add you're own WCF reference as this one is on an internal ip address
svcutil /t:metadata http://dev.taskservices.noelnet.com/LoggingService/LoggingService.svc /d:C:\Service References\Logging\
According to the documentation for svcutil
/directory: - Directory to create files in (default: current directory) (Short Form: /d)
Since the default is to use the current directory, let us change the current directory for the command.
pushd "C:\Service References\Logging\"
svcutil /t:metadata http://dev.taskservices.noelnet.com/LoggingService/LoggingService.svc
popd
If you do not need to revert back to the original directory you can just use cd "C:\Service References\Logging\".
Note, in order for this to work, svcutil must be called using its entire path or have its path listed in the PATH environment variable. This is what I mean by calling using its entire path:
cd "C:\Service References\Logging\"
"C:\Program Files (x86)\Microsoft SDKs\Windows\v8.0A\bin\NETFX 4.0 Tools\svcutil.exe" /t:metadata http://dev.taskservices.noelnet.com/LoggingService/LoggingService.svc