У меня есть работа Jenkins, которая вызывает файл сборки maven, который вызывает строгий скрипт.Jenkins Плагин GMavenPlus не может импортировать локальный класс в groovy script
В Jenkins у меня есть:
Maven version 3.0
Goals and options: -U -P hudson gplus:execute
Отлич- сценарий вызывается с помощью GMavenPlus. В pom.xml у меня есть
<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>
Который называет testImport.groovy скрипт:
println "Hello from testImport"
importedClass = new ImportedClass()
importedClass.hello()
Этот скрипт пытается включить еще один заводной сценарий, ImportedClass.groovy, который имеет один метод:
class ImportedClass {
def hello() {
println("Hello from imported class")
}
}
Сценарий testImport правильно вызывается, и у меня все работает, но при попытке использовать импорт для importClass возникает проблема.
У меня есть эта ошибка появляется в консоли Дженкинс
[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?
мне удалось внешних зависимостей работать, используя это в pom.xml:
<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")