如何使用Jenkins从nexus获取jar文件?

2024-06-28 10:47:21 发布

您现在位置:Python中文网/ 问答频道 /正文

我有一个Jenkins作业,它包含3个参数:ARTIFACT_ID、GROUP_ID和APP_VERSION。我想用这3个参数从Nexus下载任何特定的jar文件。在

注意,nexusurl是在Jenkins配置中提供的,因此它将自动知道从哪里查找。在

你知道怎么做吗!!在

例如,对于python应用程序,我使用pip download --no-deps ARTIFACT_ID==APP_VERSION,它工作得很好。在


Tags: pip文件nexusidapp应用程序参数version
1条回答
网友
1楼 · 发布于 2024-06-28 10:47:21

您可以使用一个使用curl和xmlint的shell脚本来访问nexusapi并下载工件。在

下面是我如何从Nexus检索工件的示例:

NEXUS_BASE_URL=https://nexus.example.com
REPOSITORY="reponame"
GROUP_ID="groupid"
ARTIFACT_ID="artifact_id"
LOCAL_FILE="destination.jar"

NEXUS_RESOLVE_URL="${NEXUS_BASE_URL}artifact/maven/resolve?g=${GROUP_ID}a=${ARTIFACT_ID}&r=${REPOSITORY}&v=${VERSION}"
REPOSITORY_LOCAL_PATH=`curl -s "${NEXUS_RESOLVE_URL}" | xmllint  xpath "//artifact-resolution/data/repositoryPath/text()" -`
ARTIFACT_DOWNLOAD_URL="${NEXUS_BASE_URL}repositories/${REPOSITORY}/content${REPOSITORY_LOCAL_PATH}"
curl -o "${LOCAL_FILE}" "${ARTIFACT_DOWNLOAD_URL}"

有关解析atrifacts的更多信息可以在nexusapi参考中找到 https://repository.sonatype.org/nexus-restlet1x-plugin/default/docs/path__artifact_maven_resolve.html

相关问题 更多 >