Groovyスクリプトを呼び出すmavenビルドファイルを呼び出すJenkinsジョブがあります。ジェンキンスでJenkins GMavenPlusプラグインはGroovyスクリプトでローカルクラスをインポートできません
私が持っている:
Maven version 3.0
Goals and options: -U -P hudson gplus:execute
のGroovyスクリプトがGMavenPlusを使用して呼ばれています。
println "Hello from testImport"
importedClass = new ImportedClass()
importedClass.hello()
このスクリプトは、単一を持つ別のグルーヴィーなスクリプト、ImportedClass.groovyを含めるしようとします:のpom.xmlで、私はtestImport.groovyスクリプトを呼び出している
<plugin>
<groupId>org.codehaus.gmavenplus</groupId>
<artifactId>gmavenplus-plugin</artifactId>
<version>1.5</version>
<executions>
<execution>
<goals>
<goal>execute</goal>
</goals>
</execution>
</executions>
<configuration>
<scripts>
<script>
file:///${project.basedir}/src/main/java/com/mycompany/testImport.groovy
</script>
</scripts>
</configuration>
</plugin>
を持っています方法:
class ImportedClass {
def hello() {
println("Hello from imported class")
}
}
testImportスクリプトが正しく呼び出されていますが、すべて機能していますが、importedClassのインポートを使用しようとしているときに問題が発生しているようです。
私はこのエラーは、私がセットアップパッケージ名にしようとしたジェンキンスコンソール
[ERROR] Failed to execute goal org.codehaus.gmavenplus:gmavenplus-plugin:1.5:execute (default-cli) on project com.mycompany: Error occurred while calling a method on a Groovy class from classpath. InvocationTargetException: startup failed:
[ERROR] Script1.groovy: 3: unable to resolve class ImportedClass
[ERROR] @ line 3, column 21.
[ERROR] def importedClass = new ImportedClass()
[ERROR]^
[ERROR]
[ERROR] 1 error
[ERROR] -> [Help 1]
に登場し、はを評価するが、常にそのエラーに終わるも使用しています。外部groovyファイルを含める方法はありますか?その後、私はグルーヴィーコードで使用することができます
<dependencies>
<dependency>
<groupId>org.codehaus.groovy.modules.http-builder</groupId>
<artifactId>http-builder</artifactId>
<version>0.7</version>
</dependency>
:
import groovyx.net.http.HTTPBuilder
// and create instance of the class
def httpBuilder = new HTTPBuilder("blablabla")