adding clean up script for nested k8s
[icn.git] / ci / README.md
1 # Setup a private Jenkins server from a refresh ubuntu 18.04
2
3 Akraino community has a publich 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.
6 The 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.
11 The default listening address is the default ip address of the Jenkins server.
12 To override the listening address/domain name, please set `jenkins_hostname`.
13 The default Jenkins username/password is `admin/admin`. To overrides it, please set
14 `jenkins_admin_username` and `jenkins_admin_password`.
15
16 ```bash
17 git clone "https://gerrit.akraino.org/r/icn" # may need to switch the branch based on your case
18 cd icn/ci
19 sudo ./install_ansible.sh
20 sudo ansible-playbook site_jenkins.yaml --extra-vars "@vars.yaml" -v
21 ```
22
23 Once the playbook is successful, we can visite the jenkins server at http://<listen_address>:8080.
24
25 ## What to do next
26
27 1. Add the gerrit ssh key as jenkins credential, so that our jobs can pull code from the gerrit.
28 The credential ID field must be `jenkins-ssh`, as this is hard coded in the jobs. The type should
29 be private key. The user name is the gerrit account name.
30 2. To push the logs to Akraino Nexus server, we need to create the authentication file for lftools.
31 The file should be owned by jenkins user. The file path is `/var/lib/jenkins/.netrc` and
32 the content should be one line `machine nexus.akraino.org login the_name password the_pass`
33 3. The last step is to deploy our CD jobs by jenkins-job-builder tool.
34
35 ```
36 git clone --recursive "https://gerrit.akraino.org/r/ci-management"
37 git clone "https://gerrit.akraino.org/r/icn"
38 # create the jjb config file before moving on
39 # https://docs.releng.linuxfoundation.org/en/latest/jenkins-sandbox.html
40 jenkins-jobs test ci-management/jjb:icn/ci/jjb icn-master-verify
41 jenkins-jobs update ci-management/jjb:icn/ci/jjb icn-master-verify
42 ```
43
44 A sample of jjb config file located at `~/.config/jenkins_jobs/jenkins_jobs.ini`
45 ```
46 [job_builder]
47 ignore_cache=True
48 keep_descriptions=False
49 recursive=True
50 retain_anchors=True
51 update=jobs
52
53 [jenkins]
54 user=admin
55 password=admin
56 url=http://localhost:8080
57 ```
58
59 4. There is [a bug](https://issues.jenkins-ci.org/browse/JENKINS-28466) of jenkins
60 which makes some environemtn variables not usable. To fix the bug, we need 'Manage Jenkins' > 'Configure System' > 'click save without any changes'.