如何使用REST API部署具有maven布局的工件?

时间:2014-11-24 02:32:14

标签: artifactory

我可以使用以下命令进行正常部署

curl -i -X PUT -u $artifactoryUser:$artifactoryPassword -T /path/to/file/file.zip http://localhost/artifactory/simple/repo/groupId/artifactId/version/file.zip

但是,这不会解决或更新工件上的maven布局。有没有一种方法可以在不使用artifactory-maven插件的情况下上传?

1 个答案:

答案 0 :(得分:2)

我找到了我发布的这个问题的解决方案。

使用的语法:

curl -i -X PUT -K $CURLPWD "http://localhost/artifactory/$REPO/$groupId/$artifactId/$versionId/$artifactId-$versionId.$fileExt"

结束编写脚本以便md5& sha1值与文件一起上传,否则,我必须进入Artifactory并手动修复它。

#!/bin/bash

usage() {
        echo "Please check the Usage of the Script, there were no enough parameters supplied."
        echo "Usage: ArtifactoryUpload.sh localFilePath Repo GroupID ArtifactID VersionID"
        exit 1
}

if [ -z "$5" ]; then
        usage
fi

localFilePath="$1"
REPO="$2"
groupId="$3"
artifactId="$4"
versionId="$5"

ARTIFAC=http://localhost/artifactory

if [ ! -f "$localFilePath" ]; then
        echo "ERROR: local file $localFilePath does not exists!"
        exit 1
fi

which md5sum || exit $?
which sha1sum || exit $?

md5Value="`md5sum "$localFilePath"`"
md5Value="${md5Value:0:32}"

sha1Value="`sha1sum "$localFilePath"`"
sha1Value="${sha1Value:0:40}"

fileName="`basename "$localFilePath"`"
fileExt="${fileName##*.}"

echo $md5Value $sha1Value $localFilePath
echo "INFO: Uploading $localFilePath to $targetFolder/$fileName"

curl -i -X PUT -K $CURLPWD \
-H "X-Checksum-Md5: $md5Value" \
-H "X-Checksum-Sha1: $sha1Value" \
-T "$localFilePath" \
"$ARTIFAC/$REPO/$groupId/$artifactId/$versionId/$artifactId-$versionId.$fileExt"