Hygieia-你值得拥有!!!(上篇)

  • 2019 年 10 月 4 日
  • 筆記

背景介绍

Hygieia,由Capitalone公司开源的DevOps系统,可构建软件需求、开发、测试、部署全流程的端到端Dashboard看板平台,采集各种常见系统的数据并图形化集中动态展示,涉及的系统包括不限于jira、gitlab、github、svn、jenkins、sonarqube等。使用Hygieia后,在整个软件开发周期中,用户可以选择VersionOne或Jira进行用户故事的追踪,选择Subversion或GitHub作为代码仓库,选择Jenkins或Hudson进行构建,选择Selenium和SonarQube用于质量检测,以及选择uDeploy或Jenkins进行部署等等,当然Hygieia不止这点,它的api基于rest风格插件设计,其他的一些软件工程组件可以很轻松的接入到Hygieia,他的dashboard大盘可以展示软件创建到交付的整个生命周期数据。

Hygieia架构图?

Hygieia开发用到技术栈?

Hygieia主要java开发的,使用了spring boot框架,前端使用angular.js开发,阅读实践本文,你需要了解如下相关技术栈:

  • 前端相关:node、npm、bower、gulp
  • 后端相关:java、spring boot、maven
  • 数据库:mongoDB

效果如下图

这么高大上的系统,你也一定希望能够拥有吧? 下面给大家分享一下部署和配置的过程。

源码及文件下载地址

官方帮助文档:http://hygieia.github.io/Hygieia/getting_started.html 备注:部分说明有些不准确,文档仅供参考

Hygieia 主工程

  • Github地址:https://github.com/Hygieia/Hygieia.git
  • Release版本下载地址:https://github.com/Hygieia/Hygieia/archive/v3.1.0.tar.gz
  • 说明:Going forward Hygieia project will only have the UI component. All components api, api-audit and collectors now have their own repositories. This version v3.1.0 is the baseline UI only Hygieia project going forward.

Dashboard UI Layer

  • Github地址:https://github.com/Hygieia/UI.git
  • Release版本下载地址:无
  • 说明文档:https://github.com/Hygieia/UI/blob/master/README.md
  • 备注:主工程中已包含UI模块,故如果已下载了主工程,则无需独立下载。

REST API Layer

  • Github地址:https://github.com/Hygieia/api.git
  • Release版本下载地址:https://github.com/Hygieia/api/archive/v3.1.1.tar.gz
  • 配置文档:https://github.com/Hygieia/Hygieia/blob/gh-pages/pages/hygieia/api/api.md

Hygieia-core

  • Github地址:https://github.com/Hygieia/hygieia-core.git
  • Release版本下载地址:https://github.com/Hygieia/hygieia-core/archive/v3.1.5.tar.gz

在接下来的文章中主要讲述以下各分系统的搭建步骤:

Hygieia部署与配置

  • Hygieia 主工程部署、配置及运行
  • Hygieia UI 部署、配置及运行
  • Hygieia API 部署、配置及运行
  • Hygieia Core 部署、配置及运行

环境要求

  • Java – Version 1.8 is recommended
  • Maven – Version 3.3.9 and above are recommended
  • Git – Install Git

第一步:Hygieia 主工程部署

1. 获取主工程代码

获取代码的方式有两种,克隆或者下载:

  • 克隆,获取最新的代码,执行 “git clone https://github.com/Hygieia/Hygieia.git” ,存在的风险是无法工程可能编译不成功;
  • 下载,获取最新的Release版本, https://github.com/Hygieia/Hygieia/archive/v3.1.0.tar.gz ,推荐使用。

2. Hygieia 配置

  • 进入hygieia根目录
  • 运行以下命令 mvn clean install package

第二步:Hygieia UI 部署

1. 获取UI工程代码

  • 方法1:下载主工程,在/Hygieia/UI目录下既是UI工程代码
    • 获取最新代码部署,执行 “ git clone https://github.com/Hygieia/Hygieia.git ” ,缺点是存在编译失败的风险;
    • 使用最新Release版本部署,下载地址:https://github.com/Hygieia/Hygieia/archive/v3.1.0.tar.gz ,推荐使用。
  • 方法2:下载UI独立工程代码
    • 获取最新代码部署,执行 “ git clone https://github.com/Hygieia/UI.git ” ,缺点是存在编译失败的风险;

2. 配置UI构建及环境

  • 进入UI工程根目录
  • 执行以下命令,安装bower、gulp npm install -g bower npm install -g gulp
  • 安装成功后,执行构建 gulp serve

构建完成后,会在/Hygieia/UI/dist目录下生成前端页面的文件。

3. Hygieia UI 配置

工程配置文件:/Hygieia/UI/gulpfile.js

  • 如果需要修改UI连接Hygieia-api的端口,请参考以下步骤:
    • 编辑vi Hygieia/UI/gulpfile.js;
    • var proxyTarget = config.api || 'http://localhost:8080';
    • 修改为真实api地址及端口号,如下图。

4. Hygieia UI 运行

运行方式有两种:

  1. 构建运行 执行命令:gulp serve 访问:http://10.152.102.183:3000 或 http://localhost:3000 备注:默认端口为3000,缺点是执行命令的窗口需要一直开着,如果关闭,则前端页面无法访问。
  2. 搭配Nginx运行 实例配置文件下载如下; 备注:通过Nginx配置,web页面可以随时访问。
server  {  	listen *:3000;  	server_name hygieia.qa.sogou;    	access_log /search/odin/nginx/log/hygieia.qa.sogou_log main;    	root html;    	error_page   500 502 503 504  /50x.html;            location / {               root   /search/odin/Hygieia/Hygieia/UI/dist;               index  index.html index.htm;            }      	location = /50x.html  	{  		root   html;  	}            location ~ .php$ {               root           /search/odin/html;               fastcgi_pass   127.0.0.1:9000;               fastcgi_index  index.php;               fastcgi_param  SCRIPT_FILENAME  $document_root$fastcgi_script_name;               include        fastcgi_params;           }      	location ^~/api/{  	    proxy_set_header Host $host;  	    proxy_set_header X-Real-IP $remote_addr;  	    proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;  	    proxy_pass http://localhost:8080;  	}  } 

5.UI 展示如下:

登录页面如下:

第三步:Hygieia API 主工程部署

1. 获取主工程代码

获取代码的方式有两种,克隆或者下载:

  • 克隆,获取最新的代码,执行 “git clone https://github.com/Hygieia/api.git” ,存在的风险是无法工程可能编译不成功;
  • 下载,获取最新的Release版本, https://github.com/Hygieia/api/archive/v3.1.1.tar.gz ,推荐使用。

本系统使用的数据库为Mongon,具体的搭建方法网上有很多,就不在这里叙述了。

2. Hygieia API 配置

  • 进入api根目录
  • 修改配置: vim /src/main/resources/application.properties
  • 修改配置文件 # 需要在mongon中创建 dbname=xxxxx # 连接数据库的用户名 dbusername=xxxxx # 连接数据库的密码 dbpassword=xxxxx # 数据库的IP dbhost=xxxxxx # 数据库的端口 dbport=27017 dbreplicaset=false dbhostport=xxxxxx:27017 server.contextPath=/api # API服务端口 server.port=8080
  • 编译打包: mvn clean install package

3. Hygieia API 运行

启动服务:

  • 前台运行: java -jar target/api.jar –spring.config.location=src/main/resources/api.properties -Djasypt.encryptor.password=hygieiasecret
  • 静默运行: nohup java -jar target/api.jar –spring.config.location=src/main/resources/api.properties -Djasypt.encryptor.password=hygieiasecret &

验证启动状态:

访问:http://10.152.102.183:8080/api/ping,返回true证明运行成功

第四步:Hygieia Core 工程部署

1. 获取工程代码

获取代码的方式有两种,克隆或者下载:

  • 克隆,获取最新的代码,执行 “git clone https://github.com/Hygieia/hygieia-core.git” ,存在的风险是无法工程可能编译不成功;
  • 下载,获取最新的Release版本, https://github.com/Hygieia/hygieia-core/archive/v3.1.5.tar.gz ,推荐使用。

2. Hygieia Core 编译打包

  • 进入core根目录
  • 执行命令 mvn clean install package

至此,这个系统就搭建完成了,在后续的文章中,我们在继续讲解各个collector的部署、配置及运行

  • hygieia-scm-gitlab-collector 部署、配置及运行
  • hygieia-build-jenkins-collector 部署、配置及运行
  • hygieia-codequality-sonar-collector 部署、配置及运行
  • ……