- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我有以下 build.gradle
apply plugin: 'groovy'
apply plugin: 'idea'
apply plugin: 'java'
repositories {
mavenCentral()
maven {
url 'https://repo.jenkins-ci.org/releases'
}
maven {
url 'https://repo.jenkins-ci.org/public'
}
}
sourceSets {
main {
groovy {
srcDirs = ['src']
}
}
test {
groovy {
srcDirs = ['test']
}
}
}
dependencies {
compile group: 'org.jenkins-ci.main', name: 'jenkins-core', version: '2.76'
compile group: 'org.jenkins-ci.plugins.workflow', name: 'workflow-step-api', version: '2.13'
compile 'com.cloudbees:groovy-cps:1.14'
compile 'org.connectbot.jbcrypt:jbcrypt:1.0.0'
compileOnly 'javax.servlet:javax.servlet-api:3.1.0'
compile 'org.codehaus.groovy:groovy-all:2.4.12'
testCompile 'junit:junit:4.12'
}
当我运行“gradle build”时,出现以下错误:
> Task :compileGroovy FAILED
startup failed:
/home/user/myproject/SomeClass.groovy: 26: unable to resolve class org.jenkinsci.plugins.workflow.steps.FlowInterruptedException
@ line 26, column 11.
} catch (org.jenkinsci.plugins.workflow.steps.FlowInterruptedException flowInterruptedException) {
^
1 error
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':compileGroovy'.
> Compilation failed; see the compiler error output for details.
* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.
* Get more help at https://help.gradle.org
BUILD FAILED in 1s
1 actionable task: 1 executed
就好像它没有看到“org.jenkinsci.plugins.workflow.steps.FlowInterruptedException”,但我添加了工作流步骤-api,它应该找到它。
我做错了什么?如何修复?
谢谢
最佳答案
'org.jenkins-ci.plugins.workflow:workflow-step-api:2.13'
依赖项有一个 POM,其中包含此内容(取自 here ):
<packaging>hpi</packaging>
当您指向此依赖项时,Gradle 检索的依赖项是 hpi
工件,而不是 jar
工件。这可以通过如下任务来显示:
tasks.create('showDependencies') {
doFirst {
final config = configurations.getByName(sourceSets.getByName('main').compileClasspathConfigurationName)
config.resolvedConfiguration.resolvedArtifacts.findAll { it.moduleVersion.id.group.contains('jenkins') }.each {
println("Resolved dependency: id=${it.id}, extension=${it.extension}, classifier=${it.classifier}")
}
}
}
输出:
> Task :showDependencies
Resolved dependency: id=jenkins-core.jar (org.jenkins-ci.main:jenkins-core:2.76), extension=jar, classifier=null
Resolved dependency: id=workflow-step-api.hpi (org.jenkins-ci.plugins.workflow:workflow-step-api:2.13), extension=hpi, classifier=null
Resolved dependency: id=cli.jar (org.jenkins-ci.main:cli:2.76), extension=jar, classifier=null
Resolved dependency: id=trilead-ssh2.jar (org.jenkins-ci:trilead-ssh2:build-217-jenkins-11), extension=jar, classifier=null
Resolved dependency: id=icon-set.jar (org.jenkins-ci.plugins.icon-shim:icon-set:1.0.5), extension=jar, classifier=null
Resolved dependency: id=remoting.jar (org.jenkins-ci.main:remoting:3.11), extension=jar, classifier=null
Resolved dependency: id=version-number.jar (org.jenkins-ci:version-number:1.4), extension=jar, classifier=null
Resolved dependency: id=crypto-util.jar (org.jenkins-ci:crypto-util:1.1), extension=jar, classifier=null
Resolved dependency: id=bytecode-compatibility-transformer.jar (org.jenkins-ci:bytecode-compatibility-transformer:1.8), extension=jar, classifier=null
Resolved dependency: id=structs.hpi (org.jenkins-ci.plugins:structs:1.5), extension=hpi, classifier=null
Resolved dependency: id=symbol-annotation.jar (org.jenkins-ci:symbol-annotation:1.5), extension=jar, classifier=null
Resolved dependency: id=annotation-indexer.jar (org.jenkins-ci:annotation-indexer:1.12), extension=jar, classifier=null
Resolved dependency: id=task-reactor.jar (org.jenkins-ci:task-reactor:1.4), extension=jar, classifier=null
Resolved dependency: id=commons-jelly.jar (org.jenkins-ci:commons-jelly:1.1-jenkins-20120928), extension=jar, classifier=null
Resolved dependency: id=commons-jexl.jar (org.jenkins-ci:commons-jexl:1.1-jenkins-20111212), extension=jar, classifier=null
Resolved dependency: id=memory-monitor.jar (org.jenkins-ci:memory-monitor:1.9), extension=jar, classifier=null
Resolved dependency: id=jmdns.jar (org.jenkins-ci:jmdns:3.4.0-jenkins-3), extension=jar, classifier=null
Resolved dependency: id=constant-pool-scanner.jar (org.jenkins-ci:constant-pool-scanner:1.2), extension=jar, classifier=null
Resolved dependency: id=dom4j.jar (org.jenkins-ci.dom4j:dom4j:1.6.1-jenkins-4), extension=jar, classifier=null
有多种方法可以使用 Gradle 的 dependency management features以更好地处理依赖关系。更改依赖关系的一种可能方法是添加 artifact dependency与扩展名。这可能无法解决您的确切用例,具体取决于您希望依赖项如何结束,但希望可以为您指明方向:
compile(group: 'org.jenkins-ci.plugins.workflow', name: 'workflow-step-api', version: '2.13') {
artifact {
name = 'workflow-step-api'
type = 'jar'
}
}
顺便说一下,在 Jenkins 插件生态系统中,Jenkins Maven HPI Plugin和 Jenkins Plugin Parent POM共同进行依赖管理,这样您就不会遇到这样的问题。
关于jenkins - 在哪里可以找到带有 gradle 的 org.jenkinsci.plugins.workflow.steps.FlowInterruptedException ?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47312009/
我有以下 build.gradle apply plugin: 'groovy' apply plugin: 'idea' apply plugin: 'java' repositories {
我是一名优秀的程序员,十分优秀!