在Jenkins中使用Groovy进行scala测试



我正在尝试用groovy和jenkins构建一个scala项目。单元测试在本地工作,但在jenkins上不起作用。

build.gradle

apply plugin: 'idea'
apply plugin: 'scala'

repositories {
    mavenCentral()
}
dependencies {
    compile 'junit:junit:4.11',
            'org.scala-lang:scala-library:2.11.1',
            'com.github.nscala-time:nscala-time_2.10:1.0.0'
    testCompile 'org.scalatest:scalatest_2.11:2.1.6',
        'org.scalautils:scalautils_2.11:2.1.6',
        'org.scala-lang:scala-library:2.11.1'
}
compileTestScala << {
    classpath= classpath.asPath + ":" + compileScala.destinationDir
}
test << {
    ant.taskdef(
            name: 'scalatest',
            classname: 'org.scalatest.tools.ScalaTestAntTask',
            classpath: classpath.asPath
    )
    print(classpath.asPath)
    ant.scalatest(
            runpath: testClassesDir,
            haltonfailure: 'true',
            fork: 'false') {
        reporter(type: 'stderr')
    }
}
日志


:compileTestScala
[ant:taskdef] Could not load definitions from resource scala/tools/ant/antlib.xml. It could not be found.
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':compileTestScala'.
Cause: Problem: failed to create task or type scalac
Cause: The name is undefined.
Action: Check the spelling.
Action: Check that any custom tasks/types have been declared.
Action: Check that any / declarations have taken place.

* Try:
Run with --info or --debug option to get more log output.
* Exception is:
org.gradle.api.tasks.TaskExecutionException: Execution failed for task ':compileTestScala'.
    at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.executeActions(ExecuteActionsTaskExecuter.java:71)
    at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.execute(ExecuteActionsTaskExecuter.java:48)
    at org.gradle.api.internal.tasks.execution.PostExecutionAnalysisTaskExecuter.execute(PostExecutionAnalysisTaskExecuter.java:34)
    at org.gradle.api.internal.tasks.execution.SkipUpToDateTaskExecuter.execute(SkipUpToDateTaskExecuter.java:55)
    at org.gradle.api.internal.tasks.execution.ValidatingTaskExecuter.execute(ValidatingTaskExecuter.java:57)
    at org.gradle.api.internal.tasks.execution.SkipEmptySourceFilesTaskExecuter.execute(SkipEmptySourceFilesTaskExecuter.java:41)
    at org.gradle.api.internal.tasks.execution.SkipTaskWithNoActionsExecuter.execute(SkipTaskWithNoActionsExecuter.java:51)
    at org.gradle.api.internal.tasks.execution.SkipOnlyIfTaskExecuter.execute(SkipOnlyIfTaskExecuter.java:52)
    at org.gradle.api.internal.tasks.execution.ExecuteAtMostOnceTaskExecuter.execute(ExecuteAtMostOnceTaskExecuter.java:42)
    at org.gradle.api.internal.AbstractTask.execute(AbstractTask.java:237)
    at org.gradle.execution.DefaultTaskGraphExecuter.executeTask(DefaultTaskGraphExecuter.java:167)
    at org.gradle.execution.DefaultTaskGraphExecuter.doExecute(DefaultTaskGraphExecuter.java:160)
    at org.gradle.execution.DefaultTaskGraphExecuter.execute(DefaultTaskGraphExecuter.java:78)
    at org.gradle.execution.TaskNameResolvingBuildExecuter.execute(TaskNameResolvingBuildExecuter.java:113)
    at org.gradle.execution.DelegatingBuildExecuter.execute(DelegatingBuildExecuter.java:54)
    at org.gradle.initialization.DefaultGradleLauncher.doBuildStages(DefaultGradleLauncher.java:158)
    at org.gradle.initialization.DefaultGradleLauncher.doBuild(DefaultGradleLauncher.java:112)
    at org.gradle.initialization.DefaultGradleLauncher.run(DefaultGradleLauncher.java:80)
    at org.gradle.launcher.RunBuildAction.execute(RunBuildAction.java:41)
    at org.gradle.launcher.RunBuildAction.execute(RunBuildAction.java:27)
    at org.gradle.launcher.ExceptionReportingAction.execute(ExceptionReportingAction.java:32)
    at org.gradle.launcher.ExceptionReportingAction.execute(ExceptionReportingAction.java:21)
    at org.gradle.launcher.CommandLineActionFactory$WithLoggingAction.execute(CommandLineActionFactory.java:219)
    at org.gradle.launcher.CommandLineActionFactory$WithLoggingAction.execute(CommandLineActionFactory.java:203)
    at org.gradle.launcher.Main.execute(Main.java:55)
    at org.gradle.launcher.Main.main(Main.java:40)
    at org.gradle.launcher.ProcessBootstrap.runNoExit(ProcessBootstrap.java:46)
    at org.gradle.launcher.ProcessBootstrap.run(ProcessBootstrap.java:28)
    at org.gradle.launcher.GradleMain.main(GradleMain.java:24)
