文档章节

Continuous Integration

pillsilly
 pillsilly
发布于 2016/08/25 23:23
字数 1267
阅读 70
收藏 0

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

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

    CentOS 
    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:$PATH
    export PATH
    
  • Installing JDK 1.8

  • Install Nexus

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

     

  • 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):
    <!-- release to -->
    <distributionManagement>
                <repository>
                    <id>releases</id>
                    <name>releases</name>
                    <url>http://172.16.3.64:8081/nexus/content/repositories/releases/</url>
                </repository>
    </distributionManagement> 
    
    • In maven’s setting.xml (pls use mvn help:effective-settings to ensure that which file is currently effective)
    <mirror>
        <id>nexus-internal</id>
        <mirrorOf>*</mirrorOf><!-- means this nexus server would take over all the pull request from maven-->
        <name>nexus-internal</name>
        <url>http://172.16.3.64:8081/nexus/content/groups/public/</url>
    </mirror> 
    
    <server> 
      <id>releases</id>
      <username>admin</username>
      <password>admin123</password>
    </server>
    
  • Install Maven on server side (later will be used by Jenkins)

  • Install GitLab

     

    • Official Installation Guide : https://about.gitlab.com/downloads/#centos6
    • 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 gitlab-ce-8.8.5-ce.1.el6.x86_64.rpm
    • 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) 
       

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 here
    • 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@git 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 Gitlab Hook Plugin on Jenkins ,see Usage

      • 配置 –> Gitlab Web Hook 
        check the option : Trigger build also when pushing to merged branches

      • Project Configuration

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

        • go to Branches to build fill in with$BRANCH_TO_BUILD

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

    • Install Deploy to container Plugin
    • Do as follow 
       
    • enable tomcat manage console

      • configure the conf/tomcat-users.xml
        <role rolename="tomcat"/>
        <role rolename="role1"/>
        <role rolename="admin"/> 
        <role rolename="admin-script"/> 
        <role rolename="manager-gui"/> 
        <role rolename="manager-script"/> 
        <role rolename="manager"/> 
        <role rolename="admin-gui"/> 
        <user username="tomcat" password="tomcat" roles="manager,manager-gui,tomcat,role1,admin,admin-gui,manager-script,admin-script"/>
      

      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 link
    • install git

      • get latest git source package here
      • 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 testrepo1
      cd testrepo1
      git clone git@172.16.3.64:/home/soft/git/repo1/project.git
      

© 著作权归作者所有

pillsilly
粉丝 2
博文 23
码字总数 45873
作品 0
杭州
私信 提问
[笔记]CI笔记——CI业界术语

自动化的(automated) 构建(build) 持续(Continuous) 持续集成(Continuous Integration) 开发环境(development environment) 审查(inspection) 集成(integration) 集成构建(i...

leeoo
2011/12/24
39
0
Jenkins: The Definitive Guide - John Ferguson Smart

出版时间:2011年7月 语言:英语 下载地址: EPUB&PDF 内容简介: This book is aimed at relatively technical readers, though no prior experience with Continuous Integration is assume......

kklin
2016/02/15
2
0
Xcode Server + Slack = Rockstar Combo for iOS CI/CD

Xcode Server is a Continuous Integration service provided by Apple to analyze, build, test, and archive iOS apps. Xcode Server has been recently inbuilt with Xcode 9, which made......

Shashikant Jagtap
2017/12/12
0
0
Xcode Server + Ansible: Scalable and Programmable iOS CI/CD Infrastructure

One of the complaints about Xcode Server is it's not scalable to be used at a large-scale or enterprise level. However, if you have the skills to understand and manage an infras......

Shashikant Jagtap
2017/12/19
0
0
Continuous Testing at the Core of Frequent and Faster Software Releases

The way to build software has changed due to escalated market trends and consumer needs. However, conventional methods of developing software cannot meet the new demands in the ......

Venkatesh Akula
2017/12/16
0
0

没有更多内容

加载失败,请刷新页面

加载更多

golang-字符串-地址分析

demo package mainimport "fmt"func main() {str := "map.baidu.com"fmt.Println(&str, str)str = str[0:5]fmt.Println(&str, str)str = "abc"fmt.Println(&s......

李琼涛
今天
4
0
Spring Boot WebFlux 增删改查完整实战 demo

03:WebFlux Web CRUD 实践 前言 上一篇基于功能性端点去创建一个简单服务,实现了 Hello 。这一篇用 Spring Boot WebFlux 的注解控制层技术创建一个 CRUD WebFlux 应用,让开发更方便。这里...

泥瓦匠BYSocket
今天
8
0
从0开始学FreeRTOS-(列表与列表项)-3

FreeRTOS列表&列表项的源码解读 第一次看列表与列表项的时候,感觉很像是链表,虽然我自己的链表也不太会,但是就是感觉很像。 在FreeRTOS中,列表与列表项使用得非常多,是FreeRTOS的一个数...

杰杰1号
今天
9
0
Java反射

Java 反射 反射是框架设计的灵魂(使用的前提条件:必须先得到代表的字节码的 Class,Class 类 用于表示.class 文件(字节码)) 一、反射的概述 定义:JAVA 反射机制是在运行状态中,对于任...

zzz1122334
今天
7
0
聊聊nacos的LocalConfigInfoProcessor

序 本文主要研究一下nacos的LocalConfigInfoProcessor LocalConfigInfoProcessor nacos-1.1.3/client/src/main/java/com/alibaba/nacos/client/config/impl/LocalConfigInfoProcessor.java p......

go4it
昨天
9
0

没有更多内容

加载失败,请刷新页面

加载更多

返回顶部
顶部