简体   繁体   English

当jenkins管道作业触发时,如何使用作业dsl获取文件数组?

[英]how do i get an array of files using job dsl when triggered by a jenkins pipeline job?

how do i get an array of files using jenkins job-dsl when triggered by a jenkins-pipeline job ? 当jenkins管道作业触发时,如何使用jenkins job-dsl获取一系列文件? There is a single file option called readFileFromWorkspace but it doesn't help when i want the contents of a directory. 有一个名为readFileFromWorkspace的文件选项,但是当我需要目录的内容时,它没有帮助。

this needs to work on a slave rather than a master which rules out: 这需要工作在奴隶而不是主人,这排除了:

using this variable hudson.FilePath workspace = hudson.model.Executor.currentExecutor().getCurrentWorkspace() works when not using jenkins pipeline but errors out when you are 使用此变量hudson.FilePath workspace = hudson.model.Executor.currentExecutor().getCurrentWorkspace()在不使用jenkins管道时工作但是当你遇到错误时

The environment variable WORKSPACE does not exist when using jenkins pipeline from what i can see 从我能看到的内容使用jenkins管道时,环境变量WORKSPACE不存在

this format only works if you are running on the master new File(__FILE__).parent.absolutePath 只有在主new File(__FILE__).parent.absolutePath上运行时,此格式才有效

You can use the SEED_JOB variable ( wiki ) to get the job which runs the Job DSL build step. 您可以使用SEED_JOB变量( wiki )来获取运行Job DSL构建步骤的作业。 In case of Pipeline, this should be a org.jenkinsci.plugins.workflow.job.WorkflowJob . 在Pipeline的情况下,这应该是org.jenkinsci.plugins.workflow.job.WorkflowJob And with SEED_JOB.lastBuild you should get the running build which is a org.jenkinsci.plugins.workflow.job.WorkflowRun . 使用SEED_JOB.lastBuild您应该获得正在运行的构建,这是一个org.jenkinsci.plugins.workflow.job.WorkflowRun I do not know the Pipeline internals, but maybe you can look through the sources starting here . 我不知道Pipeline的内部结构,但也许你可以从这里开始查看源代码。

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

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM