英文:
Jenkins groovy pipeline: specifying Java Options
问题
我们有一个相对简单的作业配置,我正在尝试将其转换为Jenkinsfile中的Groovy流水线。
现在,我能够在Jenkinsfile的相关部分指定所有这些值,除了Java选项。这是我正在尝试的:
...
script {
antTarget = 'configure clean version.file compile jars create.webstart.module.eu.app-main.gui create.war.module.eu.app-main.srv release'
labelArgument = "-Dlabel=${CURRENT_BUILD}@${GIT_HASH}"
javaOptions = "-Donline=t"
withAnt(installation: 'Ant Installation', jdk: 'java-for-sonarcube') {
dir ("ingest/dev") {
sh "ant ${labelArgument} ${javaOptions} ${antTarget}"
}
}
}
...
标签成功应用于构建,但是关于Java选项,显然我漏掉了某些内容:
/tmp/workspace/nb-ingest_feature_NBINGEST-124/ingest/dev@tmp/durable-fee91921/script.sh: 第2行:-Donline=t:找不到命令
我在这里漏掉了什么?
英文:
We have a relatively simple job configuration which I am trying to convert into a groovy pipeline in Jenkinsfile.
In our classic view, the part "Call Ant" looks like this:
Now, I am able to specify all those values in the relevant part of the Jenkinsfile, except for Java Options. This is what I am trying:
...
script {
antTarget = 'configure clean version.file compile jars create.webstart.module.eu.app-main.gui create.war.module.eu.app-main.srv release'
labelArgument = "-Dlabel=${CURRENT_BUILD}@${GIT_HASH}"
javaOptions = "-Donline=t"
withAnt(installation: 'Ant Installation', jdk: 'java-for-sonarcube') {
dir ("ingest/dev") {
sh "ant ${labelArgument} ${javaOptions} ${antTarget}"
}
}
}
...
The label gets applied successfully to the build, however regarding the Java Options, obviously I am missing something:
> /tmp/workspace/nb-ingest_feature_NBINGEST-124/ingest/dev@tmp/durable-fee91921/script.sh: line 2: -Donline=t: command not found
What am I missing here?
答案1
得分: 1
script{
antTarget = 'cleanlib clean ensure-all-jars jar backport test slowtest cvrgreport-all ivy.publish-hudson'
buildFile = "${WORKSPACE}/java/Utils6/auto_build.xml"
javaOptions = "-Djava.io.tmpdir=${WORKSPACE}/tmp"
prop = "-Divylib=${WORKSPACE}/buildutils/ivy/lib -Dresolver=hudson-server"
r=params.SVN_BUILD_REVISION
b=params.SVN_BRANCH
rev = "-DSVN_BUILD_REVISION=${r}"
bch = "-DSVN_BRANCH=${b}"
withAnt(installation: 'Ant1.9.4', jdk: 'JDK7') {
sh "ant ${rev} ${bch} ${javaOptions} ${prop} ${antTarget} -file ${buildFile}"
}
英文:
I was also facing a similar kind of issue.This was the solution to it.
script{
antTarget = 'cleanlib clean ensure-all-jars jar backport test slowtest cvrgreport-all ivy.publish-hudson'
buildFile = "${WORKSPACE}/java/Utils6/auto_build.xml"
javaOptions = "-Djava.io.tmpdir=${WORKSPACE}/tmp"
prop = "-Divylib=${WORKSPACE}/buildutils/ivy/lib -Dresolver=hudson-server"
r=params.SVN_BUILD_REVISION
b=params.SVN_BRANCH
rev = "-DSVN_BUILD_REVISION=${r}"
bch = "-DSVN_BRANCH=${b}"
withAnt(installation: 'Ant1.9.4', jdk: 'JDK7') {
sh "ant ${rev} ${bch} ${javaOptions} ${prop} ${antTarget} -file ${buildFile}"
}
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论