generated from Templates/Baseline
add upload command #3
@ -47,8 +47,46 @@ showSettings() {
|
|||||||
say "PLUGIN_UPDATE: $PLUGIN_UPDATE" "showSettings"
|
say "PLUGIN_UPDATE: $PLUGIN_UPDATE" "showSettings"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
testArtifact() {
|
||||||
|
tout=$(curl --output /dev/null --write-out "%{http_code}" \
|
||||||
|
"$CI_FORGE_URL/api/packages/$PLUGIN_OWNER/generic/$PLUGIN_PACKAGE_NAME/$PLUGIN_PACKAGE_VERSION/$PLUGIN_FILE_NAME")
|
||||||
|
|
||||||
|
if [ "$tout" = "200" ]; then
|
||||||
|
echo "true"
|
||||||
|
else
|
||||||
|
echo "false"
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
deleteArtifact() {
|
||||||
|
dout=$(curl --output /dev/null --write-out "%{http_code}" \
|
||||||
|
--user "$PLUGIN_USER:$PLUGIN_PASSWORD" -X DELETE \
|
||||||
|
"$CI_FORGE_URL/api/packages/$PLUGIN_OWNER/generic/$PLUGIN_PACKAGE_NAME/$PLUGIN_PACKAGE_VERSION/$PLUGIN_FILE_NAME")
|
||||||
|
|
||||||
|
if [ "$dout" = "204" ]; then
|
||||||
|
say "Old package file deleted" "deleteArtifact"
|
||||||
|
elif [ "$dout" = "404" ]; then
|
||||||
|
sayE "The package or file was not found." "deleteArtifact"
|
||||||
|
exit 1
|
||||||
|
else
|
||||||
|
sayE "Unknown curl response! ($dout)" "deleteArtifact"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
uploadArtifact() {
|
uploadArtifact() {
|
||||||
say "Starting file upload..."
|
say "Testing if the artifact already exists in give package version..." "uploadArtifact"
|
||||||
|
fexist=$(testArtifact)
|
||||||
|
if [ "$fexist" = "true" ]; then
|
||||||
|
if [ -n "$PLUGIN_UPDATE" ]; then
|
||||||
|
sayW "Given file already exists. Updating package file..." "uploadArtifact"
|
||||||
|
deleteArtifact
|
||||||
|
else
|
||||||
|
sayW "A file with the same name exist already in the package." "uploadArtifact"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
say "Starting file upload..." "uploadArtifact"
|
||||||
cout=$(curl --output /dev/null --write-out "%{http_code}" \
|
cout=$(curl --output /dev/null --write-out "%{http_code}" \
|
||||||
--user "$PLUGIN_USER:$PLUGIN_PASSWORD" \
|
--user "$PLUGIN_USER:$PLUGIN_PASSWORD" \
|
||||||
--upload-file "$PLUGIN_FILE_SOURCE" \
|
--upload-file "$PLUGIN_FILE_SOURCE" \
|
||||||
@ -62,8 +100,7 @@ uploadArtifact() {
|
|||||||
sayE "Upload failed! (Bad Request)" "uploadArtifact"
|
sayE "Upload failed! (Bad Request)" "uploadArtifact"
|
||||||
exit 1
|
exit 1
|
||||||
elif [ "$cout" = "409" ]; then
|
elif [ "$cout" = "409" ]; then
|
||||||
sayW "A file with the same name exist already in the package." "uploadArtifact"
|
sayE "File already exists in package version!" "uploadArtifact"
|
||||||
exit 1
|
|
||||||
else
|
else
|
||||||
sayE "Unknown upload response! ($cout)" "uploadArtifact"
|
sayE "Unknown upload response! ($cout)" "uploadArtifact"
|
||||||
exit 1
|
exit 1
|
||||||
|
Loading…
Reference in New Issue
Block a user