博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
Continuous Integration
阅读量:6222 次
发布时间:2019-06-21

本文共 7426 字,大约阅读时间需要 24 分钟。

hot3.png

-- 几个月前的学习笔记,懒得再翻译回来了

Continuous Integration

  • Continuous Integration
        • Purpose & Main Goals
        • Enviroment Infomation
        • Configuring Env Path
        • Installing JDK 1.8
        • Install Nexus
        • Configuring iptables
        • Verify Nexus service by setting up a Maven project
        • Install Maven on server side (later will be used by Jenkins)
        • Install GitLab
        • Enable SSH connection using GitLab without password
        • Install Jenkins
        • Setup automated build in Jenkins with Gitlab’s Web Hook feature
        • Setup automated deploy after build in Jenkins
        • Install Git server(Optional)
  • Purpose & Main Goals

    1.  Automatically build

    2.  Expose problems earlier.

    3.  Common module management.

    4.  Internal Maven Server makes building process faster.

    5.  Set up the standard of the whole life circle of Soft Ware development.

    6.  Code Review Process setup

    7.  Build trigger

    8.  Automatically deploy

    9.  Automatically test run : (Front end and Back End (Unit Test Framework integration))

    10.  base platforms setup gitlab , nexus,jenkins , maven 

  • Enviroment Infomation

     

    root @ qazwsx%1984416ssh 
    work dir : /home/soft

  • Configuring Env Path

    open /etc/profile,add below text to the end

    PATH=/var/opt/gitlab/git-data/repositories:$PATHexport PATH
  • Installing JDK 1.8

    • rpm -ivh 
  • Install Nexus

    in this case , we use the nexus 2 because it’s more friendly with maven then nexus 31

    • tar -xvf 
    • run /home/soft/nexus-extract/nexus-2.13.0-01/bin/nexus
    •  
      - default account : admin/admin123

     

  • Configuring iptables

    vi /etc/sysconfig/iptables

    add this to the end : -A INPUT -p tcp -m sate --state NEW -m tcp --dport 8081 -j ACCEPT

    or ,simply turn off the iptable service by service iptables stop

  • Verify Nexus service by setting up a Maven project

    • In project’s pom.xml,add this(it tells maven which repository to deploy the jar):
    releases
    releases
    http://172.16.3.64:8081/nexus/content/repositories/releases/
    • In maven’s setting.xml (pls use mvn help:effective-settings to ensure that which file is currently effective)
    nexus-internal
    *
    nexus-internal
    http://172.16.3.64:8081/nexus/content/groups/public/
    releases
    admin
    admin123
  • Install Maven on server side (later will be used by Jenkins)

    • tar -xvf 
  • Install GitLab

     

    • Official Installation Guide : 
    • If you’re in CentOS 6/7 , to avoid from the network connectivity problem in China, I suggest you use the rpm way. 
      in my case : I use 
    • install path would be : /var/opt/gitlab
    • default repository is /var/opt/gitlab/git-data
    • setting file is : /etc/gitlab/gitlab.rb
    • Use gitlab-ctl to manage the application (start,stop,tail,etc)
    • Problems occured solved: 
      • Port in use ? 
        Because the component “Tweak” using 8080 as the default port,if it’s been taken by any other program,GitLab would be failed to start. 

     

    To change the port 

    • vi /etc/gitlab/gitlab.rb
    • Find session # GitLab Unicorn #
    • Modify unicorn['listen'] = '127.0.0.1',unicorn['port'] = 8090
    • Apply changes : sudo gitlab-ctl reconfigure
    • Check logs sudo gitlab-ctl tail
    • Set git user’s default shell to bash : usermod -s /bin/bash git 
  • Default Account ? 
    1. During the installing process,you’d be asked to set your password,it means your current Linux account ,e.g root;After installation has been done,you can use that to login into the system.
    2. If there’s no account/pwd setting process came out during the installation,you can register one from the entry index,and it’d be the admin authority.
  • Enable SSH connection using GitLab without password

    • Use Git Bash as the Git Client in Windows.
    • Open GitBash from user home dir : e.g C:\Users\bob\.ssh>
    • Execute command : ssh-keygen -t rsa

      C:\Users\bob\.ssh>ls    id_rsa  id_rsa.pub  known_hosts     type %userprofile%\.ssh\id_rsa.pub | clip
    • Go to GitLab User Profile Page,add a SSH Key like below (the key’s already in your clip) 

       232007_DuXZ_560844.png

About ssh no-pwd verify login: 

