##// 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
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
@@ -16,7 +16,7 b' 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
@@ -50,7 +50,7 b' the url would look like that::'
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
@@ -66,6 +66,9 b' calling such example url provided in :re'
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 +++++++++
@@ -19,7 +19,8 b' Type/Name |RC| Edi'
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
@@ -53,3 +54,4 b' See pages specific to each type of integ'
53 webhook
54 webhook
54 email
55 email
55 ci
56 ci
57 jenkins
General Comments 0
You need to be logged in to leave comments. Login now