简体   繁体   English

Jenkins groovy 管道:指定 Java 选项

[英]Jenkins groovy pipeline: specifying Java Options

We have a relatively simple job configuration which I am trying to convert into a groovy pipeline in Jenkinsfile.我们有一个相对简单的作业配置,我正在尝试将其转换为 Jenkinsfile 中的 groovy 管道。

In our classic view, the part "Call Ant" looks like this:在我们的经典视图中,“Call Ant”部分如下所示: 在此处输入图像描述

Now, I am able to specify all those values in the relevant part of the Jenkinsfile, except for Java Options.现在,我可以在 Jenkinsfile 的相关部分中指定所有这些值,除了 Java 选项。 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: label 成功应用于构建,但是关于 Java 选项,显然我遗漏了一些东西:

/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?我在这里想念什么?

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何在Groovy Jenkins Pipeline中使用全局外部Java库中的方法? - How to use methods from a global external java library in a Groovy Jenkins Pipeline? 詹金斯,指定 JAVA_HOME - Jenkins, specifying JAVA_HOME 如何使用 JProfiler 提高 Jenkins 管道 Groovy 作业性能? - How to improve Jenkins Pipeline Groovy jobs performance using JProfiler? 为Jenkins工作流/管道创建Serializable Groovy类的语法是什么 - What's the syntax to create a Serializable Groovy Class for Jenkins Workflow/Pipeline Jenkins - 从 Groovy 访问 JAVA “getProperties” - Jenkins - Access JAVA “getProperties” from Groovy 按名称执行.JAR,而不指定'java -jar'命令选项 - Execute .JAR by name without specifying 'java -jar' command options 在Jenkins上解析Groovy脚本时出现java.lang.StackOverflowError - java.lang.StackOverflowError when parsing Groovy script on Jenkins 如何使用groovy for Jenkins自动化Maven和Java JDK8安装? - How to automate Maven and Java JDK8 installation with groovy for Jenkins? 即使测试失败,如何始终写入 Jenkins Groovy 管道中的 a.csv 数据文件 - How to always write out to a .csv data file in a Jenkins Groovy pipeline even with test failures 如何在Jenkins管道中导入Java库 - How do I import a Java library in Jenkins pipeline
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM