##// END OF EJS Templates
docs: updated docs about Jenkins CI integration.
marcink -
r2865:09bbedf2 stable
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
@@ -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
General Comments 0
You need to be logged in to leave comments. Login now