Commit 724b41bf authored by qhoangxuan's avatar qhoangxuan

update README.md

parent 4da5a41d
# Zoe Continuous Integration
---------------------------
----------------------------
# Overview
- Integrate Zoe repository to Jenkins and SonarQube
- Each commit to Zoe repository trigger a build at Jenkins:
......@@ -11,22 +12,34 @@
# Software Stack
- Jenkins - version 2.7.4
- SonarQube - version 9.6.0
- SonarQube - version 6.1
# Configuration
### Jenkins
- Required:
- Plugins: Github plugin, SonarQube Plugin, Email Plugin (optional), Cobetura Coverage Report (optional)
- Softwares: Java, Python, Docker
- Go to **Manage Jenkins**, then **Global Tool Configuration** to setup Java SDK
- SonarQube server configuration:
- Go to **Manage Jenkins** then **Configure System**
- SonarQube servers: input name, server URL, server version, **sever authentication token** (created on SonarQube Server)
- Create credentials for Github account
- Create SSH key pair on Jenkins Server
### Jenkins: all the configurations in this section is configured on Jenkins Server
- Required:
- Plugins: Github plugin, SonarQube Plugin, Quality Gates, Email Plugin (optional), Cobertura Coverage Report (optional)
- Softwares: Java, Python, Docker
- Go to **Manage Jenkins**, then **Global Tool Configuration** to setup Java SDK, SonarQube Scanner
- SonarQube server configuration: this aims to connect Jenkins and SonarQube together
- Go to **Manage Jenkins** then **Configure System**
- SonarQube servers: input name, server URL, server version, **sever authentication token** (created on SonarQube Server)
- Quality Gates configuration:
- Go to **Manage Jenkins** then **Configure System**
- Quality Gates: input name, server URL, username and password to login into SonarQube server
- Github Servers configuration:
- Go to **Manage Jenkins** then **Configure System**
- Github: **Add Github Server**, the API URL would be ``https://api.github.com``. The credentials creation is well defined in the document of Github plugin:
- You can create your own [personal access token](https://github.com/settings/tokens/new) in your account GitHub settings.
- Token should be registered with scopes:
- admin:repo_hook - for managing hooks (read, write and delete old ones)
- repo - to see private repos
- repo:status - to manipulate commit statuses
- In Jenkins create credentials as «Secret Text», provided by Plain Credentials Plugin
- Create credentials for Github account: this is similar when you want to [connect to Github over SSH](https://help.github.com/articles/connecting-to-github-with-ssh/), here, beside adding your public key to Github, you also need to add your private key to Jenkins.
- Create SSH key pair on the machine run Jenkins:
- Add public key to Github
- Add private key to Jenkins credentials
- Create new item as a **freestyle project** to describe Github repository
- Create new item as a **freestyle project**: this aims to create a Jenkins job with the github repository
- General
- Select Github project
- Insert project URL
......@@ -36,10 +49,17 @@
- Repository URL: use **SSH URL** of Github repository
- Credentials: select the one created above
- Build Triggers
- Select **Build when a change is pushed to Github**
- For Github plugin with version before 1.25.1: Select **Build when a change is pushed to Github**
- For Github plugin with version from 1.25.1: Select **GitHub hook trigger for GITScm polling**
- Build
- Add **Execute SonarQube Scanner** to do SonarQube Analysis
- Add **Quality Gates** to break the build when the SonarQube quality gate is not passed
- Add **Execute Shell** to run script for testing, deploying. Please refer to the Appendix section for the script.
- Post-build Actions [Optional]
- Add **Publish Covetura Coverage Report** for getting report from coverage
Due to the shell script in Appendix, the xml file generated by coverage is located at ``test`` folder, so, we should put ``**/tests/coverage.xml`` as the input of the field **Cobertura xml report pattern**.
- Add **E-mail Notification** for notifying when jobs finish
### Github
- Add new SSH key (the one created on Jenkins server)
- Go to the project (which is integrated to Jenkins) settings
......@@ -47,19 +67,28 @@
- Add Service, choose **Jenkins (Github plugin)**
- Add Jenkins hook url
- For github plugin, this one would have the format: http://your-jenkins.com/github-webhook/
- In case your Jenkins doens't expose to the world, try **ngrok**
### SonarQube
- In case your Jenkins doens't expose to the world, try [**ngrok**](https://ngrok.com/)
### SonarQube: all the configurations in this section is configured on SonarQube Server
- On **Administration**, go to **My Account**, then **Security**
- Generate Tokens, copy this and paste to **server authentication token** on Jenkins configuration
- The project needs to provides **sonar-properties** file in the repo: http://docs.sonarqube.org/display/SCAN/Analyzing+with+SonarQube+Scanner
- The project needs to provides **sonar-properties** file in the repo: [Analyzing with SonarQube Scanner](http://docs.sonarqube.org/display/SCAN/Analyzing+with+SonarQube+Scanner)
# Appendix
----------
# Sonar properties files
Take a look at sonar-project.properties files at branch [**i34-t7.4.1**](https://github.com/DistributedSystemsGroup/zoe-kpmg/tree/i34-t7.4.1), in root, ``zoe_api``, ``zoe_master``, ``zoe_lib``, ``zoe_fe`` folders.
# Execute Shell Script
Script to execute ci in zoe-kpmg branch i34-t7.4.1
Push this script inside the execute shell script of Jenkins job
Push this script inside the execute shell script of Jenkins job you created above
```
# Run Style checker for Sphinx RST documentation
doc8 docs/
# Build new container images
python3 ci/zoeci.py 1 tcp://192.168.12.2:2375 192.168.12.2:5000/zoe:$BUILD_ID
# Deploy new zoe with the above images for testing
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment