I trying to use Copy Artifacts plugin of Jenkins, want to get build number that archive copied from and use it for later pipeline script.
parameters {
buildSelector(
name: 'LAST_ARCHIVED_BUILD',
defaultSelector: lastCompleted(),
description: 'Build for copy artifact from')
...
copyArtifacts(
projectName: "${JOB_NAME}",
selector: ${LAST_ARCHIVED_BUILD},
filter: "report_log_${LAST_ARCHIVED_BUILD}_dump.json"
)
...
sh( """
jq --sort-keys . report_log_${LAST_ARCHIVED_BUILD}_dump.json > last.json
jq --sort-keys . report_log_${BUILD_NUMBER}_dump.json > today.json
diff last.json today.json > diff_result.txt
"""
)
...
But it seems this LAST_ARCHIVED_BUILD
have a string like :
LAST_ARCHIVED_BUILD=<LastCompletedBuildSelector plugin="copyartifact@1.47"/> (for lastCompleted())
or
LAST_ARCHIVED_BUILD=<SpecificBuildSelector plugin="copyartifact@1.47"> <buildNumber>526</buildNumber></SpecificBuildSelector> (for specific build)
Is there any way to get a build number from this BuildSelector or Copy Artifact plugin?