Thanks for contributing an answer to Stack Overflow! Please be sure to answer the question.Provide details and share your research! Asking for help, clarification, or responding to other answers.
Instead of having duplicate scripts inside your.gitlab-ci.yml, we created a Python script inside our repo. To make it more readable, we modified the Python script with Click!, turning it into a CLI. Uses the node and python image for this GitLab CI builds. As we are deploying python function using serverless framework and serverless framwork is based on npm so we need an image which consist both python and npm configuration. May 22, 2019 git add.gitlabci.yml git commit -m 'Updated.gitlabci.yml' git push origin master. GitLab Ci will see that there is a CI configuration file (.gitlab-ci.yml) and use this to run the pipeline: This is the start of a CI process for a python project! GitLab CI will run a linter (flake8) on every commit that is pushed up to GitLab for this project. See full list on section.io.
Project pipelines¶
A pipeline is a group of jobs executed by GitLab CI.
Reference¶
v4 API:
gitlab.v4.objects.Project.pipelines
GitLab API: https://docs.gitlab.com/ce/api/pipelines.html
Examples¶
List pipelines for a project:
Get a pipeline for a project:
Digital concepts cr-70r drivers. Get variables of a pipeline:
Create a pipeline for a particular reference with custom variables:
Retry the failed builds for a pipeline:
Cancel builds in a pipeline:
Delete a pipeline:
Triggers¶
Triggers provide a way to interact with the GitLab CI. Using a trigger a useror an application can run a new build/job for a specific commit.
Reference¶
v4 API:
gitlab.v4.objects.Project.triggers
GitLab API: https://docs.gitlab.com/ce/api/pipeline_triggers.html
Examples¶
List triggers:
Get a trigger:
Create a trigger:
Remove a trigger:
Full example with wait for finish:
You can trigger a pipeline using token authentication instead of userauthentication. To do so create an anonymous Gitlab instance and use lazyobjects to get the associated project:
Reference: https://docs.gitlab.com/ee/ci/triggers/#trigger-token
Pipeline schedule¶
You can schedule pipeline runs using a cron-like syntax. Variables can beassociated with the scheduled pipelines.
Reference¶
v4 API
gitlab.v4.objects.Project.pipelineschedules
gitlab.v4.objects.Project.pipelineschedules
GitLab API: https://docs.gitlab.com/ce/api/pipeline_schedules.html
Examples¶
List pipeline schedules:
Get a single schedule:
Create a new schedule:
Update a schedule:
Trigger a pipeline schedule immediately:
Delete a schedule:
List schedule variables:
Create a schedule variable:
Edit a schedule variable:
Delete a schedule variable:
Jobs¶
Jobs are associated to projects, pipelines and commits. They provideinformation on the jobs that have been run, and methods to manipulatethem.
Reference¶
v4 API
gitlab.v4.objects.Project.jobs
GitLab API: https://docs.gitlab.com/ce/api/jobs.html
Examples¶
Jobs are usually automatically triggered, but you can explicitly trigger a newjob:
List jobs for the project:
Get a single job:
List the jobs of a pipeline:
Note
Job methods (play, cancel, and so on) are not available onProjectPipelineJob
objects. To use these methods create a ProjectJob
object:
Get the artifacts of a job:
Get the artifacts of a job by its name from the latest successful pipeline ofa branch or tag:
project.artifacts(ref_name=’master’, job=’build’)
Warning
Artifacts are entirely stored in memory in this example.
You can download artifacts as a stream. Provide a callable to handle thestream:
You can also directly stream the output into a file, and unzip it afterwards:
Get a single artifact file:
Get a single artifact file by branch and job:
Gitlab Ci Python Example
Mark a job artifact as kept when expiration is set:
Delete the artifacts of a job:
Get a job trace:
Forum.gitlab.com › T › Execute-script-python-usingExecute Script Python Using Curl - GitLab CI/CD - GitLab Forum
Warning
Traces are entirely stored in memory unless you use the streaming feature.See the artifacts example.
Gitlab Ci Cd Example
Cancel/retry a job:
Play (trigger) a job:
Erase a job (artifacts and trace):
Pipeline bridges¶
Get a list of bridge jobs (including child pipelines) for a pipeline.
Reference¶
v4 API
gitlab.v4.objects.ProjectPipeline.bridges
GitLab API: https://docs.gitlab.com/ee/api/jobs.html#list-pipeline-bridges
Examples¶
List bridges for the pipeline:
Pipeline test report¶
Get a pipeline’s complete test report.
Reference¶
v4 API
gitlab.v4.objects.ProjectPipeline.test_report
GitLab API: https://docs.gitlab.com/ee/api/pipelines.html#get-a-pipelines-test-report
Examples¶
Get the test report for a pipeline: