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