Find parent directory name of a file - Jenkins pipeline

Viewed 62

I have some groovy code (Jenkins Pipeline) to loop over a coverage directory and find any files matching a certain pattern. For any files found, I want to determine what their parent directory is named as. These files are currently in sub dirs under a coverage directory.

def coverageReportFiles = findFiles(glob: 'coverage/**/coverage-summary.json')
for(file in coverageReportFiles ){
    echo "${file.directory}" // currently prints out 'false'
}

Are there any utilities with Jenkins Pipeline steps or anything native in groovy I can use to determine this?

1 Answers

It should be possible with file.parentFile.name

Related