TFS2015 Build fails on all Command Line Commands with 'file not found' - tfs

In Team Foundation Server 2015 Build (on-premise), I'm having issues running simple command line commands. All Command Line tasks simply fail with the following error: "File not found: ".
Take for example the following build definition:
This is executed using an on-premise Build Agent and will fail with the following exception in the logs:
BUILD FAILED
2016-01-20T12:04:47.5127709Z ##[warning]Filename doesn't indicate a full path to a executable file.
2016-01-20T12:04:47.5127709Z Executing the following commandline. (workingFolder = D:\_work\2\s)
2016-01-20T12:04:47.5127709Z date
2016-01-20T12:04:47.5127709Z Error message highlight pattern:
2016-01-20T12:04:47.5127709Z Warning message highlight pattern:
2016-01-20T12:04:47.5439748Z ##[error]File not found: date
Of course this is a simplified example where I simply want to output the current date using the date /t command. But the same problem occurs with all general command line commands which I've tried, such as dir, time, path etc. The MSDN does not provide any troubleshooting info on it, other than that the tool executed must reside in the PATH variable.
The issue is not specific to one build definition or repo; it can be reproduced on others as well.
The builds run as the built-in svc_tfsbuild account.
I'm perhaps thinking this is either a simple setting, or - wildly guessing - an issue related to rights, but cannot find any documentation where to look or what to check. Any help would be appreciated.

It appears this is a known issue on MS Connect as well.
In short a MSFT mentions the following:
Commands that are built-in to command prompt don't work. Anything resolvable based on your PATH/PATHEXT will work.
In the comment from 27 Oct, 2015 it is stated that this will be fixed in the next sprint. The mentioned workaround for now is simply executing cmd.exe first and provide the rest as arguments.
Using the example from the original question this would lead to:
Tool: cmd.exe
Arguments: /c "date /t"
And I can indeed confirm this works.

Related

Bazel giving "open_proc" error 21 running embedded command

