我正在寻找一种方法,将构建工件作为Github Release在Jenkins上传为构建后操作或发布者 - 类似于Publish Over。
Jenkins的Github插件(JENKINS-18598)尚不支持。
我一直在研究postbuild-task插件,但这似乎不支持环境变量(我认为这有助于防止在构建输出中记录我的API令牌)。
有人这样做了吗?用Jenkins解决这个问题的好方法是什么?通过cURL或CLI客户端上传(例如,基于Go的github-release)。
答案 0 :(得分:26)
我使用github-release工具解决了这个问题。 像魅力一样非常容易。
echo "Compressing artifacts into one file"
zip -r artifacts.zip artifacts_folder
echo "Exporting token and enterprise api to enable github-release tool"
export GITHUB_TOKEN=$$$$$$$$$$$$
export GITHUB_API=https://git.{your domain}.com/api/v3 # needed only for enterprise
echo "Deleting release from github before creating new one"
github-release delete --user ${GITHUB_ORGANIZATION} --repo ${GITHUB_REPO} --tag ${VERSION_NAME}
echo "Creating a new release in github"
github-release release --user ${GITHUB_ORGANIZATION} --repo ${GITHUB_REPO} --tag ${VERSION_NAME} --name "${VERSION_NAME}"
echo "Uploading the artifacts into github"
github-release upload --user ${GITHUB_ORGANIZATION} --repo ${GITHUB_REPO} --tag ${VERSION_NAME} --name "${PROJECT_NAME}-${VERSION_NAME}.zip" --file artifacts.zip
答案 1 :(得分:12)
我认为你正在走上正轨!