Gitlab Pipeline Run Python Script

  1. See Full List On Blueskyjunkie.ca
  2. Gitlab Pipeline Api
  3. Cached

Gitlab ships with its own free CICD which works pretty well. This post will give you an example of the CICD file .gitlab-ci.yml for a Python project running on Gitlab Windows runner.

P Python Pipeline Project information Project information Activity Labels Members Repository Repository Files Commits Branches Tags Contributors Graph Compare Locked Files Issues 0 Issues 0 List Boards Service Desk Milestones Iterations Merge requests 0 Merge requests 0 Requirements Requirements CI/CD CI/CD Pipelines Jobs Schedules Test Cases. Jun 14, 2020 tests: our Python script to validate YAML syntax will go in here vars: YAML variable files gitlab-ci.yml: pipeline configuration file, this is where we define our stages and jobs. Test:pylint: image: python:3.6 script: - pip install pylint - quiet - pylint - ignored - classes=socketobject.py. Test:pylint is simply the name of the job. You can choose whatever you want. The rest of the code indicates that gitlab-runner should use the docker image python:3.6, and run the mentioned commands. See full list on blueskyjunkie.ca.

Gitlab pipeline variable

The official doc on how to use coverage is not very clear.

My coverage tool’s output (from pytest --cov=) is something like :

See Full List On Blueskyjunkie.ca

In my example .gitlab-ci.yml, the coverage is configured as:

Gitlab Pipeline Api

This regex will find the coverage which is at 81%.

See full list on section.io

Be aware that:

  1. The coverage only use regular expression to find the coverage percentage from coverage tool’s output.
  2. The regular expression must be surrounded by single quote ', double quote is not allowed.
  3. Inside the single quotes, must be surrounded by /.
  4. You can use http://rubular.com to test your regex.
  5. The overage regex returns the last catch group value from the output. Even if it is not in the last line, or if the regex catches more than one values among all the lines.
Gitlab Pipeline Run Python Script

.gitlab-ci.yml file content

I cloned the project flask_log_request_id and try to run CICD over it.

I’m still working on this CICD .gitlab-ci.yml file, the example given here will be updated as long as I add new things inside.

.gitlab-ci.yml results from pipeline view

.gitlab-ci.yml results from job view

Setting up Gitlab

Cached

.gitlab-ci.yml results from merge_request view