我现在用Google搜索了很多年,我放弃了,热门话题Groovy + Jenkins正在提出这么多假旗......
我有一个我在IntelliJ中开发的Groovy项目,它还包含一个带单元测试的JUnit.groovy。现在这是SoapUI的脚本,不需要Maven,Ant或Grails,但我希望能够在Jenkins上编译这些文件并在之后运行单元测试。是否可以在Jenkins上构建和测试这些文件?到目前为止,所有解决方案似乎都是我手动运行groovyc(与我的存储库一起提交),然后在JUnit.class上运行JUnit。
所以在我开始深入挖掘并编写Maven,Grails或Ant文件之前,还有另一种方法不涉及我在我的git上推动GroovySDK吗?或者是否可能有一个简单的构建脚本,不涉及20个库和步骤来构建groovy源并运行JUnit测试:)?
我显然是詹金斯的新手;),感谢你的投入。
更新:
build.gradle
是:
version '2.5-SNAPSHOT'
apply plugin: 'groovy'
dependencies {
compile fileTree(dir: '../Library', include: ['*.jar'])
}
test {
reports {
junitXml.enabled = true
html.enabled = true
}
}
sourceCompatibility = 1.8
gradle wrapper
为gradlew.bat
设置项目的gradle包装post-commit
中添加了一个/.hooks/
,所以我的詹金斯是通过curl http://jenkins:8080/git/notifyCommit?url=https://git.git&branches=dev
提交时触发的#!groovy
node {
stage('Checkout') {
git branch: 'dev', credentialsId: 'youwish', url: 'https://git.git'
}
stage('Build') {
dir('./Modules') {
gradle('clean')
gradle('compileTestGroovy')
}
}
stage('UnitTest') {
dir('./Modules') {
gradle('test')
junit '/build/test-results/**/TEST-*.xml'
}
}
stage('IntegrationTest') {
stage('CodeTableDownload') {
dir('./SoapUi') {
bat 'AutoRun.bat'
junit '/results/**/*-JUNIT.xml'
}
}
}
}
def gradle(command) {
bat "./gradlew.bat $command"
}
有一个Groovy plugin for Jenkins可以让你在Jenkins上执行Groovy脚本。
但是,为什么不让像Gradle这样的东西进行构建并为你运行测试呢? Groovy的最小Gradle构建文件将同时执行:
apply plugin: 'groovy'
repositories {
jcenter()
}
dependencies {
compile 'org.codehaus.groovy:groovy-all:2.4.12'
testCompile 'junit:junit:4.12'
}
您不必提交GDK,只需声明依赖项。