我已經花了很多時間在這方面沒有任何成功。根據this我應該可以使用任何可用的SCM,但我不知道如何映射路徑,在任何地方插入$ {library.RegLib.version}或要使用的工作空間名稱。如何使用perforce作爲SCM設置Jenkins Pipeline全局庫?
我有一個庫設置按照上述文檔:
<root>/src/org/somelib/MyLib.groovy
其中包含:
package org.registration;
def doTest() {
echo "test running..."
}
我已經嘗試了很多不同的東西,但沒有任何工程。我也嘗試重新啓動詹金斯,如提到here。不用找了。
我的構建報告:
Loading library [email protected]#1
java.lang.ArrayIndexOutOfBoundsException: 1
at org.jenkinsci.plugins.p4.tasks.AbstractTask.setEnvironment(AbstractTask.java:106)
at org.jenkinsci.plugins.p4.PerforceScm.checkout(PerforceScm.java:391)
at org.jenkinsci.plugins.workflow.steps.scm.SCMStep.checkout(SCMStep.java:109)
at org.jenkinsci.plugins.workflow.libs.SCMSourceRetriever.doRetrieve(SCMSourceRetriever.java:107)
at org.jenkinsci.plugins.workflow.libs.SCMRetriever.retrieve(SCMRetriever.java:63)
at org.jenkinsci.plugins.workflow.libs.LibraryAdder.retrieve(LibraryAdder.java:150)
at org.jenkinsci.plugins.workflow.libs.LibraryAdder.add(LibraryAdder.java:131)
at org.jenkinsci.plugins.workflow.libs.LibraryDecorator$1.call(LibraryDecorator.java:99)
at org.codehaus.groovy.control.CompilationUnit.applyToPrimaryClassNodes(CompilationUnit.java:1053)
at org.codehaus.groovy.control.CompilationUnit.doPhaseOperation(CompilationUnit.java:591)
at org.codehaus.groovy.control.CompilationUnit.processPhaseOperations(CompilationUnit.java:569)
at org.codehaus.groovy.control.CompilationUnit.compile(CompilationUnit.java:546)
at groovy.lang.GroovyClassLoader.doParseClass(GroovyClassLoader.java:298)
at groovy.lang.GroovyClassLoader.parseClass(GroovyClassLoader.java:268)
at groovy.lang.GroovyShell.parseClass(GroovyShell.java:688)
at groovy.lang.GroovyShell.parse(GroovyShell.java:700)
at org.jenkinsci.plugins.workflow.cps.CpsGroovyShell.reparse(CpsGroovyShell.java:67)
at org.jenkinsci.plugins.workflow.cps.CpsFlowExecution.parseScript(CpsFlowExecution.java:429)
at org.jenkinsci.plugins.workflow.cps.CpsFlowExecution.start(CpsFlowExecution.java:392)
at org.jenkinsci.plugins.workflow.job.WorkflowRun.run(WorkflowRun.java:221)
at hudson.model.ResourceController.execute(ResourceController.java:98)
at hudson.model.Executor.run(Executor.java:404)
org.codehaus.groovy.control.MultipleCompilationErrorsException: startup failed:
WorkflowScript: Loading libraries failed
「默認版本」設置爲1,因爲這裏只有過一次提交。我也試過#1。我不知道是否映射特定文件或頂層目錄。如果我刪除默認版本,構建失敗並抱怨我沒有設置版本。它應該是可選的,但顯然不是。
我也使用瓦爾目錄
<root>/vars/doTest.groovy
其中包含嘗試:
def call(msg) {
echo msg
}
,但我相信這也要求要加載的庫。這些文件不清楚。
因此...
這是否會與perforce一起工作?
如何映射路徑使其工作?
如何讓代碼可以訪問?這是作爲整個圖書館的一部分加載的嗎?
我的代碼中是否有錯誤?
非常感謝。
謝謝,但不回答任何問題。應該很清楚,我已經做到了。負載'implicitly'是一個選項,但我想'@ Library'。乾杯。 – ConfusedAgain
我能夠訪問VARS/*。Groovy文件從我Jenkinsfile只調用它們。你確定你正確配置Global Pipeline Libraries設置嗎? – Amityo
顯然不是,因此問題。事實上,我幾乎肯定我不是,但我沒有嘗試過的作品。 – ConfusedAgain