After your execute the command ssh-keygen -t rsa 
The generated 3 files : id_rsa, id_rsa.pub , known hosts are bound together on the client side ,and it must be under client side’s user folder (in this case : C:\Users\bob\.ssh). 
After you gave out the public key id_rsa.pub to the server side , where did it go? 
it’s been added to the end of the file of /var/opt/gitlab/.ssh/authorized_keys on the server side

  • Install Jenkins

    • Download latest Jenkins 
    • Start it with executing nohup java -jar jenkins.war & . 
      Or you can deploy it into tomcat , which is more recommended.
    • Install git plugin from system admin page.
    • To add Credential,here are the steps: 
      1. Supposed I’m trying to add a project and my git accont is bob
      2. Login as bob in git server
      3. ssh-keygen -t rsa press ENTER till it’s done.*(this will gen 2 files “id_rsa”,”id_rsa.pub” under default user home “/home/bob/.ssh”,cat id_rsa and you’ll see the private key content )
      4. go to the jenkins admin page : index->Credentials->System->Goblal credentials->Add Credentials
      5. Kind: SSH
      6. Scope: Global
      7. Username : your git username(linux account)
      8. Private Key : Enter directly (step 3)
      9. other field just leave for empty
    • try a maven project build with jenkins 
      • index -> new
      • choose maven,next
      • choose git and give the git url
      • choose the credential that you just created. save
      • click build on the left side
  • Setup automated build in Jenkins with Gitlab’s Web Hook feature

    • GitLab: 
      • go to Settings > Webhooks
      • at “URL” fill in with http://172.16.3.64:8180/jenkins/gitlab/build_now/eclipse_maven_web
      • at “Trigger” choose whenever you want it to be triggered.
    • Jenkins:

      • Install plugin  on Jenkins ,see 

      • 配置 –> Gitlab Web Hook 

        check the option : Trigger build also when pushing to merged branches

      • Project Configuration

        • 参数化构建过程,do as follow 

          232007_yATz_560844.png ;

        • go to Branches to build fill in with$BRANCH_TO_BUILD

        • go to source browser,do as follow 
           232007_wD6W_560844.png
  • Setup automated deploy after build in Jenkins

    • Install 
    • Do as follow 
       232007_oq9R_560844.png
    • enable tomcat manage console

      • configure the conf/tomcat-users.xml

      tomcat/tomcat would be the user Jenkins’d use.

  • Install Git server(Optional)

    • install neccesary dependence 
      • yum install curl-devel expat-devel gettext-devel openssl-devel zlib-devel perl-devel 
        some times the zlib env might go wrong ,try download and make install
      • wget http://jaist.dl.sourceforge.net/project/libpng/zlib/1.2.8/zlib-1.2.8.tar.gz
      • other dependence error pls ref to this 
    • install git

      • get latest git source package 
      • tar -zxvf git-2.9.0.tar.gz
      • cd git2.9
      • ./configure
      • make
      • make install
      • git version
    • add git accounts on server side

      • add a user : useradd -g git git
      • set password for it : passwd git
      • delete a user (-f means also delete user’s folder) userdel -f git
    • create a test repository directory

      • mkdir /home/soft/git/repo1
      • initial : git init --bare project.git
    • grand authority

      • sudo chown -R git:git project.git
    • ssh setting (client side)

      • ssh-keygen -t rsa
      • scp ~/.ssh/id_rsa.pub root@192.168.56.1:~/

    or you can pass your rsa key in text ,after key generating,do cat rsa.pub and you’ll see the rsa key content, 

    pass it to server admin,and he shall write that into /home/git/.ssh/authorized_keys (real path might depends)

    • verify uploaded file(server side): ls ~/id_rsa.pub

    • try it on client side

      mkdir testrepo1cd testrepo1git clone git@172.16.3.64:/home/soft/git/repo1/project.git

转载于:https://my.oschina.net/u/560844/blog/738056

你可能感兴趣的文章
这篇是ECMAScript 2016、2017和2018中所有新特性的示例!
查看>>
【重温基础】5.表达式和运算符
查看>>
【芝士整理】CSS经典布局
查看>>
MySQL数据库设计规范
查看>>
探寻hashmap
查看>>
从入门到求职,成为数据科学家的终极指南
查看>>
Vue.js 图标选择组件实践详解
查看>>
【整理总结】负载均衡浅析
查看>>
HeaderViewListAdapter.isEnabled数组越界问题分析
查看>>
测试本地node包
查看>>
Windows平台下安装或卸载Apache服务
查看>>
开发第一个VUE插件
查看>>
解析世界杯超大规模直播场景下的码率控制
查看>>
聊聊BOM的那些事
查看>>
Xamarin 学习笔记 - Page(页面)
查看>>
JavaScript中的函数个人分享
查看>>
Promise A+ 中文翻译
查看>>
FPGA加速:面向数据中心和云服务的探索和实践
查看>>
利用Object.prototype.toString.call()来进行类型检验
查看>>
如何在Vue里建立长按指令
查看>>