Jenkins pipeline job with PowerShell step runs indefinitely - powershell

I ran into an issue with Jenkins and I can't manage to figure it out. The problem is that, as the title suggest, a pipeline job hangs while a PowerShell is running.
The PowerShell script works with the Az.Monitor module to create alerts for Azure Resources. If I comment this script out, everything works well so I think it's safe to say that it is the problem.
Even so, when I run it in a powershell terminal, it works fine. Even stranger, if I run it in a normal Jenkins job (not a pipeline one), it works fine aswell. I even left the job running overnight.
I saw that someone suggested that maybe some hidden prompts appear while running on Jenkins, but I set the $ConfirmPreference variable to "None" and the issue still happens.
What could be the issue?

For me, the issue was the Durable-Task Jenkins plugin. I downgraded it from version 1.34 to 1.33 and it worked.
This plugin was problematic back in 2017-2018 too with the version 1.15.

Related

Azure Devops automated test results incoherent with powershell test results using the same data

I'm currently trying to integrate automatic test execution on the deployment process using Azure Devops but it's causing me an issue where some tests don't run properly.
The application I'm testing has a log-in page and I've set up a couple of tests to see if it opened properly. These ones run smoothly, but the ones that require going through the login process do not.
I've set up some snapshots amidst the process and the result was that I was getting an error on the last step of logging in. I've checked the application logs and the result I got was that no credentials were sent through the request which I found odd since they were displayed on the snapshots.
All the data being inserted was correct, I've checked the endpoints and settings on the agent that was running them and everything seemed fine.
I tried then to run the automated tests through powershell command directly on the same agent and all of them passed with no issue whatsoever.
I've tried changing my task to a powershell command but it still gives me an error.
I have no idea where my issue could be or where I should be even able to start looking for the problem, as clearly it seems that the problem is on the azure devops task but everything seems fine with it, I've tinkered around with the settings a bit but none of them seemed to have any impact on the results I was getting.
I'm using version 2 of the vstest task and am targetting the test assembly that was deployed to the agent. Any idea on what I could be missing or pointers on how to find the solution?
These ones run smoothly, but the ones that require going through the
login process do not
Based on this description, it seems that it will open a new window automatically by the task.
If I'm right, and your test will open a window to login with your private-hosted agent. At this time, the mode of your private-hosted agent must be in interactive which it can allow auto-logon enabled.
Just check this official document for more detail information.

TeamCity nunit tests different output

I have tests that have to be run on CI server. The thing is that when I am running the tests in nunit console, they are all passing, but on teamcity server I keep receiving a bunch of errors, connected with sqllocaldb instance. I guess this is due to the fact that running teamcity from 'local system' privileges gives such an output, but I don't know how to bypass this thing, even using 'Run as' plugin.
Maybe you can suggest an option/configuration/workaround to me to get the right results?
Created new windows profile, called "TeamCity", configured everything and made service to be run under this profile, now everything works fine.

How to run scheduled Coded UI Tests on Virtual Machine without having a RDP connection

Situation in short:
Virtual Machine with Visual Studio 2013 installed. PowerShell script
runs on the VM to execute Get Latest, Build and Execute Coded UI
Tests. Windows Scheduled Task to execute PowerShell nightly.
auto-logon is enabled (or I'm doing something wrong?)
yes, I've read post Is it possible to run Coded UI tests without having to connect via remote desktop?
I've seen posts about TCM. Does this help and how can I use it in my
situation?
I made some tests in Microsoft Test Manager and I also executed and recorded them.
I've loaded these tests in a test project (and changed the script providing categories and custom checks).
I then categorized these (as Development or Acceptance).
I executed out using a PowerShell script on a VM (with Visual Studio 2013 installed) with following actions:
Get Latest
Build
Run latest build with a selected set aka category using mstest.exe
So far everything is going perfectly. All the tests pass.
However, when I create a Scheduled Task on my VM run the PowerShell script everything fails because of a missing session.
Do I have the VM (I have no knowledge of Virtual Machines) then unlock or something?
Side-Note:
I also tried to fix this with a Test Agent and Controller, but once I had installed these, all other users of TFS lost their rights, so I prefer not to do this again.
I would be very grateful if you know something that can solve this.
I spent hours on Google finding a solution for this issue, but no solution helped me.
Do I need to provide more information?
The problem you're seeming to have is that the testagent is not setup correctly. You need an active desktop session for Coded UI to be able to run (it needs it to perform all the actions such as clicks).
Microsoft has some nice info about setting up your test agent here.
But to tackle your exact problem of the test failing because of a missing session I'd suggest the following:
Run AutoLogOn.exe from the sysinternals suite (can be found at http://live.sysinternals.com/). It will automatically log in with specified user when the machine starts, and keeps the desktop session active.
Alright...I'm making progress.
I've installed test agent and controller. It's all running fine.
Next I've opened Lab Center on my own MTM to create a new environment.
Test Controller is found, but I receive the message in this post "Microsoft Test Manager cannot install test agent on these machines" when creating new Lab Center environment
File and Printer sharing exception is enabled. I don't get the other message.
I don't understand what is wrong.
Maybe I'm completely on the wrong track and it's not necessary to use the Lab Center.
Then the only remaining issue is the non-active desktop issue.

rake script weird in cmd.exe, works fine in ruby.exe

I have this rakefile that works fine when called from a "Start Command Prompt with Ruby" instance, but fails when called with rake.bat. This means I can't get it to work on Jenkins at all using the Rake build step plugin.
From what I can tell, it's the rake/clean task that's messing up and deleting all files in a "/Core" directory. I've explicitly excluded this from the CLEAN filelist, but when called from rake.bat, this is completely ignored.
What could possibly be the cause for this?
Edit:
OK, more info. CLEAN.exclude('**/core') is ignored the first time it's run in the Ruby shell too, but subsequent runs are fine. That explains why rake.bat is a problem 100% of the time.
I'm using rake 0.8.7, but the same thing happens with 0.9.2. Ruby version is 1.9.2p290. albacore version is 0.2.7. Windows 7 x64 (same thing happens on Windows Server 2008 R2 Standard)
OK, I solved it.
Should've realised it earlier, but it's mind-boggingly weird.
fails the first time: CLEAN.exclude("**/core", "**/bak", "**/~") # a comment here
this always works: CLEAN.exclude("**/core", "**/bak", "**/~")
I guess I'm henceforth removing all comments that are not on a single line in my rakefiles...

Running nunit-console.exe fails while GUI is also running

I'm trying to run nunit-console.exe from a script and I get an 'Unable to locate fixture' error, but only when I have NUnit GUI also running. Once I close the NUnit GUI the script runs the tests just fine.
Here is nunit command being executed by the script;
"C:\Dev\Test1\Build\NUnit\nunit-console.exe" "C:\Dev\Test1\Tests\bin\Release\Test1.Tests.dll" /framework=v4.0.30319
It can even be a different version of the NUnit GUI that is running and it still interferes (ver 2.5.1 vs 2.5.5). It think it has something to do with the nunit-agent.exe as it runs (spawned by the nunit-console.exe process) when the GUI is not running, but it doesn't run when the nunit colsole runs while the GUI is also running.
I found this same problem too, which appeared unexpectedly.
The only information that I had found online about it, was a question that someone had posted in a forum and that Charlie Poole (one of the NUnit authors) had responded to it.
Basically, the bug was found in 2.5.5 and was fixed in the next release, available from the NUnit.org download page of the website.
For me, this meant upgrading to NUnit 2.6.1 and the problem disappeared.
I hope this helps to clear your tumbleweed away! :-)
Try using nunit-console-x86.exe instead of nunit-console.exe.
Also, try using /framework=4.0 instead of /framework=v4.0.30319.
Lastly, I've had similar issues when I try to run nunit-console-x86.exe using a different user account than the logged in user, and so I resolved this by running the exe using the same user account.
Maybe this question will also help: nunit-console can not loacte fixture
Also see this bug: https://bugs.launchpad.net/nunitv2/+bug/582051
Good luck! :)