I'm working on creating a Bazel extension for Haxe and while I've had some initial success in getting things to build, I've hit a roadblock and I'm not sure what the right way around it is.
In Haxe if you declare a dependency on a Haxelib in your build.hxml file, when you perform the build the Haxe compiler will go grab that Haxelib from the internet and install it locally if you don't already have it, using a program named "haxelib". It seems that this process is being blocked by the Bazel sandbox, but I haven't been able to find much documentation on how the sandboxing works, if this is expected, and if there's a way around it. I'm currently working in Windows 10; this is the error that I'm getting:
$ bazel build //:neko-lib --verbose_failures
INFO: Analyzed target //:neko-lib (0 packages loaded, 0 targets configured).
INFO: Found 1 target...
ERROR: D:/repo/validation/BUILD:3:13: HaxeCompile neko/validation.n failed (Exit 1): haxe.exe failed: error executing command
cd C:/users/user/_bazel_user/s6xipia4/execroot/__main__
external/haxe_windows_amd64/haxe.exe bazel-out/x64_windows-fastbuild/bin/build.hxml
Execution platform: #local_config_platform//:host
Unix.Unix_error(21, "open_proc", "haxelib path hx3compat")
Target //:neko-lib failed to build
INFO: Elapsed time: 1.705s, Critical Path: 0.62s
INFO: 0 processes.
FAILED: Build did NOT complete successfully
hx3compat is the name of the haxelibthat I'm trying to load. Error 21 seems to be "is a directory" but I'm not exactly sure what's actually being complained about. Here's the run action that I'm using:
ctx.actions.run(
outputs = [out],
inputs = inputs,
executable = haxe_cmd,
arguments = [args],
env = env,
mnemonic = "HaxeCompile",
)
haxe_cmd points the haxe.exe file, while the inputs are:
bazel-out/x64_windows-fastbuild/bin/build.hxml (the build file I'm building)
external/haxe_windows_amd64/haxe.exe
external/haxe_windows_amd64/haxelib.exe
Any ideas on things I can try to get around this issue?
Update: I wrote a rule today that runs the command in question (haxelib path hx3compat) and that works, so I think this is an error with invoking that command - not with the command itself.
The particular error that I was getting - Unix error 21 - was caused by the shell that Bazel creates not having the COMSPEC environment variable: see here and here for more details. Adding that variable to the environment via the --action_env=COMSPEC command line got me past that error. However the command shell that gets spawned by the Haxe process cannot handle symlinks, and so has a lot of trouble trying to access the directories brought in by Bazel, so I think using haxe via this route will end up being a lost cause. Just for the record though, I was able to get the haxelib command itself to run through the haxe process, so the answer for this question is to ensure the COMSPEC variable is set.

How does AOSP build system produce .rsp files and how to get them?

According to How does AOSP 9.0 build system link the executable? and What does # mean in this clang command in AOSP build log? , when linking a module, AOSP seems to produce a .rsp file that contains all the obj files that the module need,and pass the file name as a parameter to the link command, for example:
prebuilts/clang/host/linux-x86/clang-4691093/bin/clang++ /OpenSource/Build/Android/9.0.0_r30/soong/.intermediates/bionic/libc/crtbegin_so/android_x86_64_core/crtbegin_so.o #/OpenSource/Build/Android/9.0.0_r30/soong/.intermediates/frameworks/base/libs/hwui/libhwui/android_x86_64_core_shared/libhwui.so.rsp ......
But the .rsp files seems to be removed after build.
The question is, how are these file generated and how to get these files? This may require to learn and modify the build scripts which is out of reach for me.
There maybe the answer for you, read the ninja build manual , in that manual .rsp file mentioned.
https://ninja-build.org/manual.html
the following is info that I copy out.
rspfile, rspfile_content
if present (both), Ninja will use a response file for the given command, i.e. write the selected string (rspfile_content) to the given file (rspfile) before calling the command and delete the file after successful execution of the command.
This is particularly useful on Windows OS, where the maximal length of a command line is limited and response files must be used instead.

Setting up Rails project on TeamCity hosted on a Windows server

I'm setting up my first Ruby project on Team City, which is hosted on a Windows Server, but I'm having a problem. Now, because the server may not have the required gems installed, I've added a command line build step:
bundle install
Now I thought this would be enough, but apparently bundle is not recognized as an internal or external command. Except, if I RDP into the server, if I run bundle install from anywhere, it is fine, and just notifies me that no gemfile was found.
Any ideas on if I've missed a step, or I'm going about this the wrong way?
Most likely this is a problem with TeamCity not finding the path to ruby executables.
You can address this by overriding the value to the PATH environment variable in your build configuration in the Build Parameters section.
env.PATH=/path/to/ruby;%env.PATH%
See this answer for the proper links to documentation, etc.
EDIT #1
I noticed when updating one of my configurations that TeamCity is supposed to take care of appending values so you DO NOT need to set path equal to itself. The post mentioned above is a workaround for a bug where TeamCity was overwriting the values, but that has been corrected. See the help at the mouse-over for more information:
EDIT #2
I tested edit #1 and found that is not the case. You do need to
create an environment variable env.Path
and set it's value to itself plus your new path; in my example, C:\Program Files\MySQL\MySQL Server 5.6\bin\;%env.Path%
you do NOT need to say env.Path=... as listed above; that is what the configuration file will look like.
I tested this out by doing the following:
Created a new project with no repository
Added a command line build step to `echo %env.Path%
Added a command step to call MySql mysql --help This will fail if it cannot find MySql
I then ran it for each of the following settings for the env.Path variable:
Not added / changed; TeamCity reports out the environment variable for the build agent as is.
Added as just C:\Program Files\MySQL\MySQL Server 5.6\bin\. TeamCity reports out only that entry.
Added as C:\Program Files\MySQL\MySQL Server 5.6\bin\;%env.Path%. TeamCity prepends C:\Program Files\MySQL\MySQL Server 5.6\bin\ to the build agent's values shown in #1. The result is what we want, #1 + #2

TFS build partially succeeded when calling a batch file, but no error in log

I’m building a solution which requires a batch file to be run after the build (there's a sequence in the workflow for this). TFS flags the build as partially succeeded, but there’s no error in the log even in full verbose mode ("diagnostic"). I’m checking the errorlevel after each line in the batch file and it’s always 0. I’ve also tested redirecting stdout and stderr in a file after each line and there’s no clue there.
It’s got nothing to do with unit tests because I’m skipping them for the time being.
I’ve noticed that usually when an error occurs in a batch file (e.g. file not found) there’s a visual cue to indicate the error and this matches the partially succeeded status. But I don’t see any visual cue.
So how can TFS decide that the build is only partially succeeded?
Thank you,
Solved.
It turns out the GetImpactedTests activity is throwing an exception (I can see it in the event viewer of the TFS machine), but it doesn't show at all in the build log.
I'm guessing that this exception makes the build partially succeeded (because the compilation part succeeded) but I couldn't see the assignment explicitly in the buid log. When I bypass the impact analysis (either by setting Analyze Test Impact to False or by removing the GetImpactedTests activity altogether), the error does not occur.
We experiment something similar here using the Lab Workflow (to kick our CodedUI tests). Different build template, same symptoms.
I have noticed that the build process reports that it partially succeeded, highlighting what seems to be a successful step in the deploy script (batch file).
The command is question is a command to install our mobile app on a mobile device (in order to test it at night):
adb install -d -r test.apk
I thought about looking the errorlevel right after running the adb command but the errorlevel was 0.
Then I thought that maybe the command is sending its output to stderr and found out this article on the android open source project, which confirms my hypothesis.
Following is my fix:
adb install -r -d test.apk 2>&1
Appending 2>&1 simply redirects stderr to stdout and now my deploy script does not report an error anymore and the build now succeeds (when all tests pass!).
Conclusion: When a script writes anything to stderr, the build workflow will report it as an error (partial success since it does not prevent execution of the workflow).
I know this is not your particular issue but since we had the same symptoms, I thought the stderr information could help somebody else find out the reason why their build process is reporting a partial success even though everything seems to work.

Help using signtool.exe in Delphi project post-build events

This is a very simple question. What should I write in Delphi post build events to execute a coomand line tool?
I wrote this:
c:\BinPath\signtool.exe sign /f c:\BinPath\Mypfxfile.pfx /p MyPassword
/t http:// timestamp.verisign.com/scripts/timstamp.dll c:\BinPath\Project1.exe
(where c:\BinPath is the Delphi output path, for simplicity I copied signtool.exe adn pfx file in the same folder)
as i build the project I have this modal window error:
--------------------------- Project 1- CodeGear Delphi for Microsoft Windows - Form1
--------------------------- Cannot open file "C:\SourcePath\EXEC".
Impossible to find the specified
path..
and in the messages I have
[Exec Error] EXEC(1):
"SignerTimeStamp() failed."
(-2147467259/0x80004005)
[Exec Error]
exit from command
"c:\BinPath\signtool.exe sign /f
c:\BinPath\Mypfxfile.pfx /p MyPassword
/t http://
timestamp.verisign.com/scripts/timstamp.dll
c:\BinPath\Project1.exee" with code 1.
How to manage this? In Delphi help I read (from Creating Build Events topic):
Enter the build commands, one command per line, and press Return after entering each command. Commands consist of any valid DOS command, such as: copy $() c:\Built\$()
So i simply inserted in the build event what (c:\BinPath\....Project1.exe) I was able to run from command prompt. Where is the error? Thanks.
I could have deleted this question, since I found the problem, but I think it is better to leave it since it can be useful for others:
THE PROBLEM WAS SIMPLY
http:// timestamp...
of course should be
http://timestamp...
when copying on build event I inserted an extra space by mistake. By reading the question posted I found the error...

Resources