Show More
@@ -1,68 +1,77 b'' | |||
|
1 | 1 | .. _repo-xtra: |
|
2 | 2 | |
|
3 | 3 | Repository Extra Fields |
|
4 | 4 | ======================= |
|
5 | 5 | |
|
6 |
Extra fields attached to a |repo| allow you to configure additional |
|
|
7 | |RCX|. To install and read more about |RCX|, see the :ref:`install-rcx` section. | |
|
6 | Extra fields attached to a |repo| allow you to configure additional fields for | |
|
7 | each repository. This allows storing custom data per-repository. | |
|
8 | ||
|
9 | It can be used in :ref:`integrations-webhook` or in |RCX|. | |
|
10 | To install and read more about |RCX|, see the :ref:`install-rcx` section. | |
|
11 | ||
|
8 | 12 | |
|
9 | 13 | Enabling Extra Fields |
|
10 | 14 | --------------------- |
|
11 | 15 | |
|
12 | 16 | To enable extra fields on |repos|, use the following steps: |
|
13 | 17 | |
|
14 | 18 | 1. Go to the :menuselection:`Admin --> Settings --> Visual` page. |
|
15 | 19 | 2. Check the :guilabel:`Use repository extra fields` box. |
|
16 | 20 | 3. Save your changes. |
|
17 | 21 | |
|
18 | 22 | |
|
19 | 23 | Configuring Extra Fields |
|
20 | 24 | ------------------------ |
|
21 | 25 | |
|
22 | 26 | To configure extra fields per repository, use the following steps: |
|
23 | 27 | |
|
24 | 28 | 1. Go to :menuselection:`Admin --> Repositories` and select :guilabel:`Edit` |
|
25 | 29 | beside the |repo| to which you wish to add extra fields. |
|
26 | 30 | 2. On the |repo| settings page, select the :guilabel:`Extra fields` tab. |
|
27 | 31 | |
|
28 | 32 | .. image:: ../images/extra-repo-fields.png |
|
29 | 33 | |
|
34 | The most important is the `New field key` variable which under the value will | |
|
35 | be stored. It needs to be unique for each repository. The label and description | |
|
36 | will be generated in repository settings where users can actually save some | |
|
37 | values inside generated extra fields. | |
|
30 | 38 | |
|
31 | Example Usage | |
|
32 | ------------- | |
|
39 | ||
|
40 | Example Usage in extensions | |
|
41 | --------------------------- | |
|
33 | 42 | |
|
34 | 43 | To use the extra fields in an extension, see the example below. For more |
|
35 | 44 | information and examples, see the :ref:`extensions-hooks-ref` section. |
|
36 | 45 | |
|
37 | 46 | .. code-block:: python |
|
38 | 47 | |
|
39 | 48 | call = load_extension('http_notify.py') |
|
40 | 49 | if call: |
|
41 | 50 | url = 'http://default.url' # <url for post data> |
|
42 | 51 | |
|
43 | 52 | # possibly extract the URL from extra fields |
|
44 | 53 | call = load_extension('extra_fields.py') |
|
45 | 54 | if call: |
|
46 | 55 | repo_extra_fields = call(**kwargs) |
|
47 | 56 | # now update if we have extra fields, they have precedence |
|
48 | 57 | # this way users can store any configuration inside the database per |
|
49 | 58 | # repo |
|
50 | 59 | for key, data in repo_extra_fields.items(): |
|
51 | 60 | kwargs[key] = data['field_value'] |
|
52 | 61 | |
|
53 | 62 | # an endpoint url data will be sent to, fetched from extra fields |
|
54 | 63 | # if exists, or fallback to default |
|
55 | 64 | kwargs['URL'] = kwargs.pop('webhook_url', None) or url |
|
56 | 65 | |
|
57 | 66 | # fetch pushed commits, from commit_ids list |
|
58 | 67 | call = load_extension('extract_commits.py') |
|
59 | 68 | extracted_commits = {} |
|
60 | 69 | if call: |
|
61 | 70 | extracted_commits = call(**kwargs) |
|
62 | 71 | # store the commits for the next call chain |
|
63 | 72 | kwargs['COMMITS'] = extracted_commits |
|
64 | 73 | |
|
65 | 74 | # set additional keys and values to be sent via POST to given URL |
|
66 | 75 | kwargs['caller_type'] = 'rhodecode' |
|
67 | 76 | kwargs['date'] = time.time() # import time before |
|
68 | 77 | call(**kwargs) |
General Comments 0
You need to be logged in to leave comments.
Login now