Update documentation for Cluster-API and Flux
[icn.git] / ci / README.md
1 # Setup a private Jenkins server from a fresh Ubuntu 18.04
2
3 Akraino community has a public Jenkins cluster, we run CI jobs there.
4 But the CD jobs, we need to run them in our private Jenkins cluster.
5 For now, we support only one node private Jenkins deployment.  The
6 only supported OS is Ubuntu 18.04.
7
8 ## How to setup Jenkins server
9
10 We define vars in `vars.yaml` to customize the deployment.  The
11 default listening address is the default IP address of the Jenkins
12 server.  To override the listening address/domain name, please set
13 `jenkins_hostname`.  The default Jenkins username/password is
14 `admin/admin`. To override it, please set `jenkins_admin_username` and
15 `jenkins_admin_password`.
16
17 1. Fetch the source for ICN and Akraino CI management.The ICN jenkins
18 job macros require that the the icn and ci-management directories are
19 peers.
20
21 ** Note: Switch the branch of the repositories below as needed.**
22
23 ``` shell
24 git clone https://gerrit.akraino.org/r/icn
25 git clone --recursive https://gerrit.akraino.org/r/ci-management
26 ```
27
28 2. Install Jenkins.
29
30 ```shell
31 cd icn/ci
32 sudo -H ./install_ansible.sh
33 sudo -H ansible-playbook site_jenkins.yaml --extra-vars "@vars.yaml" -v
34 ```
35
36 Once the playbook is successful, we can visit the Jenkins server at
37 http://<listen_address>:8080.
38
39 ## What to do next
40
41 1. Add the gerrit ssh key as Jenkins credential, so that our jobs can
42 pull code from the gerrit.  The credential ID field must be
43 `jenkins-ssh`, as this is hard coded in the jobs. The type should be
44 private key. The user name is the gerrit account name.
45
46 2. To push the logs to Akraino Nexus server, we need to create the
47 authentication file for lftools.  The file should be owned by Jenkins
48 user. The file path is `/var/lib/jenkins/.netrc` and the content
49 should be one line `machine nexus.akraino.org login the_name password
50 the_pass`
51
52 3. The last step is to deploy our CD jobs by jenkins-job-builder tool.
53
54 Basic Jenkins Job Builder (JJB) configuration using admin/admin
55 credentials.
56
57 ``` shell
58 mkdir -p ~/.config/jenkins_jobs
59 cat << EOF | tee ~/.config/jenkins_jobs/jenkins_jobs.ini
60 [job_builder]
61 ignore_cache=True
62 keep_descriptions=False
63 recursive=True
64 retain_anchors=True
65 update=jobs
66
67 [jenkins]
68 user=admin
69 password=admin
70 url=http://localhost:8080
71 EOF
72 ```
73
74 Install jenkins-job-builder.
75
76 ``` shell
77 sudo -H pip3 install jenkins-job-builder
78 ```
79
80 Install the job into Jenkins. The test command displays the output of
81 the job builder that will be installed into Jenkins; it is optional.
82
83 ``` shell
84 jenkins-jobs test ci-management/jjb:icn/ci/jjb icn-master-verify
85 jenkins-jobs update ci-management/jjb:icn/ci/jjb icn-master-verify
86 ```