gpt4 book ai didi

amazon-web-services - 从 aws lambda 触发 Gitlab-ci

转载 作者:行者123 更新时间:2023-12-04 04:13:09 25 4
gpt4 key购买 nike

我正在寻找可以触发 Gitlab-ci 管道部署特定分支并将结果发送到 slack 的 lambda。

谢谢。

最佳答案

触发管道

根据 GitLab Trigger API manual :

To trigger a job you need to send a POST request to GitLab’s API endpoint:

    curl -X POST <API url>/projects/<your_awesome_gitlab_project>/trigger/pipeline

The required parameters are the trigger’s token and the Git ref on which the trigger will be performed. Valid refs are the branch and the tag. The :id of a project can be found by querying the API or by visiting the CI/CD settings page which provides self-explanatory examples.

观察管道

要检查管道结果,请使用 CloudWatch Events :

You can set up a rule to run an AWS Lambda function on a schedule. This tutorial shows how to use the AWS Management Console or the AWS CLI to create the rule. If you would like to use the AWS CLI but have not installed it, see the AWS Command Line Interface User Guide.

要检查作业状态,请使用:Get a single pipelineList project pipelines API 调用。

curl --header "PRIVATE-TOKEN: ""https://gitlab.example.com/api/v4/projects/1/pipelines/46 "

通知 Slack

要使用 lambda 发送 Slack 通知,请使用本教程:

Creating an AWS Lambda Function and API Endpoint | Slack

关于端点安全的两分钱

CI 触发器由 token 保护.通常,它足以保护您的端点。

但是,如果这种方法还不够,还有一些技术可以“隐藏”端点:

关于amazon-web-services - 从 aws lambda 触发 Gitlab-ci,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/61340305/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com