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