##// END OF EJS Templates
docs: updated references for rhodecode extensions
marcink -
r3289:9530a430 default
parent child Browse files
Show More
@@ -1,77 +1,77 b''
1 1 .. _repo-xtra:
2 2
3 3 Repository Extra Fields
4 4 =======================
5 5
6 6 Extra fields attached to a |repo| allow you to configure additional fields for
7 7 each repository. This allows storing custom data per-repository.
8 8
9 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.
10 To read more about |RCX|, see the :ref:`integrations-rcextensions` section.
11 11
12 12
13 13 Enabling Extra Fields
14 14 ---------------------
15 15
16 16 To enable extra fields on |repos|, use the following steps:
17 17
18 18 1. Go to the :menuselection:`Admin --> Settings --> Visual` page.
19 19 2. Check the :guilabel:`Use repository extra fields` box.
20 20 3. Save your changes.
21 21
22 22
23 23 Configuring Extra Fields
24 24 ------------------------
25 25
26 26 To configure extra fields per repository, use the following steps:
27 27
28 28 1. Go to :menuselection:`Admin --> Repositories` and select :guilabel:`Edit`
29 29 beside the |repo| to which you wish to add extra fields.
30 30 2. On the |repo| settings page, select the :guilabel:`Extra fields` tab.
31 31
32 32 .. image:: ../images/extra-repo-fields.png
33 33
34 34 The most important is the `New field key` variable which under the value will
35 35 be stored. It needs to be unique for each repository. The label and description
36 36 will be generated in repository settings where users can actually save some
37 37 values inside generated extra fields.
38 38
39 39
40 40 Example Usage in extensions
41 41 ---------------------------
42 42
43 43 To use the extra fields in an extension, see the example below. For more
44 44 information and examples, see the :ref:`extensions-hooks-ref` section.
45 45
46 46 .. code-block:: python
47 47
48 48 call = load_extension('http_notify.py')
49 49 if call:
50 50 url = 'http://default.url' # <url for post data>
51 51
52 52 # possibly extract the URL from extra fields
53 53 call = load_extension('extra_fields.py')
54 54 if call:
55 55 repo_extra_fields = call(**kwargs)
56 56 # now update if we have extra fields, they have precedence
57 57 # this way users can store any configuration inside the database per
58 58 # repo
59 59 for key, data in repo_extra_fields.items():
60 60 kwargs[key] = data['field_value']
61 61
62 62 # an endpoint url data will be sent to, fetched from extra fields
63 63 # if exists, or fallback to default
64 64 kwargs['URL'] = kwargs.pop('webhook_url', None) or url
65 65
66 66 # fetch pushed commits, from commit_ids list
67 67 call = load_extension('extract_commits.py')
68 68 extracted_commits = {}
69 69 if call:
70 70 extracted_commits = call(**kwargs)
71 71 # store the commits for the next call chain
72 72 kwargs['COMMITS'] = extracted_commits
73 73
74 74 # set additional keys and values to be sent via POST to given URL
75 75 kwargs['caller_type'] = 'rhodecode'
76 76 kwargs['date'] = time.time() # import time before
77 77 call(**kwargs)
@@ -1,56 +1,51 b''
1 1 .. _repo-hooks:
2 2
3 3 |RCE| Repository Hooks
4 4 ======================
5 5
6 6 |RCE| installs hooks inside each of the |repos| that it manages. These
7 7 hooks enable users to execute custom actions based on certain events.
8 8 This is the complete list of |repos| hooks and the events which trigger them:
9 9
10 10 .. rst-class:: dl-horizontal
11 11
12 12 \--CREATE_REPO_HOOK
13 13 Any time a |repo| is created.
14 14
15 15 \--CREATE_REPO_GROUP_HOOK
16 16 Any time a |repo| group is created.
17 17
18 18 \--CREATE_USER_HOOK
19 19 Any time a user is created.
20 20
21 21 \--DELETE_REPO_HOOK
22 22 Any time a |repo| is created.
23 23
24 24 \--DELETE_USER_HOOK
25 25 Any time a user is deleted.
26 26
27 27 \--PRE_CREATE_USER_HOOK
28 28 Any time a user is created but before the action is executed by |RCE|.
29 29
30 30 \--PRE_PULL
31 31 Any pull from a |repo| but before the action is executed by |RCE|.
32 32
33 33 \--PRE_PUSH
34 34 Any push to a |repo| but before the action is executed by |RCE|.
35 35
36 36 \--POST_PUSH
37 37 After any push to a |repo|.
38 38
39 39 \--PUSH_HOOK
40 40 Any push to a |repo|, including editing tags or branches.
41 41 Commits via API actions that update references are also counted.
42 42
43 43 \--PULL_HOOK
44 44 Any pull from a Repository.
45 45
46 46 Using Repository Hooks
47 47 ----------------------
48 48
49 To use these hooks you need to install |RCX|. For more information, see the
50 :ref:`install-rcx` section.
49 To use these hooks you need to setup |RCX|. For more information, see the
50 :ref:`integrations-rcextensions` section.
51 51
52 Creating Extensions
53 -------------------
54
55 To create your own extensions using these hooks, see the :ref:`dev-plug`
56 section.
General Comments 0
You need to be logged in to leave comments. Login now