简体   繁体   中英

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 ? There is a single file option called readFileFromWorkspace but it doesn't help when i want the contents of a directory.

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

The environment variable WORKSPACE does not exist when using jenkins pipeline from what i can see

this format only works if you are running on the master new File(__FILE__).parent.absolutePath

You can use the SEED_JOB variable ( wiki ) to get the job which runs the Job DSL build step. In case of Pipeline, this should be a 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 . I do not know the Pipeline internals, but maybe you can look through the sources starting here .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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