Jenkins groovy pipeline: 指定Java选项

huangapple go评论68阅读模式
英文:

Jenkins groovy pipeline: specifying Java Options

问题

我们有一个相对简单的作业配置,我正在尝试将其转换为Jenkinsfile中的Groovy流水线。

在我们的经典视图中,“Call Ant”部分的样子如下:
Jenkins groovy pipeline: 指定Java选项

现在,我能够在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:
Jenkins groovy pipeline: 指定Java选项

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}"
}

huangapple
  • 本文由 发表于 2020年7月23日 21:33:43
  • 转载请务必保留本文链接:https://go.coder-hub.com/63055551.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定