Skip to content
This repository was archived by the owner on Aug 4, 2023. It is now read-only.

Commit 232c412

Browse files
updated how to create projects with gcip in user doc
1 parent f322059 commit 232c412

File tree

1 file changed

+45
-10
lines changed

1 file changed

+45
-10
lines changed

docs/user/index.adoc

Lines changed: 45 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -17,16 +17,25 @@ For the code documentation please proceed to the xref:./gcip/README.adoc[README.
1717

1818
== Configuring your project to use gcip
1919

20-
Create a `.gitlab-ci.yaml` with following static content:
20+
Your Gitlab project needs these two files:
21+
22+
____
23+
MyProject
24+
├ .gitlab-ci.py
25+
└ .gitlab-ci.yml
26+
____
27+
28+
The `.gitlab-ci.yml` is the file you already know. It's only task is to
29+
render and trigger the child Pipeline created with the Gitlab CI Python Library.
30+
Latter is written into the `.gitlab-ci.py`. Here is how your `.gitlab-ci.yml` should
31+
look like:
2132

2233
----
2334
---
2435
generate-pipeline:
2536
stage: build
26-
image: python:3
27-
script:
28-
- pip3 install -r requirements.txt
29-
- python3 .gitlab-ci.py > generated-config.yml
37+
image: thomass/gcip:0.3.0
38+
script: /usr/src/app/docker/gcip.sh
3039
artifacts:
3140
paths:
3241
- generated-config.yml
@@ -42,17 +51,43 @@ run-pipeline:
4251
strategy: depend
4352
----
4453

45-
Your gcip pipeline code then goes into a file named `.gitlab-ci.py`.
54+
Your gcip pipeline code then goes into the file named `.gitlab-ci.py`. The following
55+
chapers show to crete the pipeline code.
4656

4757
== Hints regarding the following examples
4858

4959
All the code examples in the following chapters are made for also be run with Pytest.
50-
Thus to use the code for your real life Gitlab CI pipeline you have to change the following:
60+
For instance a code example could look like following:
61+
62+
----
63+
import gcip
64+
from tests import conftest
65+
66+
67+
def test():
68+
pipeline = gcip.Pipeline()
69+
pipeline.add_children(gcip.Job(namespace="print_date", script="date"))
70+
71+
conftest.check(pipeline.render())
72+
----
73+
74+
To transform this pytest into a valid `.gitlab-ci.py` file your have to:
5175

5276
* Omit the import `from tests import conftest`.
5377
* Put your pipeline code plain into the Python script and not within the `def test():` method.
54-
* Instead of routing the pipeline output to the test method (`conftest.check(pipeline.render())`)
55-
print the resulting pipeline to STDOUT with `pipeline.print_yaml()`.
78+
* Instead of testing rendered pipelin with `conftest.check(pipeline.render())` you have to
79+
write the `generated-pipeline.yml` with `pipeline.write_yaml()`.
80+
81+
The real `.gitlab-ci.py` code derived from the example would look like following:
82+
83+
----
84+
from tests import conftest
85+
86+
pipeline = gcip.Pipeline()
87+
pipeline.add_children(gcip.Job(namespace="print_date", script="date"))
88+
89+
pipeline.write_yaml()
90+
----
5691

5792
== Create a pipeline with one job
5893

@@ -64,7 +99,7 @@ include::../../tests/unit/test_readme_pipe_with_one_job.py[]
6499
----
65100

66101
Remember: As stated in the <<hints-regarding-the-following-examples,hints regarding the examples>>,
67-
your real pipeline code must end with `pipeline.print_yaml()` instead of `conftest.check(pipeline.render())`!
102+
your real pipeline code must end with `pipeline.write_yaml()` instead of `conftest.check(pipeline.render())`!
68103

69104
*Output:*
70105

0 commit comments

Comments
 (0)