2016-12-06 74 views
0

我已經花了很多時間在這方面沒有任何成功。根據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一起工作?

如何映射路徑使其工作?

如何讓代碼可以訪問?這是作爲整個圖書館的一部分加載的嗎?

我的代碼中是否有錯誤?

非常感謝。

回答

0

安裝Pipeline Shared Libraries插件。

的配置在管理詹金斯 - >全球管道庫

檢索方法應該是legacy mode。添加存儲庫

勾選Load implicitly加載腳本在每個建設

把Groovy文件在瓦爾/ yourGroovy。Groovy和從Jenkinsfile調用它:

yourGroovy() 
+0

謝謝,但不回答任何問題。應該很清楚,我已經做到了。負載'implicitly'是一個選項,但我想'@ Library'。乾杯。 – ConfusedAgain

+0

我能夠訪問VARS/*。Groovy文件從我Jenkinsfile只調用它們。你確定你正確配置Global Pipeline Libraries設置嗎? – Amityo

+0

顯然不是,因此問題。事實上,我幾乎肯定我不是,但我沒有嘗試過的作品。 – ConfusedAgain

0

似乎是一個懸而未決的問題與P4插件,涉及到P4插件後也無法從工作區根目錄不同的位置來處理Perforce的檢出:

https://issues.jenkins-ci.org/browse/JENKINS-40055

https://issues.jenkins-ci.org/browse/JENKINS-36243

編輯:您可能能夠得到這個使用舊版本的插件工作,根據第一個問題的記者:

在工作流程-cps-global-lib的2.4版中不存在該崩潰,它僅在版本2.5中開始發生。

+0

感謝。是的,第一個看起來特別貼切,我一直在想這是否可能。你可能是對的。乾杯。 – ConfusedAgain

相關問題