Hi. I am fairly new to Octopus, but have come across a problem that i can’t resolve.
I have a problem with custom build step. I want to run vstest.console.exe after a deploy to verify the success of the deploy. My powershell script fails on postback to TFS with this error: Error: Build “Project.Package_9107” cannot be found under team project “Git”.
The command I use is this:
vstest.console.exe" Tests.dll /inisolation /TestCaseFilter:“TestCategory=Dev” /logger:TfsPublisher;Collection=http://myserver:8080/tfs/default;BuildName=Project.Package_9107;TeamProject=Git;flavor=release
This command works if I run it on the server, either directly by powershell or by console, but if I run it from Octopus it fails. I have tried from custom build step and from script console, but yields the same result. I have upgraded to 3.2 but the result is the same.
Thanks for reaching out. Both Script Console and Custom build step are scripts executed by the account running the Tentacle service. Do you know if that account has enough permissions to run that command? A very quick way to test this out would be to change the Tentacle service account to run under your own account, and then trying to run the command again. If it runs with your user, then you know its a permission issue.
I’ve been through that. Logged on as the same user that runs the tentacle service, and had none problems running the script. The results was published back to the specific build.
Absolutt worth pointing out, the tests runs perfectly. Its only the postback portion of the script that fails.
Its weird that it returns that error, but tests run ok. Doing a quick google of the message “cannot be found under team project” returned these 2 results which might be helpful (not sure really, I have 0 experience with vstest.console)
This seems to be a problem with the way VSTest is being executed, and not with Octopus itself. Something tells me you’re gonna have more luck asking in a forum dedicated to VSTest. Perhaps StackOverflow would be the best place to go.
On the other hand, if all it does is return that error but tests run perfectly like you said, perhaps wrapping the script call in a Try/Catch block on a Powershell script to handle that particular exception and still return a successful exit code wouldn’t be such a bad idea.
I’ve analyzed the situation with Fiddler. See screenshots. It seems like vstest does not try to connect to TFS when run by Octopus, but when run directly, by the same user, it does.
Is there any limitations to how Octopus runs powershell commands?
I’m very sorry for the delay here. Somehow your reply was marked as “read” and it didn’t show up on my queue.
I’m gonna consult with one of our devs if the way we execute Powershell scripts might be causing this behavior somehow. I’ll try to get back to you by tomorrow (dev team is in Australia).
Could youtry to manually run your script using the Calamari executable?
The syntax would be calamari.exe run-script [path of your script]. You can find Calamari.exe on your tentacle’s app directory, which is by default C:\Octopus\Calamari
The Tentacle uses the same Calamari executable you just used to execute steps during the deployment. The only difference between these 2 methods,is that one is running interactively(manual Calamari execution which appears to work), and one as a non-interactive Windows Service (from the Octopus deployment). It appears that vstest.console.exe is doing something “unexpected” and not just a plain console call, reason why it doesn’t work from a non-interactive process.
We’ve seen users workaround similar situations by setting up a scheduled task on the server using schtasks.exe that invokes that console app.
Other than that, I’ve asked around the team and we are unfortunately out of ideas. Perhaps the Microsoft forums could help explaining why cant that executable be called from a service?