##// END OF EJS Templates
release: merge back stable branch into default
marcink -
r2895:5aa6464f merge default
parent child Browse files
Show More
1 NO CONTENT: new file 100644, binary diff hidden
1 NO CONTENT: new file 100644, binary diff hidden
1 NO CONTENT: new file 100644, binary diff hidden
1 NO CONTENT: new file 100644, binary diff hidden
1 NO CONTENT: new file 100644, binary diff hidden
@@ -0,0 +1,113 b''
1 .. _integrations-jenkins:
2
3 Jenkins integration
4 ===================
5
6 .. important::
7
8 Jenkins integration is only available in |RCEE|.
9
10
11
12 Below are few examples how to use dedicated Jenkins integrations with |RCEE|.
13
14
15
16 Configure Jenkins to check each commit after push
17 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
18
19 In order to configure Jenkins to trigger a build on a project after each push we
20 need to create a project that will allow triggering a build from external sources.
21
22 In Jenkins, check `Trigger builds remotely (e.g., from scripts)` option. This gives
23 now ability to trigger builds using an URL.
24
25 .. image:: ../images/jenkins-build-with-parameters.png
26
27 We also need to specify the parameters we're going to build the project with.
28 In this example we'll use build with 3 parameters `COMMIT_ID`, `BRANCH_HEAD` and `BRANCH`.
29 In Jenkins we need to add those 3 parameters, and check an option
30 `This project is parameterised`
31
32 .. image:: ../images/jenkins-adding-build-parameters.png
33
34
35 Our final URL that |RCEE| Jenkins integration would use could look like this:
36
37 This URL will be triggered for each pushed branch, and will include the branch head commit id.
38
39 https://jenkins.server.com/job/test-build-commits/buildWithParameters?token=secret&BRANCH=${branch}&BRANCH_HEAD=${branch_head}
40
41 Or we can also use commit_id in this case URL will be triggered for each pushed commit in the branch, and will include the commit id.
42
43 https://jenkins.server.com/job/test-build-commits/buildWithParameters?token=secret&BRANCH=${branch}&COMMIT_ID=${commit_id}
44
45
46 Now we have all the required information to fetch/checkout and test our project.
47 We can write an example build common in Jenkins.
48
49
50 .. image:: ../images/jenkins-build-command.png
51
52
53 Below is an example of the integration page we used on |RCEE| side.
54
55
56 .. image:: ../images/rhodecode-jenkins-integration-settings.png
57
58
59
60 Configure Jenkins to check each pull-request on creation and updates
61 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
62
63 Jenkins integration also allows checking created pull-requests inside |RCCE|. This is
64 somehow a special case compared to testing commits. The pull-requests cannot be cloned
65 from the repository. Instead |RCCE| exposes different links back to CI systems which
66 store information on how to obtain the pull-request code.
67
68 On |RCCE| side we need to create a new integration that would use only two events:
69
70 - pullrequest created
71 - pullrequest commits updated
72
73 This will trigger the builds when pull-request is firstly created, and then each time
74 pull-requests is updated and commits that it stores change.
75
76
77 In Jenkins, we should create at least two new build string parameters.
78 We could use `PR_ID` and `SHADOW_URL`.
79 Using those parameters, we can then create a customized build command to checkout a
80 merged state of pull-request. And later on using rhodecode-api notify about the checks
81 using the `PR_ID`.
82
83
84 .. image:: ../images/jenkins-pr-build-command.png
85
86
87 There's even a helper script we created to send notifications.
88 Here's how the build on success could look like in Jenkins.
89
90 .. code-block:: bash
91
92 # clone the ci-notify script, and save it into our $BUILD_TAG/notify directory
93 hg clone https://code.rhodecode.com/ci-notify $BUILD_TAG/notify
94
95 # execute the script. $RC_TOKEN is auth-token for API
96 # url is your rhodecode instance, repoid is repository project which PR was opened
97 # status could be "approved" or "rejected"
98 python $BUILD_TAG/notify/notify.py \
99 --token $RC_TOKEN \
100 --url https://code.server.com \
101 --repoid my-example-project \
102 --prid $PR_ID \
103 --status "approved" \
104 --message "Build Succeeded: $BUILD_URL"
105
106
107 Below is also an example that we could use on |RCCE| side in the Jenkins integration settings.
108 A Jenkins Trigger url that exposes all required information back to Jenkins CI server:
109
110 .. code-block:: bash
111
112 http://jenkins.server.com/job/my-project-pull-request-tests/buildWithParameters?token=secret&PR_ID=${pull_request_id}&PR_TITLE=${pull_request_title}&SHADOW_URL=${pull_request_shadow_url}&PR_UID=${pull_request_commits_uid}
113
@@ -0,0 +1,47 b''
1 |RCE| 4.12.4 |RNS|
2 ------------------
3
4 Release Date
5 ^^^^^^^^^^^^
6
7 - 2018-07-13
8
9
10 New Features
11 ^^^^^^^^^^^^
12
13
14
15 General
16 ^^^^^^^
17
18
19
20 Security
21 ^^^^^^^^
22
23
24
25 Performance
26 ^^^^^^^^^^^
27
28
29
30 Fixes
31 ^^^^^
32
33 - Repository: fixed problems with mercurial/git url validators.
34 - User Groups: fixed audit log data on user group permissions view.
35 This caused an 500 error when editing user groups.
36 - Authentication: fixed problem with displaying social auth providers in the login page.
37 - Google Authentication: updated google user info api to latest version. The previous
38 endpoint was deprecated and it caused problems with Google authentication.
39 - API: fixed problem with setting recursive permissions changes to repo group.
40 - API: fixed problem with creation of pull request with custom reviewers rules.
41 - API: fixed problem with proper diff calculation with using pull-request API.
42
43
44 Upgrade notes
45 ^^^^^^^^^^^^^
46
47 - Scheduled release addressing reported problems, and improving stability.
@@ -1,41 +1,42 b''
1 1 1bd3e92b7e2e2d2024152b34bb88dff1db544a71 v4.0.0
2 2 170c5398320ea6cddd50955e88d408794c21d43a v4.0.1
3 3 c3fe200198f5aa34cf2e4066df2881a9cefe3704 v4.1.0
4 4 7fd5c850745e2ea821fb4406af5f4bff9b0a7526 v4.1.1
5 5 41c87da28a179953df86061d817bc35533c66dd2 v4.1.2
6 6 baaf9f5bcea3bae0ef12ae20c8b270482e62abb6 v4.2.0
7 7 32a70c7e56844a825f61df496ee5eaf8c3c4e189 v4.2.1
8 8 fa695cdb411d294679ac081d595ac654e5613b03 v4.3.0
9 9 0e4dc11b58cad833c513fe17bac39e6850edf959 v4.3.1
10 10 8a876f48f5cb1d018b837db28ff928500cb32cfb v4.4.0
11 11 8dd86b410b1aac086ffdfc524ef300f896af5047 v4.4.1
12 12 d2514226abc8d3b4f6fb57765f47d1b6fb360a05 v4.4.2
13 13 27d783325930af6dad2741476c0d0b1b7c8415c2 v4.5.0
14 14 7f2016f352abcbdba4a19d4039c386e9629449da v4.5.1
15 15 416fec799314c70a5c780fb28b3357b08869333a v4.5.2
16 16 27c3b85fafc83143e6678fbc3da69e1615bcac55 v4.6.0
17 17 5ad13deb9118c2a5243d4032d4d9cc174e5872db v4.6.1
18 18 2be921e01fa24bb102696ada596f87464c3666f6 v4.7.0
19 19 7198bdec29c2872c974431d55200d0398354cdb1 v4.7.1
20 20 bd1c8d230fe741c2dfd7100a0ef39fd0774fd581 v4.7.2
21 21 9731914f89765d9628dc4dddc84bc9402aa124c8 v4.8.0
22 22 c5a2b7d0e4bbdebc4a62d7b624befe375207b659 v4.9.0
23 23 d9aa3b27ac9f7e78359775c75fedf7bfece232f1 v4.9.1
24 24 4ba4d74981cec5d6b28b158f875a2540952c2f74 v4.10.0
25 25 0a6821cbd6b0b3c21503002f88800679fa35ab63 v4.10.1
26 26 434ad90ec8d621f4416074b84f6e9ce03964defb v4.10.2
27 27 68baee10e698da2724c6e0f698c03a6abb993bf2 v4.10.3
28 28 00821d3afd1dce3f4767cc353f84a17f7d5218a1 v4.10.4
29 29 22f6744ad8cc274311825f63f953e4dee2ea5cb9 v4.10.5
30 30 96eb24bea2f5f9258775245e3f09f6fa0a4dda01 v4.10.6
31 31 3121217a812c956d7dd5a5875821bd73e8002a32 v4.11.0
32 32 fa98b454715ac5b912f39e84af54345909a2a805 v4.11.1
33 33 3982abcfdcc229a723cebe52d3a9bcff10bba08e v4.11.2
34 34 33195f145db9172f0a8f1487e09207178a6ab065 v4.11.3
35 35 194c74f33e32bbae6fc4d71ec5a999cff3c13605 v4.11.4
36 36 8fbd8b0c3ddc2fa4ac9e4ca16942a03eb593df2d v4.11.5
37 37 f0609aa5d5d05a1ca2f97c3995542236131c9d8a v4.11.6
38 38 b5b30547d90d2e088472a70c84878f429ffbf40d v4.12.0
39 39 9072253aa8894d20c00b4a43dc61c2168c1eff94 v4.12.1
40 40 6a517543ea9ef9987d74371bd2a315eb0b232dc9 v4.12.2
41 41 7fc0731b024c3114be87865eda7ab621cc957e32 v4.12.3
42 6d531c0b068c6eda62dddceedc9f845ecb6feb6f v4.12.4
@@ -1,97 +1,100 b''
1 1 .. _integrations-ci:
2 2
3 3 CI Server integration
4 4 =====================
5 5
6 6
7 7 RhodeCode :ref:`integrations-webhook` integration is a powerfull tool to allow
8 8 interaction with systems like Jenkin, Bamboo, TeamCity, CircleCi or any other
9 9 CI server that allows triggering a build using HTTP call.
10 10
11 11 Below are few examples on how to use :ref:`integrations-webhook` to trigger
12 12 a CI build.
13 13
14 14
15 15 General Webhook
16 16 +++++++++++++++
17 17
18 18 :ref:`integrations-webhook` allows sending a JSON payload information to specified
19 url with GET or POST methods. There are several variables that could be used
19 custom URL with GET or POST methods. There are several variables that could be used
20 20 in the URL greatly extending the flexibility of this type of integration.
21 21
22 22 Most of the modern CI systems such as Jenkins, TeamCity, Bamboo or CircleCi
23 23 allows triggering builds via GET or POST calls.
24 24
25 25 :ref:`integrations-webhook` can be either specified per each repository or
26 26 globally, if your CI maps directly to all your projects a global
27 27 :ref:`integrations-webhook` integration can be created and will trigger builds
28 28 for each change in projects. If only some projects allow triggering builds a
29 29 global integration will also work because mostly a CI system will ignore a
30 30 call for unspecified builds.
31 31
32 32
33 33 .. note::
34 34
35 35 A quick note on security. It's recommended to allow IP restrictions
36 36 to only allow RhodeCode server to trigger builds. If you need to
37 37 specify username and password this could be done by embedding it into a
38 38 trigger URL, e.g. `http://user:password@server.com/job/${project_id}`
39 39
40 40
41 41 If users require to provide any custom parameters, they can be stored for each
42 42 project inside the :ref:`repo-xtra`. For example to migrate a current job that
43 43 has a numeric build id, storing this as `jenkins_build_id` key extra field
44 44 the url would look like that::
45 45
46 46 http://server/job/${extra:jenkins_build_id}/
47 47
48 48
49 49 .. note::
50 50
51 51 Please note that some variables will result in multiple calls.
52 52 e.g. for |HG| specifying `${branch}` will trigger as many builds as how
53 many branches the suer actually pushed. Same applies to `${commit_id}`
53 many branches the user actually pushed. Same applies to `${commit_id}`
54 54 This will trigger many builds if many commits are pushed. This allows
55 55 triggering individual builds for each pushed commit.
56 56
57 57
58 58 Jenkins
59 59 +++++++
60 60
61 61 To use Jenkins CI with RhodeCode, a Jenkins Build with Parameters should be used.
62 62 Plugin details are available here: https://wiki.jenkins.io/display/JENKINS/Build+With+Parameters+Plugin
63 63
64 64 If the plugin is configured, RhodeCode can trigger builds automatically by
65 65 calling such example url provided in :ref:`integrations-webhook` integration::
66 66
67 67 http://server/job/${project_id}/build-branch-${branch}/buildWithParameters?token=TOKEN&PARAMETER=value&PARAMETER2=value2
68 68
69 The |RCEE| includes a custom :ref:`integrations-jenkins` integration. That allows using some
70 of Jenkins added security features. Please check also the above link for more examples.
71
69 72
70 73 Team City
71 74 +++++++++
72 75
73 76 To use TeamCity CI it's enough to call the API and provide a buildId.
74 77 Example url after configuring :ref:`repo-xtra` would look like that::
75 78
76 79 http://teacmtiyserver/viewType.html?buildTypeId=${extra:tc_build_id}
77 80
78 81
79 82 Each project can have many build configurations.
80 83 buildTypeId which is a unique ID for each build configuration (job).
81 84
82 85
83 86 CircleCi
84 87 ++++++++
85 88
86 89 To use CircleCi, a POST call needs to be triggered. Example build url would
87 90 look like this::
88 91
89 92 http://cicleCiServer/project/${repo_type}/${username}/${repo_id}/tree/${branch}
90 93
91 94
92 95 Circle Ci expects format of::
93 96
94 97 POST: /project/:vcs-type/:username/:project/tree/:branch
95 98
96 99
97 100 CircleCi API documentation can be found here: https://circleci.com/docs/api/v1-reference/
@@ -1,55 +1,57 b''
1 1 .. _integrations:
2 2
3 3 Integrations
4 4 ------------
5 5
6 6 Rhodecode supports integrations with external services for various events,
7 7 such as commit pushes and pull requests. Multiple integrations of the same type
8 8 can be added at the same time; this is useful for posting different events to
9 9 different Slack channels, for example.
10 10
11 11 Supported integrations
12 12 ^^^^^^^^^^^^^^^^^^^^^^
13 13
14 14 ============================ ============ =====================================
15 15 Type/Name |RC| Edition Description
16 16 ============================ ============ =====================================
17 17 :ref:`integrations-slack` |RCCEshort| https://slack.com/
18 18 :ref:`integrations-hipchat` |RCCEshort| https://www.hipchat.com/
19 19 :ref:`integrations-webhook` |RCCEshort| POST events as `json` to a custom url
20 20 :ref:`integrations-ci` |RCCEshort| Trigger Builds for Common CI Systems
21 21 :ref:`integrations-email` |RCCEshort| Send repo push commits by email
22 :ref:`integrations-redmine` |RCEEshort| Close/Resolve/Reference redmine issues
22 :ref:`integrations-jenkins` |RCEEshort| Trigger Builds for Jenkins CI System
23 :ref:`integrations-redmine` |RCEEshort| Close/Resolve/Reference Redmine issues
23 24 :ref:`integrations-jira` |RCEEshort| Close/Resolve/Reference JIRA issues
24 25 ============================ ============ =====================================
25 26
26 27 .. _creating-integrations:
27 28
28 29 Creating an Integration
29 30 ^^^^^^^^^^^^^^^^^^^^^^^
30 31
31 32 Integrations can be added globally via the admin UI:
32 33
33 34 :menuselection:`Admin --> Integrations`
34 35
35 36 or per repository in each repository's settings:
36 37
37 38 :menuselection:`Admin --> Repositories --> Edit --> Integrations`
38 39
39 40 To create an integration, select the type from the list in the *Create New
40 41 Integration* section.
41 42
42 43 The *Current Integrations* section shows existing integrations that have been
43 44 created along with their type (eg. Slack) and enabled status.
44 45
45 46 See pages specific to each type of integration for more instructions:
46 47
47 48 .. toctree::
48 49
49 50 slack
50 51 hipchat
51 52 redmine
52 53 jira
53 54 webhook
54 55 email
55 56 ci
57 jenkins
@@ -1,118 +1,119 b''
1 1 .. _rhodecode-release-notes-ref:
2 2
3 3 Release Notes
4 4 =============
5 5
6 6 |RCE| 4.x Versions
7 7 ------------------
8 8
9 9 .. toctree::
10 10 :maxdepth: 1
11 11
12 release-notes-4.12.4.rst
12 13 release-notes-4.12.3.rst
13 14 release-notes-4.12.2.rst
14 15 release-notes-4.12.1.rst
15 16 release-notes-4.12.0.rst
16 17 release-notes-4.11.6.rst
17 18 release-notes-4.11.5.rst
18 19 release-notes-4.11.4.rst
19 20 release-notes-4.11.3.rst
20 21 release-notes-4.11.2.rst
21 22 release-notes-4.11.1.rst
22 23 release-notes-4.11.0.rst
23 24 release-notes-4.10.6.rst
24 25 release-notes-4.10.5.rst
25 26 release-notes-4.10.4.rst
26 27 release-notes-4.10.3.rst
27 28 release-notes-4.10.2.rst
28 29 release-notes-4.10.1.rst
29 30 release-notes-4.10.0.rst
30 31 release-notes-4.9.1.rst
31 32 release-notes-4.9.0.rst
32 33 release-notes-4.8.0.rst
33 34 release-notes-4.7.2.rst
34 35 release-notes-4.7.1.rst
35 36 release-notes-4.7.0.rst
36 37 release-notes-4.6.1.rst
37 38 release-notes-4.6.0.rst
38 39 release-notes-4.5.2.rst
39 40 release-notes-4.5.1.rst
40 41 release-notes-4.5.0.rst
41 42 release-notes-4.4.2.rst
42 43 release-notes-4.4.1.rst
43 44 release-notes-4.4.0.rst
44 45 release-notes-4.3.1.rst
45 46 release-notes-4.3.0.rst
46 47 release-notes-4.2.1.rst
47 48 release-notes-4.2.0.rst
48 49 release-notes-4.1.2.rst
49 50 release-notes-4.1.1.rst
50 51 release-notes-4.1.0.rst
51 52 release-notes-4.0.1.rst
52 53 release-notes-4.0.0.rst
53 54
54 55 |RCE| 3.x Versions
55 56 ------------------
56 57
57 58 .. toctree::
58 59 :maxdepth: 1
59 60
60 61 release-notes-3.8.4.rst
61 62 release-notes-3.8.3.rst
62 63 release-notes-3.8.2.rst
63 64 release-notes-3.8.1.rst
64 65 release-notes-3.8.0.rst
65 66 release-notes-3.7.1.rst
66 67 release-notes-3.7.0.rst
67 68 release-notes-3.6.1.rst
68 69 release-notes-3.6.0.rst
69 70 release-notes-3.5.2.rst
70 71 release-notes-3.5.1.rst
71 72 release-notes-3.5.0.rst
72 73 release-notes-3.4.1.rst
73 74 release-notes-3.4.0.rst
74 75 release-notes-3.3.4.rst
75 76 release-notes-3.3.3.rst
76 77 release-notes-3.3.2.rst
77 78 release-notes-3.3.1.rst
78 79 release-notes-3.3.0.rst
79 80 release-notes-3.2.3.rst
80 81 release-notes-3.2.2.rst
81 82 release-notes-3.2.1.rst
82 83 release-notes-3.2.0.rst
83 84 release-notes-3.1.1.rst
84 85 release-notes-3.1.0.rst
85 86 release-notes-3.0.2.rst
86 87 release-notes-3.0.1.rst
87 88 release-notes-3.0.0.rst
88 89
89 90 |RCE| 2.x Versions
90 91 ------------------
91 92
92 93 .. toctree::
93 94 :maxdepth: 1
94 95
95 96 release-notes-2.2.8.rst
96 97 release-notes-2.2.7.rst
97 98 release-notes-2.2.6.rst
98 99 release-notes-2.2.5.rst
99 100 release-notes-2.2.4.rst
100 101 release-notes-2.2.3.rst
101 102 release-notes-2.2.2.rst
102 103 release-notes-2.2.1.rst
103 104 release-notes-2.2.0.rst
104 105 release-notes-2.1.0.rst
105 106 release-notes-2.0.2.rst
106 107 release-notes-2.0.1.rst
107 108 release-notes-2.0.0.rst
108 109
109 110 |RCE| 1.x Versions
110 111 ------------------
111 112
112 113 .. toctree::
113 114 :maxdepth: 1
114 115
115 116 release-notes-1.7.2.rst
116 117 release-notes-1.7.1.rst
117 118 release-notes-1.7.0.rst
118 119 release-notes-1.6.0.rst
@@ -1,311 +1,322 b''
1 1 # -*- coding: utf-8 -*-
2 2
3 3 # Copyright (C) 2012-2018 RhodeCode GmbH
4 4 #
5 5 # This program is free software: you can redistribute it and/or modify
6 6 # it under the terms of the GNU Affero General Public License, version 3
7 7 # (only), as published by the Free Software Foundation.
8 8 #
9 9 # This program is distributed in the hope that it will be useful,
10 10 # but WITHOUT ANY WARRANTY; without even the implied warranty of
11 11 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 12 # GNU General Public License for more details.
13 13 #
14 14 # You should have received a copy of the GNU Affero General Public License
15 15 # along with this program. If not, see <http://www.gnu.org/licenses/>.
16 16 #
17 17 # This program is dual-licensed. If you wish to learn more about the
18 18 # RhodeCode Enterprise Edition, including its added features, Support services,
19 19 # and proprietary license terms, please see https://rhodecode.com/licenses/
20 20
21 21 import colander
22 22 import string
23 23 import collections
24 24 import logging
25 25
26 26 from mako import exceptions
27 27
28 28 from rhodecode.translation import _
29 29
30 30
31 31 log = logging.getLogger(__name__)
32 32
33 33
34 34 class IntegrationTypeBase(object):
35 35 """ Base class for IntegrationType plugins """
36 36 is_dummy = False
37 37 description = ''
38 38
39 39 @classmethod
40 40 def icon(cls):
41 41 return '''
42 42 <?xml version="1.0" encoding="UTF-8" standalone="no"?>
43 43 <svg
44 44 xmlns:dc="http://purl.org/dc/elements/1.1/"
45 45 xmlns:cc="http://creativecommons.org/ns#"
46 46 xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
47 47 xmlns:svg="http://www.w3.org/2000/svg"
48 48 xmlns="http://www.w3.org/2000/svg"
49 49 xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
50 50 xmlns:inkscape="http://setwww.inkscape.org/namespaces/inkscape"
51 51 viewBox="0 -256 1792 1792"
52 52 id="svg3025"
53 53 version="1.1"
54 54 inkscape:version="0.48.3.1 r9886"
55 55 width="100%"
56 56 height="100%"
57 57 sodipodi:docname="cog_font_awesome.svg">
58 58 <metadata
59 59 id="metadata3035">
60 60 <rdf:RDF>
61 61 <cc:Work
62 62 rdf:about="">
63 63 <dc:format>image/svg+xml</dc:format>
64 64 <dc:type
65 65 rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
66 66 </cc:Work>
67 67 </rdf:RDF>
68 68 </metadata>
69 69 <defs
70 70 id="defs3033" />
71 71 <sodipodi:namedview
72 72 pagecolor="#ffffff"
73 73 bordercolor="#666666"
74 74 borderopacity="1"
75 75 objecttolerance="10"
76 76 gridtolerance="10"
77 77 guidetolerance="10"
78 78 inkscape:pageopacity="0"
79 79 inkscape:pageshadow="2"
80 80 inkscape:window-width="640"
81 81 inkscape:window-height="480"
82 82 id="namedview3031"
83 83 showgrid="false"
84 84 inkscape:zoom="0.13169643"
85 85 inkscape:cx="896"
86 86 inkscape:cy="896"
87 87 inkscape:window-x="0"
88 88 inkscape:window-y="25"
89 89 inkscape:window-maximized="0"
90 90 inkscape:current-layer="svg3025" />
91 91 <g
92 92 transform="matrix(1,0,0,-1,121.49153,1285.4237)"
93 93 id="g3027">
94 94 <path
95 95 d="m 1024,640 q 0,106 -75,181 -75,75 -181,75 -106,0 -181,-75 -75,-75 -75,-181 0,-106 75,-181 75,-75 181,-75 106,0 181,75 75,75 75,181 z m 512,109 V 527 q 0,-12 -8,-23 -8,-11 -20,-13 l -185,-28 q -19,-54 -39,-91 35,-50 107,-138 10,-12 10,-25 0,-13 -9,-23 -27,-37 -99,-108 -72,-71 -94,-71 -12,0 -26,9 l -138,108 q -44,-23 -91,-38 -16,-136 -29,-186 -7,-28 -36,-28 H 657 q -14,0 -24.5,8.5 Q 622,-111 621,-98 L 593,86 q -49,16 -90,37 L 362,16 Q 352,7 337,7 323,7 312,18 186,132 147,186 q -7,10 -7,23 0,12 8,23 15,21 51,66.5 36,45.5 54,70.5 -27,50 -41,99 L 29,495 Q 16,497 8,507.5 0,518 0,531 v 222 q 0,12 8,23 8,11 19,13 l 186,28 q 14,46 39,92 -40,57 -107,138 -10,12 -10,24 0,10 9,23 26,36 98.5,107.5 72.5,71.5 94.5,71.5 13,0 26,-10 l 138,-107 q 44,23 91,38 16,136 29,186 7,28 36,28 h 222 q 14,0 24.5,-8.5 Q 914,1391 915,1378 l 28,-184 q 49,-16 90,-37 l 142,107 q 9,9 24,9 13,0 25,-10 129,-119 165,-170 7,-8 7,-22 0,-12 -8,-23 -15,-21 -51,-66.5 -36,-45.5 -54,-70.5 26,-50 41,-98 l 183,-28 q 13,-2 21,-12.5 8,-10.5 8,-23.5 z"
96 96 id="path3029"
97 97 inkscape:connector-curvature="0"
98 98 style="fill:currentColor" />
99 99 </g>
100 100 </svg>
101 101 '''
102 102
103 103 def __init__(self, settings):
104 104 """
105 105 :param settings: dict of settings to be used for the integration
106 106 """
107 107 self.settings = settings
108 108
109 109 def settings_schema(self):
110 110 """
111 111 A colander schema of settings for the integration type
112 112 """
113 113 return colander.Schema()
114 114
115 115
116 116 class EEIntegration(IntegrationTypeBase):
117 117 description = 'Integration available in RhodeCode EE edition.'
118 118 is_dummy = True
119 119
120 120 def __init__(self, name, key, settings=None):
121 121 self.display_name = name
122 122 self.key = key
123 123 super(EEIntegration, self).__init__(settings)
124 124
125 125
126 126 # Helpers #
127 # updating this required to update the `common_vars` as well.
127 128 WEBHOOK_URL_VARS = [
128 129 ('event_name', 'Unique name of the event type, e.g pullrequest-update'),
129 130 ('repo_name', 'Full name of the repository'),
130 131 ('repo_type', 'VCS type of repository'),
131 132 ('repo_id', 'Unique id of repository'),
132 133 ('repo_url', 'Repository url'),
133 134 # extra repo fields
134 135 ('extra:<extra_key_name>', 'Extra repo variables, read from its settings.'),
135 136
136 137 # special attrs below that we handle, using multi-call
137 ('branch', 'Name of each brach submitted, if any.'),
138 ('commit_id', 'Id of each commit submitted, if any.'),
138 ('branch', 'Name of each branch submitted, if any.'),
139 ('branch_head', 'Head ID of pushed branch (full sha of last commit), if any.'),
140 ('commit_id', 'ID (full sha) of each commit submitted, if any.'),
139 141
140 142 # pr events vars
141 143 ('pull_request_id', 'Unique ID of the pull request.'),
142 144 ('pull_request_title', 'Title of the pull request.'),
143 145 ('pull_request_url', 'Pull request url.'),
144 146 ('pull_request_shadow_url', 'Pull request shadow repo clone url.'),
145 147 ('pull_request_commits_uid', 'Calculated UID of all commits inside the PR. '
146 148 'Changes after PR update'),
147 149
148 150 # user who triggers the call
149 151 ('username', 'User who triggered the call.'),
150 152 ('user_id', 'User id who triggered the call.'),
151 153 ]
152 154
153 155 # common vars for url template used for CI plugins. Shared with webhook
154 156 CI_URL_VARS = WEBHOOK_URL_VARS
155 157
156 158
157 159 class CommitParsingDataHandler(object):
158 160
159 161 def aggregate_branch_data(self, branches, commits):
160 162 branch_data = collections.OrderedDict()
161 163 for obj in branches:
162 164 branch_data[obj['name']] = obj
163 165
164 166 branches_commits = collections.OrderedDict()
165 167 for commit in commits:
166 168 if commit.get('git_ref_change'):
167 169 # special case for GIT that allows creating tags,
168 170 # deleting branches without associated commit
169 171 continue
170 172 commit_branch = commit['branch']
171 173
172 174 if commit_branch not in branches_commits:
173 175 _branch = branch_data[commit_branch] \
174 176 if commit_branch else commit_branch
175 177 branch_commits = {'branch': _branch,
178 'branch_head': '',
176 179 'commits': []}
177 180 branches_commits[commit_branch] = branch_commits
178 181
179 182 branch_commits = branches_commits[commit_branch]
180 183 branch_commits['commits'].append(commit)
184 branch_commits['branch_head'] = commit['raw_id']
181 185 return branches_commits
182 186
183 187
184 188 class WebhookDataHandler(CommitParsingDataHandler):
185 189 name = 'webhook'
186 190
187 191 def __init__(self, template_url, headers):
188 192 self.template_url = template_url
189 193 self.headers = headers
190 194
191 195 def get_base_parsed_template(self, data):
192 196 """
193 197 initially parses the passed in template with some common variables
194 198 available on ALL calls
195 199 """
196 200 # note: make sure to update the `WEBHOOK_URL_VARS` if this changes
197 201 common_vars = {
198 202 'repo_name': data['repo']['repo_name'],
199 203 'repo_type': data['repo']['repo_type'],
200 204 'repo_id': data['repo']['repo_id'],
201 205 'repo_url': data['repo']['url'],
202 206 'username': data['actor']['username'],
203 207 'user_id': data['actor']['user_id'],
204 208 'event_name': data['name']
205 209 }
206 210
207 211 extra_vars = {}
208 212 for extra_key, extra_val in data['repo']['extra_fields'].items():
209 213 extra_vars['extra__{}'.format(extra_key)] = extra_val
210 214 common_vars.update(extra_vars)
211 215
212 216 template_url = self.template_url.replace('${extra:', '${extra__')
213 217 return string.Template(template_url).safe_substitute(**common_vars)
214 218
215 219 def repo_push_event_handler(self, event, data):
216 220 url = self.get_base_parsed_template(data)
217 221 url_cals = []
218 222
219 223 branches_commits = self.aggregate_branch_data(
220 224 data['push']['branches'], data['push']['commits'])
221 if '${branch}' in url:
225 if '${branch}' in url or '${branch_head}' in url:
222 226 # call it multiple times, for each branch if used in variables
223 227 for branch, commit_ids in branches_commits.items():
224 228 branch_url = string.Template(url).safe_substitute(branch=branch)
229
230 if '${branch_head}' in branch_url:
231 # last commit in the aggregate is the head of the branch
232 branch_head = commit_ids['branch_head']
233 branch_url = string.Template(branch_url).safe_substitute(
234 branch_head=branch_head)
235
225 236 # call further down for each commit if used
226 237 if '${commit_id}' in branch_url:
227 238 for commit_data in commit_ids['commits']:
228 239 commit_id = commit_data['raw_id']
229 240 commit_url = string.Template(branch_url).safe_substitute(
230 241 commit_id=commit_id)
231 242 # register per-commit call
232 243 log.debug(
233 244 'register %s call(%s) to url %s',
234 245 self.name, event, commit_url)
235 246 url_cals.append(
236 247 (commit_url, self.headers, data))
237 248
238 249 else:
239 250 # register per-branch call
240 251 log.debug(
241 252 'register %s call(%s) to url %s',
242 253 self.name, event, branch_url)
243 254 url_cals.append(
244 255 (branch_url, self.headers, data))
245 256
246 257 else:
247 258 log.debug(
248 259 'register %s call(%s) to url %s', self.name, event, url)
249 260 url_cals.append((url, self.headers, data))
250 261
251 262 return url_cals
252 263
253 264 def repo_create_event_handler(self, event, data):
254 265 url = self.get_base_parsed_template(data)
255 266 log.debug(
256 267 'register %s call(%s) to url %s', self.name, event, url)
257 268 return [(url, self.headers, data)]
258 269
259 270 def pull_request_event_handler(self, event, data):
260 271 url = self.get_base_parsed_template(data)
261 272 log.debug(
262 273 'register %s call(%s) to url %s', self.name, event, url)
263 274 url = string.Template(url).safe_substitute(
264 275 pull_request_id=data['pullrequest']['pull_request_id'],
265 276 pull_request_title=data['pullrequest']['title'],
266 277 pull_request_url=data['pullrequest']['url'],
267 278 pull_request_shadow_url=data['pullrequest']['shadow_url'],
268 279 pull_request_commits_uid=data['pullrequest']['commits_uid'],
269 280 )
270 281 return [(url, self.headers, data)]
271 282
272 283 def __call__(self, event, data):
273 284 from rhodecode import events
274 285
275 286 if isinstance(event, events.RepoPushEvent):
276 287 return self.repo_push_event_handler(event, data)
277 288 elif isinstance(event, events.RepoCreateEvent):
278 289 return self.repo_create_event_handler(event, data)
279 290 elif isinstance(event, events.PullRequestEvent):
280 291 return self.pull_request_event_handler(event, data)
281 292 else:
282 293 raise ValueError(
283 294 'event type `%s` not in supported list: %s' % (
284 295 event.__class__, events))
285 296
286 297
287 298 def get_auth(settings):
288 299 from requests.auth import HTTPBasicAuth
289 300 username = settings.get('username')
290 301 password = settings.get('password')
291 302 if username and password:
292 303 return HTTPBasicAuth(username, password)
293 304 return None
294 305
295 306
296 307 def get_web_token(settings):
297 308 return settings['secret_token']
298 309
299 310
300 311 def get_url_vars(url_vars):
301 312 return '\n'.join(
302 313 '{} - {}'.format('${' + key + '}', explanation)
303 314 for key, explanation in url_vars)
304 315
305 316
306 317 def render_with_traceback(template, *args, **kwargs):
307 318 try:
308 319 return template.render(*args, **kwargs)
309 320 except Exception:
310 321 log.error(exceptions.text_error_template().render())
311 322 raise
General Comments 0
You need to be logged in to leave comments. Login now