【问题标题】:How to get a jar file from nexus using Jenkins?如何使用 Jenkins 从 nexus 获取 jar 文件?
【发布时间】:2018-03-08 16:31:11
【问题描述】:

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

请注意,Jenkins 配置中提供了 Nexus URL,因此它会自动知道从哪里查找。

你知道怎么做吗!

例如,对于 python 应用程序,我使用pip download --no-deps ARTIFACT_ID==APP_VERSION,它可以正常工作。

【问题讨论】:

  • Nexus 3 支持 PyPi 吗?

标签: java python maven jenkins jar


【解决方案1】:

您可以使用带有 curl 和 xmllint 的 shell 脚本来访问 Nexus api 并下载工件。

这是我如何从 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 的更多信息可以在 nexus api 参考中找到 https://repository.sonatype.org/nexus-restlet1x-plugin/default/docs/path__artifact_maven_resolve.html

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2015-10-04
    • 1970-01-01
    • 2012-04-28
    • 1970-01-01
    • 2014-01-11
    • 1970-01-01
    • 1970-01-01
    • 2012-05-19
    相关资源
    最近更新 更多