从 GitLab 运行程序/管道中创建版本 [英] Create releases from within a GitLab runner/pipeline

查看:30
本文介绍了从 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,当我手动创建版本时.根据精美手册: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天全站免登陆