Caused by: : Problem: failed to create task or type scalac
Cause: The name is undefined.
Action: Check the spelling.
Action: Check that any custom tasks/types have been declared.
Action: Check that any / declarations have taken place.
    at org.apache.tools.ant.UnknownElement.getNotFoundException(UnknownElement.java:487)
    at org.apache.tools.ant.UnknownElement.makeObject(UnknownElement.java:419)
    at org.apache.tools.ant.UnknownElement.maybeConfigure(UnknownElement.java:163)
    at org.gradle.api.internal.project.ant.BasicAntBuilder.nodeCompleted(BasicAntBuilder.java:71)
    at org.gradle.api.internal.project.AntBuilderDelegate.nodeCompleted(DefaultIsolatedAntBuilder.groovy:137)
    at org.gradle.api.internal.tasks.scala.AntScalaCompiler$_execute_closure1.doCall(AntScalaCompiler.groovy:56)
    at org.gradle.util.ConfigureUtil.configure(ConfigureUtil.java:61)
    at org.gradle.util.ConfigureUtil.configure(ConfigureUtil.java:31)
    at org.gradle.util.ConfigureUtil$configure.call(Unknown Source)
    at org.gradle.api.internal.project.DefaultIsolatedAntBuilder.execute(DefaultIsolatedAntBuilder.groovy:98)
    at org.gradle.api.internal.project.IsolatedAntBuilder$execute.call(Unknown Source)
    at org.gradle.api.internal.tasks.scala.AntScalaCompiler.execute(AntScalaCompiler.groovy:53)
    at org.gradle.api.internal.tasks.scala.DefaultScalaJavaJointCompiler.execute(DefaultScalaJavaJointCompiler.java:75)
    at org.gradle.api.internal.tasks.compile.IncrementalJavaSourceCompiler.execute(IncrementalJavaSourceCompiler.java:73)
    at org.gradle.api.tasks.scala.ScalaCompile.compile(ScalaCompile.java:89)
    at org.gradle.api.internal.BeanDynamicObject.invokeMethod(BeanDynamicObject.java:158)
    at org.gradle.api.internal.CompositeDynamicObject.invokeMethod(CompositeDynamicObject.java:93)
    at org.gradle.api.tasks.scala.ScalaCompile_Decorated.invokeMethod(Unknown Source)
    at org.gradle.util.ReflectionUtil.invoke(ReflectionUtil.groovy:23)
    at org.gradle.api.internal.project.taskfactory.AnnotationProcessingTaskFactory$2.execute(AnnotationProcessingTaskFactory.java:129)
    at org.gradle.api.internal.project.taskfactory.AnnotationProcessingTaskFactory$2.execute(AnnotationProcessingTaskFactory.java:127)
    at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.executeActions(ExecuteActionsTaskExecuter.java:63)
    ... 28 more 

构建服务器安装了旧版本的gradle。必须手动安装最新版本,然后它就工作了

相关内容

  • 没有找到相关文章