持续集成之Jenkins+Gitlab实现持续集成 [二]

摘要

项目:使用git+jenkins实现持续集成.使用git+jenkins实现持续集成 开始构建 General 源码管理 我们安装的是git插件,还可以安装svn插件 我们将git路径…

持续集成之Jenkins+Gitlab实现持续集成 [二]

Jenkins

项目:使用git+jenkins实现持续集成

image_1b4gl03571ate1e3gle918s1sd19.png-51.3kB

开始构建
image_1b4gl0e1rsl1k5011291osbckcm.png-110.2kB

General
image_1b4gl0o3mne110aqijn1b5n16sc13.png-60.3kB

源码管理
我们安装的是git插件,还可以安装svn插件
image_1b4gl1bullia17ivp7t1fi713lo1g.png-62.8kB

我们将git路径存在这里还需要权限认证,否则会出现error
image_1b4gl1vbf1kudvqhms11ejkdbh1t.png-72.8kB
我们添加一个认证
image_1b4gl27jgtljj3jr0hs64afj2a.png-41.9kB

选择一下认证方式(我们可以在系统管理-->Configure Credentials)里面进行设置

#提示:gitlab有一个key,是我们用来做仓库的key。拥有的权限是read-only
image_1b4gl322h3ose1q28krgg1bau2n.png-83.1kB

公钥我们需要在服务器上查看。

  1. [root@linux-node1 ~]# ssh-keygen -t rsa
  2. Generating public/private rsa key pair.
  3. Enter file in which to save the key (/root/.ssh/id_rsa):
  4. Created directory '/root/.ssh'.
  5. Enter passphrase (empty for no passphrase):
  6. Enter same passphrase again:
  7. Your identification has been saved in /root/.ssh/id_rsa.
  8. Your public key has been saved in /root/.ssh/id_rsa.pub.
  9. The key fingerprint is:
  10. 5c:55:51:4e:a0:ad:1f:87:e0:96:9b:24:a3:09:68:62 root@linux-node2
  11. The key's randomart image is:
  12. +--[ RSA 2048]----+
  13. | ..++o|
  14. | . o o |
  15. | . o . .|
  16. | . . . . + . |
  17. | E o . S o * o .|
  18. | . o . o = + o |
  19. | o o . |
  20. | |
  21. | |
  22. +-----------------+
  23. #在192.168.56.11 部署的节点上,生成key
  24. [root@linux-node1 ~]# cat .ssh/id_rsa.pub
  25. ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQDWEDIIatngRx5NaqU6t+f6FvY2RqYp3V3u5CNJS6xAamGokQ3MnbsTv/V8yKy2TpvNcXsaXmqwQtOVSAO4BzltidMPxBJUQCqKdMRbPqpzo7ZqGCuLcCfHC8M6tSbr1AaHkLbow29YbCMyzCCkjDfRcOez8yHuLj5BSFpKYCjx2wpJxoZ/Z6J8Fslsyu7MaRMvUhBMAF6mqQaC1qZ6K4BMt0IpAuJvoL4dNu9P6KcnG3Wy2zrzoKzkFUi0xpKCmpYo2bq4zRXgAFAndp44j5iMKEavWPeRH0RHTGsfE5vU5/0CI9LCRjtp/3vTaYlBryq5vNXb2abCrJXWws0jwp6L root@linux-node2

image_1b4gl423pj111i8budbg691rem34.png-87.5kB
我们设置完成后测试git是否可以拉去

  1. [root@linux-node2 ~]# yum install git -y
  2. #如果没有git命令就安装一个git客户端
  3. [root@linux-node1 ~]# git clone git@www.abcdocker.com:web/web-demo.git
  4. Cloning into 'web-demo'...
  5. The authenticity of host 'www.abcdocker.com (192.168.56.11)' can't be established.
  6. ECDSA key fingerprint is b5:74:8f:f1:03:2d:cb:7d:01:28:30:12:34:9c:35:8c.
  7. Are you sure you want to continue connecting (yes/no)? yes
  8. Warning: Permanently added 'www.abcdocker.com,192.168.56.11' (ECDSA) to the list of known hosts.
  9. remote: Counting objects: 10, done.
  10. remote: Compressing objects: 100% (8/8), done.
  11. remote: Total 10 (delta 0), reused 0 (delta 0)
  12. Receiving objects: 100% (10/10), 70.00 KiB | 0 bytes/s, done.

