MSTest fails with NT AUTHORITY ANONYMOUS LOGON error from SQL Server when running via Jenkins Build Job

Article ID:203882560
1 minute readKnowledge base

Issue

I have MSTest unit test cases which log into a SQL Server to verify information in the database. When I run the test from a command prompt on the Jenkins server, the test runs successfully. When I kick off a build which runs the same test, all test which access the database fail with an 'NT AUTHORITY\ANONYMOUS LOGON error.

Environment

  • CloudBees Jenkins Enterprise

  • Windows 2008 R2

Resolution

The build job was running on a windows agent machine where Jenkins was not running as a service.

Change the build agent to run Jenkins as a service and set up the service account which Jenkins is running under for the test to execute as expected.