gpt4 book ai didi

jenkins - 在 Jenkins 的常规脚本中,调用目标抛出了异常

转载 作者:行者123 更新时间:2023-12-04 15:23:00 29 4
gpt4 key购买 nike

我需要维护一个 jenkins groovy 脚本(我们不确定它是否有效)。管道构建的脚本有多个阶段(“单元测试”成功之前的“修订”和“构建”阶段),其中之一如下:

enter image description here

stage('Unit Tests')
{
stages
{
stage('Tests')
{
parallel
{
stage('TRKengineTest')
{
steps
{
bat '"C:\\Program Files (x86)\\NUnit.org\\nunit-console\\nunit3-console.exe" TRKengine\\TRKengine.Test\\bin\\Release\\netcoreapp3.1\\TRKengine.Test.dll --result=TRKengine.Test.xml;format=nunit2 --timeout=180000 --workers=1'
echo "Something to do?"
}
}
stage('TRKengineGUItest')
{
steps
{
//bat '"C:\\Program Files (x86)\\NUnit.org\\nunit-console\\nunit3-console.exe" TRKengine\\TRKengineGUI.Test\\bin\\Release\\netcoreapp3.1\\TRKengineGUI.Test.dll --result=TRKengineGUI.Test.xml;format=nunit2 --timeout=180000 -v --workers=1'
echo "Nothing to do"
}
}
}
}
stage('Testresults')
{
steps
{
nunit testResultsPattern: 'TRKengine.Test.xml, TRKengineGUI.Test.xml'
}
}
}
}

bat 命令返回 -100 错误。更准确地说:

C:\Jenkins\workspace\TRKengine_trunk>"C:\Program Files (x86)\NUnit.org\nunit-console\nunit3-console.exe" TRKengine\TRKengine.Test\bin\Release\netcoreapp3.1\TRKengine.Test.dll --result=TRKengine.Test.xml;format=nunit2 --timeout=180000 -v  --workers=1 

NUnit Console Runner 3.6.1

Copyright (C) 2017 Charlie Poole



Runtime Environment

OS Version: Microsoft Windows NT 10.0.14393.0

CLR Version: 4.0.30319.42000



Test Files

TRKengine\TRKengine.Test\bin\Release\netcoreapp3.1\TRKengine.Test.dll





Errors, Failures and Warnings



1) Error :

Exception has been thrown by the target of an invocation.



Server stack trace:

at System.RuntimeMethodHandle.InvokeMethod(Object target, Object[] arguments, Signature sig, Boolean constructor)

at System.Reflection.RuntimeConstructorInfo.Invoke(BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture)

at System.RuntimeType.CreateInstanceImpl(BindingFlags bindingAttr, Binder binder, Object[] args, CultureInfo culture, Object[] activationAttributes, StackCrawlMark& stackMark)

at System.Activator.CreateInstance(Type type, BindingFlags bindingAttr, Binder binder, Object[] args, CultureInfo culture, Object[] activationAttributes)

at System.Activator.CreateInstance(String assemblyString, String typeName, Boolean ignoreCase, BindingFlags bindingAttr, Binder binder, Object[] args, CultureInfo culture, Object[] activationAttributes, Evidence securityInfo, StackCrawlMark& stackMark)

at System.Activator.CreateInstance(String assemblyName, String typeName, Boolean ignoreCase, BindingFlags bindingAttr, Binder binder, Object[] args, CultureInfo culture, Object[] activationAttributes, Evidence securityInfo)

at System.AppDomain.CreateInstance(String assemblyName, String typeName, Boolean ignoreCase, BindingFlags bindingAttr, Binder binder, Object[] args, CultureInfo culture, Object[] activationAttributes, Evidence securityAttributes)

at System.AppDomain.CreateInstanceAndUnwrap(String assemblyName, String typeName, Boolean ignoreCase, BindingFlags bindingAttr, Binder binder, Object[] args, CultureInfo culture, Object[] activationAttributes, Evidence securityAttributes)

at System.AppDomain.CreateInstanceAndUnwrap(String assemblyName, String typeName, Boolean ignoreCase, BindingFlags bindingAttr, Binder binder, Object[] args, CultureInfo culture, Object[] activationAttributes, Evidence securityAttributes)

at NUnit.Engine.Drivers.NUnit3FrameworkDriver.Load(String testAssemblyPath, IDictionary`2 settings)

at NUnit.Engine.Runners.DirectTestRunner.LoadPackage()

at NUnit.Engine.Runners.DirectTestRunner.EnsurePackageIsLoaded()

at NUnit.Engine.Runners.DirectTestRunner.RunTests(ITestEventListener listener, TestFilter filter)

at System.Runtime.Remoting.Messaging.StackBuilderSink._PrivateProcessMessage(IntPtr md, Object[] args, Object server, Object[]& outArgs)

at System.Runtime.Remoting.Messaging.StackBuilderSink.SyncProcessMessage(IMessage msg)



Exception rethrown at [0]:

at System.Runtime.Remoting.Proxies.RealProxy.HandleReturnMessage(IMessage reqMsg, IMessage retMsg)

at System.Runtime.Remoting.Proxies.RealProxy.PrivateInvoke(MessageData& msgData, Int32 type)

at NUnit.Engine.ITestEngineRunner.Run(ITestEventListener listener, TestFilter filter)

at NUnit.Engine.Runners.ProcessRunner.RunTests(ITestEventListener listener, TestFilter filter)



Test Run Summary

Overall result: Failed

Test Count: 0, Passed: 0, Failed: 0, Warnings: 0, Inconclusive: 0, Skipped: 0

Start time: 2020-07-15 11:32:42Z

End time: 2020-07-15 11:32:43Z

Duration: 0.556 seconds



Results (nunit2) saved as TRKengine.Test.xml

script returned exit code -100

我尝试了一些事情:

1)首先,nunit-console.exe 的路径似乎是错误的,但正如我所发现的,它可以在最近发布的 nunit 中使用。

2)test.dll的路径是正确的,因为我手动导航到那里,..netcoreapp3.1\TRKengine.Test.dll确实在那里。

3)我在互联网上的其他示例中发现了 --result=TRKengine.Test.xml;format=nunit2。

4)我尝试删除剩余参数、worker/timeout -v 等的任意组合,但没有成功。

所以出现错误的行似乎是正确的,我的直觉是错误可能已经发生在其他地方。

我不确定“调用”是什么意思。我也检查了How do you run NUnit tests from Jenkins?这似乎是相关的,感觉 Winston33 的命题与这里发生的事情完全一样。

有点担心的是,我的机器是 64 位的,但路径是..x86。

我还可以访问代码并成功构建解决方案中的所有项目

我是 jenkins 和 groovy 的初学者,所以如果我没有透露任何必要的信息,请通知我。

如有任何帮助,我们将不胜感激。

最佳答案

错误信息:Exception has been thrown by the target of an invocation是基于 C# 的产品的常见消息

意味着 nunit 尝试动态调用目标测试 dll,但它 (dll) 会抛出一些您看不到的异常。

检查与您的问题非常接近的 nunit 问题 https://github.com/nunit/nunit/issues/1509

建议设置以下nunit参数

  • --trace=Debug 查看更多错误信息
  • --inprocess 在单个进程中运行测试

应该创建几个日志文件,其中可能包含有助于理解错误发生原因的信息。

关于jenkins - 在 Jenkins 的常规脚本中,调用目标抛出了异常,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/62914462/

29 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com