1

I have a super simple task I need Jenkins to do for me: Run the executable that was compiled, by Jenkins, after building.

Sounds simple.

However, no matter what I've tried in the past half a day will run the program, correctly. Currently, the absolute best I can get, is a blank output of running the executable, which is Never what the program does. It always has output when run.

I've tried downloading the entire workspace related to builds, and running the executable locally, and it works fine - I get output. I went to the slave computer that Jenkins has the workspace on, and ran it out of the workspace folder, it runs fine - there is output. When run via Jenkins pipeline - through a variety of methods (here's a few of the many things and variants I've tried) - no output:

echo bat(returnStdout: true, script: "cmd.exe /c program.exe")
echo bat(returnStdout: true, script: "cmd.exe /c programRunner.bat")
echo bat(returnStdout: true, script: "call program.exe")
echo bat(returnStdout: true, script: "call programRunner.bat")
echo bat(returnStdout: true, script: "program.exe")
echo bat(returnStdout: true, script: "programRunner.bat")

NOTE: programRunner.bat simply is calling program.exe in one of the various methods above, but, written appropriately for a .bat file. When run manually it has expected output, like program.exe. But when run via Jenkins, there's no output.

All of these, do not report errors (when replaced with the actual name of the program) - so it's not that the file is missing. I've tried adding a random character to the name, and it errors because it cannot find that file (because it's a made up file name). SO, it is finding the file, and actually trying to run. But, there's absolutely no output... I've tried piping the output to a file (> ..\..\programOutput.txt 2>&1), and it's a blank but created file in the end.

I suspect it thinks it is missing some dependency. But, I don't understand why I can run it fine locally and on the slave machine manually, to get expected output. It has the dependencies it needs in the same folder as the executable (this is a step in the build process we have, to copy all .dlls needed).

Any help would be greatly appreciated. Let me know if you need clarification on anything.

Again, this sounds simple, and should be, but I'm having the hardest time. I'm not really sure what to try next to be honest. I get no output! It's super hard to debug with no output...

FooBar
  • 51
  • 4
  • 1
    I'm assuming you're running via "Execute Windows batch command"... One thing to keep in mind is that jobs running from Jenkins are being run as the SYSTEM user, so make sure that user has permission, etc., IOW, a bit of a difference (likely, anyway) from you running it manually. – tkosinski Apr 07 '20 at 20:57
  • Try tp change the Jenkins service from running under SYSTEM to a different user. SYSTEM is not really intended to run user-mode programs as it provides a different environment. So unless the program is a system service or specifically tailored to run under SYSTEM, it will most likely fail (e. g. when it makes assumptions where standard paths are supposed to be). – zett42 Apr 07 '20 at 21:25
  • i think your program outputs through `stderr` and `returnStdout` key captures only `stdout`. potentially `program.exe 2>&1` should redirect `stderr` to `stdout` – daggett Apr 07 '20 at 22:28
  • Thanks for the input everyone. I checked the user, and it is not SYSTEM, it's the same user as the account I've launched the Jenkins slave software from. And I tried adding 2>&1 @daggett but it did not output anything :/ – FooBar Apr 07 '20 at 22:39
  • try from plain commandline: `program.exe 1>1.txt 2>2.txt` and tell what file is not empty – daggett Apr 07 '20 at 22:42
  • @daggett Interesting, 1.txt is blank, so stdout is not where the output is coming from. I changed the program to use normal `std::cout` (before it was `qDebug().noquote()` from Qt), and I see the output in Jenkins. The file I try to pipe to though does not populate. So I will just change the program to write to file instead of me piping the output to file. I'm not sure why the stream redirects are not working in Jenkins. Thanks for the help! – FooBar Apr 08 '20 at 13:23

0 Answers0