Reputation: 43
Im looking for lambda that can trigger Gitlab-ci pipeline to deploy specific branches and send results to slack.
Thx.
Upvotes: 3
Views: 2469
Reputation: 4504
As per 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 Gitref
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.
To check pipeline results, use 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.
To check jobs status, use: Get a single pipeline or List project pipelines API calls.
curl --header "PRIVATE-TOKEN: " "https://gitlab.example.com/api/v4/projects/1/pipelines/46"
Slack
To send Slack
notifications with lambda
, use this tutorial:
Creating an AWS Lambda Function and API Endpoint | Slack
CI Trigger is secured by token. In general, it's enough for securing your endpoints.
But, if the approach isn't enough, there are some techniques to "hide" endpoints:
GitLab
AWS
Security Groups
for Lambda or for EC2 Nginx
or with HAProxyUpvotes: 1