Description
Jenkins and plugins versions report
Environment
Jenkins 2.440.2 File Operations Plugin 214.v2e7dc7f25757What Operating System are you using (both controller, and any agents involved in the problem)?
RHEL 8, Java 17
Reproduction steps
Jenkins pipeline step with:
steps{
fileOperations([fileCopyOperation(
includes: "**/target/app-.war",
targetLocation: "app-artifacts/",
flattenFiles: true, renameFiles: true,
sourceCaptureExpression: "((?app-)(?\d+\.\d+\.\d*-[a-zA-Z])(?.war\Z)",
targetNameExpression: "${fileName}" + "${env.releaseVersion}" + "${fileExtension}")
])
}
run in pipeline.
Expected Results
app-*.war is copied to ${WORKSPACE}/app-artifacts/app-${env.releaseVersion}.war
Actual Results
app-${env.releaseVersion}.war is copied to ${WORKSPACE}/target/app-${env.releaseVersion}.war
variable targetLocation: "app-artifacts/" is ignored
Anything else?
if (renameFiles) {
String targetFileName = item.getRemote().replaceAll(sourceCaptureExpression, targetNameExpression);
FilePath fpTF = new FilePath(fpTL, targetFileName);
listener.getLogger().println("Copy from " + item.getRemote() + " to " + fpTF);
item.copyTo(fpTF);
you can see that variable targetLocation is not used, which is confusing.
Either update de fix the class as mentioned above or update the documentation at
https://www.jenkins.io/doc/pipeline/steps/file-operations/
targetLocation : String
Destination folder location to copy the files. Base directory is workspace. Will be ignored when setting renameFiles: true.
targetNameExpression : String
An expression that provides the desired target file name. This can reference variables captured in the source capture expression by using $1, $2 etc. When using renameFiles: true set the full target file path including target file name. i.a. $ {WORKSPACE}/app-config/app-dev-0.0.2.yml
Are you interested in contributing a fix?
No response