yerel sınıfını içe olamaz ben gelenekselleşmiş bir senaryo çağıran bir maven yapı dosyası dediğimiz bir Jenkins iş var. Jenkins iseJenkins GMavenPlus eklentisi harika komut
Ben:
Maven version 3.0
Goals and options: -U -P hudson gplus:execute
Groovy komut GMavenPlus kullanılarak adlandırılır. Bu komut dosyası çalışır
println "Hello from testImport"
importedClass = new ImportedClass()
importedClass.hello()
tek olan başka bir harika senaryo,
ImportedClass.groovy içerecek şekilde: pom.xml ben
testImport.groovy senaryoyu çağırıyor
<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>
var yöntem:
class ImportedClass {
def hello() {
println("Hello from imported class")
}
}
testImport komut dosyası doğru olarak adlandırılır ve tüm çalışma, ama importedClass için bir ithalat kullanmaya çalışırken bir sorun var gibi görünüyor.
bu hata ben kurulum paketleri isimlerle çalıştı Jenkins konsola
[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]
görünen ve değerlendirmek ancak her zaman bu hata ile biten de kullanmak zorunda. Harici bir groovy dosyası eklemek için bir yolu var mı?
import groovyx.net.http.HTTPBuilder
// and create instance of the class
def httpBuilder = new HTTPBuilder("blablabla")