为多个文件添加Jenkins archiveArtifacts,而不是在一行中

8cdiaqws  于 2023-10-17  发布在  Jenkins
关注(0)|答案(1)|浏览(173)

我已经看到了Jenkins: archiveArtifacts - multiple distinct filesJenkins multiple artifacts for the same build的答案,我也看了文档(来自https://stackoverflow.com/a/50022804/264822),但没有一个解释如何将一长行文件拆分为多行(以提高可读性?)
一个简短的例子是:

archiveArtifacts artifacts: 'build_wrapper_output_directory/build-wrapper-dump.json, build_wrapper_output_directory/build-wrapper.log'

如果我尝试拆分这一行,Jenkinsfile的解析就会失败。使用单引号拆分:

archiveArtifacts artifacts: 'build_wrapper_output_directory/build-wrapper-dump.json,'
        'build_wrapper_output_directory/build-wrapper.log'

给了我:

org.codehaus.groovy.control.MultipleCompilationErrorsException: startup failed:
WorkflowScript: 116: unexpected token

在不带引号的情况下拆分时:

archiveArtifacts artifacts: 'build_wrapper_output_directory/build-wrapper-dump.json,
        build_wrapper_output_directory/build-wrapper.log'

给了我:

org.codehaus.groovy.control.MultipleCompilationErrorsException: startup failed:
WorkflowScript: 112: expecting ''', found '\n' @ line 112, column 75.
vvppvyoh

vvppvyoh1#

使用\工作:

archiveArtifacts artifacts: 'build_wrapper_output_directory/build-wrapper-dump.json, \
        build_wrapper_output_directory/build-wrapper.log'

相关问题