从GitLab运行器/管道中创建发布 [英] Create releases from within a GitLab runner/pipeline

查看:175
本文介绍了从GitLab运行器/管道中创建发布的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

随着2019年1月Gitlab 11.7的发布,我们获得了新的关键功能发布API .

With the release of Gitlab 11.7 in January 2019, we get the new key feature Publish releases for your projects. I want precisely what the screenshot on that page shows and I want to be able to download compiled binaries using the releases API.

我可以手动完成.当然,可以在堆栈溢出此处找到手动方法的说明.我需要帮助的问题是,它是作为CI/CD管道的一部分来完成的,因此您无法轻易找到答案.

I can do it manually. Of course, instructions for the manual approach can be found here on stack overflow. The problem I need help with is doing it as part of a CI/CD pipeline, which is not covered by the answers one can find easily.

发行说明包含指向文档的链接,哪个状态:

The release notes contain a link to the documentation, which states:

我们建议您将此操作作为CI/CD发行流程中的最后步骤之一.

we recommend doing this as one of the last steps in your CI/CD release pipeline.

据此我认为这是可能的.但是,我能想象的唯一方法是像手动创建发行版一样使用GitLab API.根据高级手册<<,/a>:OAUTH2令牌,个人访问令牌和会话cookie.因此,我将需要一种具有足够特权的方法来在我的CI/CD管道中提供这两种方法中的任何一种.这个问题的解决方案是一个持续不断的讨论,并做出了许多贡献,但近年来却没有实质性进展.

From this I gather it's possible. However, the only approach I can imagine is using the GitLab API just as I do, when I create releases manually. When one wants to access the GitLab API one has essentially three options for authentication, according to the fine manual: OAUTH2 tokens, personal access tokens and session cookies. Consequently I would need a method for having either of these available in my CI/CD pipeline, with sufficient privileges. Solutions for this problem are an ongoing discussion with lots of contributions, but virtually no tangible progress in recent years.

那么,如何创建发布作为CI/CD发布管道中的最后一步之一?

So, how does one create releases as one of the last steps in one's CI/CD release pipeline?

出于明显的原因,无法选择将具有API访问权限的个人访问密钥存储在CI/CD变量中,甚至将文件存储在存储库中.

Storing my personal access key with API access in a CI/CD variable or even a file in the repo is not an option for obvious reasons.

推荐答案

他们张贴了一篇博客文章,解释了如何执行此操作:

They've put up a blog post explaining how to do this:

https://about.gitlab. com/blog/2020/05/07/how-gitlab-automates-releases/

他们创建了一个工具(gitlab-releaser)来帮助完成此任务.基本上,您将创建一个新步骤,在其中使用提供此工具的docker映像,然后使用适当的参数调用该工具.

They've created a tool (gitlab-releaser) to help with this task. Basically you create a new step, where you use a docker image that provides this tool, and then call the tool with the proper parameters.

release_upload:
  image: registry.gitlab.com/gitlab-org/release-cli:v0.1.0
  script:
    - gitlab-releaser create --name="My Release" --description="My Release description"

这篇关于从GitLab运行器/管道中创建发布的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