由於一些公司的變化,我們不得不切換到詹金斯作爲CI工具。雖然這似乎不是一個壞主意,畢竟,我們遇到了很多麻煩,由於缺乏非Java應用程序的支持,尤其是對管道(舊工作流)的插件,當然我們缺乏的知識詹金斯(在這一點上是沒有的)。如何在Jenkins Pipeline(舊工作流程)中使用VSTest結果和其他.NET插件?
node('master')
{
try
{
stage('Checkout, restore, build')
{
//Checkout the code from the repository
git branch: '<branch_name>', credentialsId: '<credentials_ID>', url: '<repo_URL>'
//git clean
bat returnStatus: true, script: 'git clean -fdx'
//Perform dotnet restore and nuget restore
bat returnStatus: true, script: '''for /f "tokens=*" %%a in (\'dir project.json /b /s\') do dotnet restore "%%a"
"C:\\Users\\Administrator\\.jenkins\\workspace\\nuget.exe" restore "C:\\Users\\Administrator\\.jenkins\\workspace\\CI\\<solution_name>.sln"'''
//Build the solution
bat returnStatus: true, script: '"C:\\Program Files (x86)\\MSBuild\\14.0\\Bin\\msbuild.exe" /p:DebugType=full /p:platform=x64 /p:configuration=release /p:VisualStudioVersion=14.0 '
}
} catch(err)
{
currentBuild.result = 'FAILURE'
}
jobDsl("${env.JOB_NAME}") {
steps {
bat returnStatus: true, script: '"C:\\Program Files (x86)\\Microsoft Visual Studio 14.0\\Common7\\IDE\\CommonExtensions\\Microsoft\\TestWindow\\vstest.console.exe" "C:\\Users\\Administrator\\.jenkins\\workspace\\CI\\<path_to_tests_dll>" /TestCaseFilter:"TestCategory=UnitTest|TestCategory=ContinuousTest" /EnableCodeCoverage /Platform:x64 /logger:trx'
}
publishers {
archiveXUnit {
msTest {
pattern('"C:\\Users\\Administrator\\.jenkins\\workspace\\CI\\TestResults"')
}
}
}
}
}
但我發現了錯誤,爲jobDsl
:
java.lang.IllegalArgumentException異常:預期命名的參數,但得到 [CI,org.jenkinsci.plugins.workflow.cps.CpsClosure2 @ 1a706730]在在 org.jenkinsci.plugins.workflow.cps.DSL.invokeDescribable(DSL.java:251) 在有機 org.jenkinsci.plugins.workflow.cps.DSL.parseArgs(DSL.java:442)。 jenkinsci.plugins.workflow.cps.DSL.invokeMethod(DSL.java:129) 在 org.jenk insci.plugins.workflow.cps.CpsScript.invokeMethod(CpsScript.java:108) 在groovy.lang.GroovyObject $ invokeMethod.call(來源不明)在 org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCall(CallSiteArray .java:48) at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:113) at org.kohsuke.groovy.sandbox.impl.Checker $ 1.call(Checker.java:151 ) 在 org.kohsuke.groovy.sandbox.GroovyInterceptor.onMethodCall(GroovyInterceptor.java:21) 在 org.jenkinsci.plugins.scriptsecurity.sandbox.groovy.SandboxInterceptor.onMethodCall(SandboxInterceptor.java:115) 在 org.jenkinsci.plugins.scriptsecurity.sandbox.groovy.Sandb oxInterceptor.onMethodCall(SandboxInterceptor.java:103) at org.kohsuke.groovy.sandbox.impl.Checker $ 1.call(Checker.java:149) at org.kohsuke.groovy.sandbox.impl.Checker.checkedCall( Checker.java:146) 在 com.cloudbees.groovy.cps.sandbox.SandboxInvoker.methodCall(SandboxInvoker.java:16) 在WorkflowScript.run(WorkflowScript:1) cps.transform(母語方法)at com.cloudbees.groovy.cps.impl.ContinuationGroup.methodCall(ContinuationGroup.java:57) at com.cloudbees.groovy.cps.impl.FunctionCallBlock $ ContinuationImpl.dispatchOrArg(FunctionCallBlock.java:109) 在 com.cloudbees.groovy.cps.impl.FunctionCallBlock $ ContinuationImpl.fixArg(FunctionCallBlock.java:82) 在sun.reflect.GeneratedMethodAccessor295.invoke(來源不明)在 sun.reflect.DelegatingMethodAccessorImpl.invoke(來源不明)在 java.lang.reflect.Method.invoke(來源不明)在 com.cloudbees.groovy.cps.impl.ContinuationPtr $ ContinuationImpl.receive(ContinuationPtr.java:72) 在 com.cloudbees.groovy.cps。 impl.ClosureBlock.eval(ClosureBlock.java:46) 在com.cloudbees.groovy.cps.Next.step(Next.java:74)在 com.cloudbees.groovy.cps.Continuable.run0(Continuable.java: 154)在 org.jenkinsci.plugins.workflow.cps.SandboxContinuable.access $ 001(SandboxContinuable.java:18) 在 org.jenkinsci.plugins.workflow.cps.SandboxContinuable $ 1.call(SandboxContinuable.java:33) 在 org.jenkinsci.plugins.workflow.cps.SandboxContinuable $ 1.call(SandboxContinuable.java:30) 在 org.jenkinsci.plugins.scriptsecurity.sandbox.groovy.GroovySandbox.runInSandbox(GroovySandbox。的java:108) 在 org.jenkinsci.plugins.workflow.cps.SandboxContinuable.run0(SandboxContinuable.java:30) 在 org.jenkinsci.plugins.workflow.cps.CpsThread.runNextChunk(CpsThread.java:165) 在 org.jenkinsci.plugins.workflow.cps.CpsThreadGroup.run(CpsThreadGroup.java:328) 在 org.jenkinsci.plugins.workflow.cps.CpsThreadGroup.access $ 100(CpsThreadGroup.java:80) 在 org.jenkinsci.plugins.workflow.cps.CpsThreadGroup $ 2.call(CpsThreadGroup.java:240) 在 org.jenkinsci.plugins.workflow.cps.CpsThreadGroup $ 2.call(CpsThreadGroup.java:228) 在 組織。 jenkinsci.plugins .workflow.cps.CpsVmExecutorService $ 2.call(CpsVmExecutorService.java:64) at java.util.concurrent.FutureTask.run(Unknown Source)at hudson.remoting.SingleLaneExecutorService $ 1.run(SingleLaneExecutorService.java:112) at jenkins.util.ContextResettingExecutorService $ 1.run(ContextResettingExecutorService.java:28) 在java.util.concurrent.Executors $ RunnableAdapter.call(未知 來源)在java.util.concurrent.FutureTask.run(來源不明)在 java.util.concurrent.ThreadPoolExecutor.runWorker(來源不明)在 java.util.concurrent.ThreadPoolExecutor中的$ Worker.run(來源不明)在 java.lang.Thread.run(來源不明)
這真的讓我覺得這不是好的方法,所以有人可以擺脫一些光線並指引我走上正確的道路嗎?