image_1b4gl524rjgso121tk61sjjada3h.png-82.4kB

私钥:

  1. [root@linux-node1 ~]# cat .ssh/
  2. id_rsa id_rsa.pub known_hosts
  3. [root@linux-node1 ~]# cat .ssh/id_rsa
  4. -----BEGIN RSA PRIVATE KEY-----
  5. MIIEpQIBAAKCAQEAoVULn6xsKj+XZMyFOGcFwo0bkrzFRjeZSXby/0BXJJpVaYVj
  6. LEMNOlbD4YHCNTQ4xmyjoeaW468pciVAooOWCCdcbjDmdmACt9knHjMZ1YRG/xuM
  7.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Ja/JowqJg4jp3hFXix1igb2N3YbA0PaX
  23. vLLNtjNInwh9SiLmdYdL8Pr5PZYUYykWb5rK4wdHdfHCaYRPrNuBNdC06ZRy7u6h
  24. QkDr1khNxKczPc1n8SA3VCe1AoGAYdWb39WIaoHquoqGppAfZnNQp/SSDkkLR6mi
  25. 10xWT5+H4oOWeZ+8SKfeSPnM9nO8p194jXz5SjXcDAbo1iIW++qubxAlp2+GRGZJ
  26. Lj+XkM2pFfoky5FYqOkKRVLMVB7RAph2kuCGu7NnhoT43dRPFYxlczKJBHeIOzfO
  27. qlLOoLECgYEAkexlwKGeXyJj481SfqCYhjiTjCiibx/s6yS2cmamgEKOZCB2osmq
  28. 3m9PvOAp26Sm1ISiuINNbpLY3Gi5fEvNUSyRx8HzRXP2fydvdgpltDxJUPaUVxvn
  29. X46F8ewsMJ7/FDLSyjdzwvoDRvKCk99OBmGmofqh5zW0GrjcQjthmbk=
  30. -----END RSA PRIVATE KEY-----
  31. [root@linux-node1 ~]#

image_1b4gl5rvr1pg17c1clljv41efa3u.png-54.8kB
刚刚返回刚刚的区域,继续配置

image_1b4gl63da1jg317mi1on8oef1nqv4b.png-80.7kB
现在我们复制git的url 就不会出现验证提示
image_1b4gl6b131b8nal51pni1eh4mbf4o.png-72.4kB
我们选择gitlab,url如下图
image_1b4gl6hl16ei1hch1lulu2dg7555.png-74kB
查看gitlab版本

  1. [root@linux-node1 ~]# rpm -qa|grep gitlab
  2. gitlab-ce-8.14.5-ce.0.el7.x86_64

image_1b4gl73k21f2f1tisve41pfu1c1a5i.png-19.3kB

我们现在就添加了一个git仓库,现在保存就可以了!
image_1b4gl7dj91runmg5154fjl41iqm5v.png-75.3kB
保存完毕后,我们选择立即构建
image_1b4gl7l2pave1ttg1o1299e1ird6c.png-82.2kB

点击Console Output 可以显示控制台的输出
image_1b4gl81kv138e1q2g7ssv7i1p5d6p.png-104.8kB

现在基本就算是构建成功了


  • 2
  • 8,358 views
    A+
发布日期:2016年12月22日  所属分类:Jenkins
标签:
新闻联播老司机

发表评论

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

目前评论:2   其中:访客  1   博主  1

  1. avatar 666 0
    写的很笼统 不细
    • avatar 新闻联播老司机
      感谢您的意见