• jenkins+gitlab实现自动部署


    第一节实验环境

    jenkins100  ==>  192.168.68.100

    gitlab119  ==>  192.168.68.119

    web50  ==>  192.168.68.50

    [root@jenkins100 ~]# cat /etc/redhat-release

    CentOS Linux release 7.4.1708 (Core)

    [root@jenkins100 ~]# systemctl stop firewalld

    [root@jenkins100 ~]# systemctl disable firewalld

    [root@jenkins100 ~]# iptables -F

    [root@jenkins100 ~]# setenforce 0

    第二节软件安装

    1、gitlab安装

    gitlab安装参考:https://www.jianshu.com/p/c1ee7d92f2da

    2、jenkins安装

    jenkins安装参考:https://www.jianshu.com/p/bc717818d179

    [root@jenkins100 ~]# ssh-keygen -t rsa -f '/root/.ssh/id_rsa' -N ''

    传公钥到web50实现无密码登录

    [root@jenkins100 ~]# ssh-copy-id 192.168.68.50  

    3、web-nginx安装

    nginx安装参考:https://www.jianshu.com/p/932cbe462050

    4、web50、jenkins100

    [root@jenkins100 ~]# yum -y install git

    [root@web50 ~]# yum -y install git

    第三节配置gitlab

     
     
     
     
     
     
     
     
     
     

    获取公钥

    [root@jenkins100 ~]# cat /root/.ssh/id_rsa.pub

    ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQDvzmMsyngyYVd3C8+ruTb4uy7RZ9ABOzRJZsqz1J2kjHy+wMa7yurYt5Sx9Ugtl499YLxO2r0eOZZjPZLEixWQa+bU7bBePSL6WKlB/looLggKyR2GWP7wcTgFuE53Rd+YikmMsKut4ObP817U63nlby0NlpK2jTUcKH7h1AsmaXRRsucoHrglZgFeiNHnOwoqyXwezOx71SZZJQRcp5+KqriyTpFucfvmUYcJAA4RKVz2pSdRRKQr8Q6Gmir65B1EMgf5s6OIuRgBNi50V5vlYjesHxLleBRf4t0Zx+qKC1W6bF7KOVdOUiYDgJJBSibnDe5AY6cZ8Wxs4qdiEIPJ root@jenkins100

     
     
     
     

    第四节配置jenkins

    1、插件安装

    打开jenkins页面

    添加插件:系统管理 - 插件管理 #需要添加的插件:Gitlab Hook、Build Authorization Token Root、Publish Over SSH、Gitlab Authentication、Gitlab、Git Paramete

    2、配置jenkins自动部署到的主机

    提示:这里配置到web50,话不多说,看图

    获取私钥

    [root@jenkins100 ~]# cat /root/.ssh/id_rsa

    -----BEGIN RSA PRIVATE KEY-----

    MIIEpAIBAAKCAQEA785jLMp4MmFXdwvPq7k2+Lsu0WfQATs0SWbKs9SdpIx8vsDG

    u8rq2LeUsfVILZePfWC8Ttq9HjmWYz2SxIsVkGvm1O2wXj0i+lipQf5aKC4ICskd

    hlj+8HE4BbhOd0XfmIpJjLCrreDmz/Ne1Ot55W8tDZaSto01HCh+4dQLJml0UbLn

    KB64JWYBXojR5zsKKsl8Hszse9UmWSUEXKefiqq4sk6RbnH75lGHCQAOESlc9qUn

    UUSkK/EOhpoq+uQdRDIH+bOjiLkYATYudFeb5WI3rB8S5XgUX+LdGcfqigtVumxe

    yjlXTlImA4CSQUom5w3uQGOnGfFsbOKnYhCDyQIDAQABAoIBAQCMlR2m4HtebZps

    +8ufDFGht3pW4NkcH60jatNiYT6ZfJKU8UaQSQEsU1MkkHrj33oLMm6ye6Fq2q/D

    NhGYj0DxDZChO0atuIGM6fUv7wDDlVi5mfVpETtDkdwZ3laBrcDLGCbOB7Rdlv84

    4Z+yiulHC8oJsUAJLPb5rvPTSA/RT9aS14nS70rqnd+7fF/2xREF6XZ5wZE5saxM

    m2sA5vQ/NpV1L764TrH0CGpt0Q417DqjuEmEl/yp6MKt1w+uXXHFbB3OMKJ1KPIS

    YjJ+sNiL3m+wB0pVB6ADjjx5cerRoYhtvtvYHYPzKyg83kXeFyQ1Qixs1J+n7KWe

    ojAwqMVBAoGBAPh9gXtqhj8GbIcVGvZxzUicaH9IeT9qjFuCFJ5k9VwM0lDZNYwK

    PcADedlKznAlS/Iyt0HsU4XiJpkIElVye1SxOYt5xN1dhHWj/MYdkz4ntFhyFaXK

    vo9zavDKnz48QSaJhSEzo99YD4kaYr6iZd/BD0K9fRuploNcWIRTH/C9AoGBAPcN

    shiYFnLRdoRTbFd61RceUGFgcPln8JyVEtpbrz6FDKQBQWaRLzwbmN5KGQQkPvZm

    TiGLNIqegrSrsgq/u6VmZQWIcgISgKBeopLYHg7ROPL8lRIwik9pDiNSm5kd60X7

    5UjKCpSb8Js0ZNaM0Hx6XJVKH4ZsrM3bXlqwvg39AoGAcLd9pJ4Nh0lCsYPBV0kH

    9Yf9Xr9hQIL0aA35jF//bGHkhQgCYiPDHvZ0rzxfqD9C0/ptZlntCS4sk/41Us07

    ZI9/quTxh/iDvVlFsBh6Uhdwly4o46u0BR41xEQlN/XdF74JxaXHD+jCI070u8Su

    sXDBm2SY+5NR0wRwopWSR4ECgYBkJyEz5zPyiAfLzSX2sM0B+kALudUSxpg8YhKq

    gtCgP7/IHNouglzruSRXuSI7E5aSvRafcpdyOqAyLgiXYvLnMoNxosbVIDsUyEiP

    zx0gVKEJoGuuXA818hjRKQP7Jq3iSSPCRmXTqQP5Z1wZviwmylQOEWaGUDgdm/i8

    OzpQ4QKBgQDIS9sHa4OCFkrt1cP5OsFps8hGObvBlRjGZ2X4pxnL8y4YxQdlyxzJ

    SpJSAHwi+iQb66CNVjDDU3dckfmcnPcUsjOytd27tj2gKx4cA4tBQbBnxb3Nn57B

    I2DaMjw+29MGRew8XNiZa9T9OqYnVjfLWKPgUTAn9KhP/qOGCSRrCQ==

    -----END RSA PRIVATE KEY-----

     
     
     
     
     
     
     
     
     
     

    3、构建任务

    配置jenkins

     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     

    配置gitlab

     
     
     
     
     
     
     
     
     
     

    第五节测试

    [root@jenkins100 ~]# git clone http://192.168.68.119/root/test.git

    [root@jenkins100 ~]# cd test/

    [root@jenkins100 test]# ls

    README.md

    [root@jenkins100 test]# echo 'test jenkins!!!!' > index.html

    [root@jenkins100 test]# git add .

    [root@jenkins100 test]# git commit -m 'test commit'

    [master dd54522] test commit

    1 file changed, 1 insertion(+)

    create mode 100644 index.html

    [root@jenkins100 test]# git push

    查看jenkins

     
     

    查看gitlab

     
     

    查看web

     
     

    常见错误1

     
     

    解决办法

     
     

    作者:羅皲
    链接:https://www.jianshu.com/p/120108fbf68e
    来源:简书

  • 相关阅读:
    解决docker pull很慢的方法
    Linux 基础 Day1
    linux运维人员必须熟悉的运维工具汇总
    chrome 浏览器插件推荐
    只能运维主要职责
    Linux查看所有用户用命令
    ubuntu16.04 离线包安装docker
    2013-10
    ELK原理与介绍
    shell中各种括号的作用()、(())、[]、[[]]、{}
  • 原文地址:https://www.cnblogs.com/yueminghai/p/12929048.html
Copyright © 2020-2023  润新知