1 ## ONAP Jenkins Sandbox Process:
3 ONAP Jenkins Sandbox provides you Jenkins Job testing/experimentation environment
4 that can be used before pushing job templates to the production
5 [Jenkins](https://jenkins.onap.org).
7 It is configured similar to the ONAP [ci-management] production instance;
8 however, it cannot publish artifacts or vote in Gerrit. Be aware that this is a
9 test environment, and as such there a limited allotment of minions to test on
10 before pushing code to the ONAP repos.
11 Keep the following points in mind prior to beginning work on ONAP Jenkins Sandbox
14 - Jobs are automatically deleted every weekend
15 - Committers can login and configure Jenkins jobs in the sandbox directly
16 - Sandbox jobs CANNOT perform any upload tasks
17 - Sandbox jobs CANNOT vote on Gerrit
18 - Jenkins nodes are configured using ONAP openstack VMs and you can not access
21 Before you proceed further, ensure you have a Linux Foundation ID (LFID), which is
22 required to access Gerrit & Jenkins. Also, to get an access to Sandbox environment
23 please send email to helpdesk@onap.org (LF helpdesk team)
25 To download **ci-management**, execute the following command to clone the
26 **ci-managment** repository.
28 `git clone ssh://<LFID>@gerrit.onap.org:29418/ci-management --recursive && scp -p -P 29418 \
29 <LFID>@gerrit.onap.org:hooks/commit-msg ci-management/.git/hooks/`
31 Make sure to sync global-jjb submodule using:
33 `git submodule update --init`
35 Once you successfully clone the repository, next step is to install JJB
36 (Jenkins Job Builder) in order to experiment with Jenkins jobs.
38 ### Execute the following commands to install JJB on your machine:
42 sudo apt-get install python-virtualenv
43 virtualenv onap_sandbox
44 source onap_sandbox/bin/activate
45 pip install jenkins-job-builder
46 jenkins-jobs --version
47 jenkins-jobs test --recursive jjb/
50 ### Make a copy of the example JJB config file (in the builder/ directory)
52 Backup the jenkins.ini.example to jenkins.ini
54 `cp jenkins.ini.example jenkins.ini`
56 After copying the jenkins.ini.example, modify `jenkins.ini` with your
57 **Jenkins LFID username**, **API token** and **ONAP jenkins sandbox URL**
62 keep_descriptions=False
63 include_path=.:scripts:~/git/
67 user=jwagantall <Provide your Jenkins Sandbox username>
68 password= <Refer below steps to get API token>
69 url=https://jenkins.onap.org/sandbox
70 This is deprecated, use job_builder section instead
73 ### How to retrieve API token?
74 Login to the [Jenkins Sandbox](https://jenkins.onap.org/sandbox/), go to your user
75 page by clicking on your username. Click **Configure** and then click **Show API Token**.
77 To work on existing jobs or create new jobs, navigate to the `/jjb` directory where you
78 will find all job templates for the project. Follow the below commands to test,
79 update or delete jobs in your sandbox environment.
83 After you modify or create jobs in the above environment, it's good practice
84 to test the job in sandbox environment before you submit this job to production CI environment.
86 `jenkins-jobs --conf jenkins.ini test jjb/ <job-name>`
88 **Example:** `jenkins-jobs --conf jenkins.ini test jjb/ sdc-master-verify-java`
90 If the job you’d like to test is a template with variables in its name, it must be
91 manually expanded before use. For example, the commonly used template `sdc-{stream}-verify-java`
92 might expand to `sdc-master-verify-java`.
94 A successful test will output the XML description of the Jenkins job described by the
95 specified JJB job name.
97 Execute the following command to pipe-out to a directory:
99 `jenkins-jobs --conf jenkins.ini test jjb/ <job-name> -o <directoryname>`
101 The output directory will contain files with the XML configurations.
105 Ensure you’ve configured your `jenkins.ini` and verified it by
106 outputting valid XML descriptions of Jenkins jobs. Upon successful
107 verification, execute the following command to update the job to the
110 `jenkins-jobs --conf jenkins.ini update jjb/ <job-name>`
112 **Example:** `jenkins-jobs --conf jenkins.ini update jjb/ sdc-master-verify-java`
114 ## Trigger jobs from Jenkins Sandbox:
116 Once you push the Jenkins job configuration to the ONAP Sandbox environment,
117 run the job from Jenkins Sandbox webUI. Follow the below process to trigger the build:
119 Step 1: Login into the [Jenkins Sandbox WebUI](https://jenkins.onap.org/sandbox/)
121 Step 2: Click on the **job** which you want to trigger, then click
122 **Build with Parameters**, and finally click **Build**.
124 Step 3: Verify the **Build Executor Status** bar and make sure that the build is triggered
125 on the available executor. In Sandbox you may not see all platforms build executors and
126 you don't find many like in production CI environment.
128 Once the job is triggered, click on the build number to view the job
129 details and the console output.
133 Execute the following command to Delete a job from Sandbox:
135 `jenkins-jobs --conf jenkins.ini delete jjb/ <job-name>`
137 **Example:** `jenkins-jobs --conf jenkins.ini delete jjb/ sdc-master-verify-java`
139 The above command would delete the `sdc-master-verify-java` job.
141 ## Modify an Existing Job:
143 In the ONAP Jenkins sandbox, you can directly edit or modify the job configuration
144 by selecting the job name and clicking on the **Configure** button. Then, click the
145 **Apply** and **Save** buttons to save the job.
147 However, it is recommended to simply modify the job in your terminal and then follow
148 the previously described steps in **To Test a Job** and **To Update a Job** to perform
151 ## More online documentation:
153 https://docs.openstack.org/infra/jenkins-job-builder/