Skip to content

Instantly share code, notes, and snippets.

@daveneeley
Created May 14, 2019 00:01
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save daveneeley/18a72abe2e9a4c5de9d256b1115d5cdb to your computer and use it in GitHub Desktop.
Save daveneeley/18a72abe2e9a4c5de9d256b1115d5cdb to your computer and use it in GitHub Desktop.
Show that Artifactory jfrog-cli creates duplicate buildinfos and only the most recent can be used later
#this script proves that files that are uploaded by jfrog-cli will be promoted
#when there are no duplicate buildinfos
param (
$serverId,
$sourceRepo = "duplicate-buildinfos-source",
$promoteRepo = "duplicate-buildinfos-promote",
$buildName = "duplicate-buildinfos-build",
$buildNumber = (get-date -Format yyyyMMddss),
$repoPath = "$sourceRepo/$buildName/$buildNumber/"
)
if (test-path upload*.txt) {
rm *.txt
}
if (test-path $buildName) {
rm -recurse $buildName
}
echo "file upload1 will be uploaded and then promoted." > upload1-$buildNumber.txt
echo "file upload2 will be uploaded and then promoted." > upload2-$buildNumber.txt
#upload both of our new files
jfrog rt u --server-id $serverId --build-number $buildNumber --build-name $buildName upload*.txt $repoPath
#report our upload
jfrog rt bp $buildName $buildNumber
#promote build, which moves upload1 and upload2 to the promoteRepo
jfrog rt bpr --server-id $serverId --include-dependencies $buildName $buildNumber $promoteRepo
#this script creates duplicate buildinfos with Artifactory's jfrog-cli version 1.16.1
param (
$serverId,
$sourceRepo = "duplicate-buildinfos-source",
$promoteRepo = "duplicate-buildinfos-promote",
$buildName = "duplicate-buildinfos-build",
$buildNumber = (get-date -Format yyyyMMddss),
$repoPath = "$sourceRepo/$buildName/$buildNumber/"
)
if (test-path upload*.txt) {
rm *.txt
}
if (test-path $buildName) {
rm -recurse $buildName
}
echo "file upload1 will be uploaded, downloaded again, and then promoted." > upload1-$buildNumber.txt
echo "file upload2 will be uploaded but not promoted. It will not be promoted because the file was not downloaded and thus not reported in the last call to rt bp for the given build number." > upload2-$buildNumber.txt
#upload both of our new files
jfrog rt u --server-id $serverId --build-number $buildNumber --build-name $buildName upload*.txt $repoPath
#report our upload
jfrog rt bp $buildName $buildNumber
#download only one of the two files
jfrog rt dl --server-id $serverId --build-number $buildNumber --build-name $buildName "${repoPath}upload1-${buildNumber}.txt"
#report the downloaded file, creating a duplicate buildinfo object in Artifactory
jfrog rt bp $buildName $buildNumber
#promote build, which moves upload1 to the promoteRepo but skips upload2 because it was not in the last buildinfo
jfrog rt bpr --server-id $serverId --include-dependencies $buildName $buildNumber $promoteRepo
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment