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