-
Notifications
You must be signed in to change notification settings - Fork 665
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
3f67c4b
commit d5de4b1
Showing
5 changed files
with
98 additions
and
43 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
####### | ||
CI Lint | ||
####### | ||
|
||
Reference | ||
--------- | ||
|
||
* v4 API: | ||
|
||
+ :class:`gitlab.v4.objects.CiLint` | ||
+ :class:`gitlab.v4.objects.CiLintManager` | ||
+ :attr:`gitlab.Gitlab.ci_lint` | ||
+ :class:`gitlab.v4.objects.ProjectCiLint` | ||
+ :class:`gitlab.v4.objects.ProjectCiLintManager` | ||
+ :attr:`gitlab.v4.objects.Project.ci_lint` | ||
|
||
* GitLab API: https://docs.gitlab.com/ee/api/lint.html | ||
|
||
Examples | ||
--------- | ||
|
||
Validate a CI YAML configuration:: | ||
|
||
gitlab_ci_yml = """.api_test: | ||
rules: | ||
- if: $CI_PIPELINE_SOURCE=="merge_request_event" | ||
changes: | ||
- src/api/* | ||
deploy: | ||
extends: | ||
- .api_test | ||
rules: | ||
- when: manual | ||
allow_failure: true | ||
script: | ||
- echo "hello world" | ||
""" | ||
lint_result = gl.ci_lint.create({"content": gitlab_ci_yml}) | ||
|
||
print(lint_result.status) # Print the status of the CI YAML | ||
print(lint_result.merged_yaml) # Print the merged YAML file | ||
|
||
Validate a project's CI configuration:: | ||
|
||
lint_result = project.ci_lint.get() | ||
assert lint_result.valid is True # Test that the .gitlab-ci.yml is valid | ||
print(lint_result.merged_yaml) # Print the merged YAML file | ||
|
||
Validate a CI YAML configuration with a namespace:: | ||
|
||
lint_result = project.ci_lint.create({"content": gitlab_ci_yml}) | ||
assert lint_result.valid is True # Test that the .gitlab-ci.yml is valid | ||
print(lint_result.merged_yaml) # Print the merged YAML file |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters