1. 环境准备

  • 操作系统: centos7
  • 系统配置: 4核8G

必要的系统软件安装

  1. # 将本机ip 添加到 hosts
  2. cat >> /etc/hosts << EOF
  3. 192.168.90.128 gitlab.ylb.com jira.ylb.com jenkins.ylb.com
  4. EOF
  5. yum install -y epel-release
  6. yum install -y vim wget

安装docker-ce

  1. # 卸载旧版本
  2. yum remove docker \
  3. docker-client \
  4. docker-client-latest \
  5. docker-common \
  6. docker-latest \
  7. docker-latest-logrotate \
  8. docker-logrotate \
  9. docker-engine
  10. # 添加docker-ce yum源
  11. wget https://download.docker.com/linux/centos/docker-ce.repo -O /etc/yum.repos.d/docker-ce.repo
  12. yum repolist
  13. # 安装 docker-ce
  14. yum install -y docker-ce
  15. # 启动 docker
  16. systemctl start docker
  17. # 将 docker 开机启动
  18. systemctl enable docker

docker 安装 JIRA

安装 mysql

mysql指定库的字符集必须是utf8,否则创建项目会报错

  1. docker run \
  2. --name mysql-jira \
  3. --restart unless-stopped \
  4. -p 3306:3306 \
  5. character-set-server=utf8mb4 \
  6. --collation-server=utf8mb4_bin \
  7. -e MYSQL_ROOT_PASSWORD=123456 \
  8. -e SQL_MODE=NO_AUTO_VALUE_ON_ZERO \
  9. -e MYSQL_DATABASE=jira \
  10. -e MYSQL_USER=jira \
  11. -e MYSQL_PASSWORD=jira \
  12. -d \
  13. mysql:5.7
  14. # CREATE DATABASE jira CHARACTER SET utf8mb4 COLLATE utf8mb4_bin;

mysql-jira 操作

安装 jira

  1. docker run -d \
  2. -p 7081:8080 \
  3. --name jira-software \
  4. --restart always \
  5. cptactionhank/atlassian-jira-software:8.1.0
  6. # 下载 mysql-jdbc 驱动
  7. wget https://cdn.mysql.com//Downloads/Connector-J/mysql-connector-java-5.1.49.tar.gz -O /usr/local/src/mysql-connector-java-5.1.49.tar.gz
  8. tar -xvf /usr/local/src/mysql-connector-java-5.1.49.tar.gz -C /usr/local/src/
  9. # 下载破解包
  10. wget https://github.com/ly641921791/knowledge/raw/master/jira/crack/atlassian-extras-3.2.jar -O /usr/local/src/atlassian-extras-3.2.jar
  11. # 替换
  12. docker cp /usr/local/src/mysql-connector-java-5.1.49/mysql-connector-java-5.1.49-bin.jar jira-software:/opt/atlassian/jira/atlassian-jira/WEB-INF/lib/
  13. docker cp /usr/local/src/atlassian-extras-3.2.jar jira-software:/opt/atlassian/jira/atlassian-jira/WEB-INF/lib/
  14. # 重启
  15. docker restart jira-software

配置jira

浏览器访问: http://jira.ylb.com:7081/

image.png
image.png
image.png

docker 安装 gitlab

  1. mkdir -p /data/gitlab
  2. mkdir -p /data/back/gitlab
  3. # docker 启动gitlab
  4. GITLAB_IP="gitlab.ylb.com"
  5. GITLAB_PATH="/data/gitlab"
  6. docker run -d \
  7. -p 443:443 \
  8. -p 80:80 \
  9. -p 222:22 \
  10. --name gitlab \
  11. --hostname ${GITLAB_IP} \
  12. --restart always \
  13. -v ${GITLAB_PATH}/etc:/etc/gitlab \
  14. -v ${GITLAB_PATH}/log:/var/log/gitlab \
  15. -v ${GITLAB_PATH}/data:/var/opt/gitlab \
  16. -v ${GITLAB_PATH}/data/back/gitlab:/var/opt/gitlab/backups \
  17. gitlab/gitlab-ce:12.8.10-ce.0
  18. # gitlab 备份
  19. # gitlab-rake gitlab:backup:create

docker 安装 jenkins

  1. mkdir -p /data/jenkins
  2. docker run -d \
  3. -p 8080:8080 \
  4. -v ~/jenkins:/var/jenkins_home \
  5. --name jenkins \
  6. --restart always \
  7. jenkins:2.60.3

nginx 配置

  1. server {
  2. listen 80 default_server;
  3. #charset koi8-r;
  4. #access_log /var/log/nginx/host.access.log main;
  5. location / {
  6. root /usr/share/nginx/html;
  7. index index.html index.htm;
  8. }
  9. location /api/ {
  10. proxy_pass http://172.17.5.4:8080/;
  11. }
  12. #参考地址https://github.com/cptactionhank/docker-atlassian-jira/blob/master/.docker/nginx/nginx.conf
  13. location /jira/ {
  14. proxy_set_header X-Forwarded-Host $host;
  15. proxy_set_header X-Forwarded-Server $host;
  16. proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
  17. client_max_body_size 100M;
  18. proxy_pass http://172.17.5.4:8081/jira/;
  19. }
  20. error_page 500 502 503 504 /50x.html;
  21. location = /50x.html {
  22. root /usr/share/nginx/html;
  23. }
  24. }

设置

gitlab 设置 jira


image.png


image.png

JIRA 设置

JIRA集成gitlab 注意事项

  1. jira 允许远程 API调用

JIRA 查看项目 issue 的工作流

  1. 必须使用 admin 帐号查看
  2. image.png
  3. image.png
  4. image.png

**

JIRA 安装 jenkins 插件

image.png

JIRA 中设置jenkins

image.png

image.png

JIRA 中issue状态的改变触发Jenkins构建

在 jira 中配置 webhook
image.png

jenkins 设置

jenkins 所需要的插件

上传下载好的插件
image.png

配置 jenkins

image.png