Jenkins安装使用

一、安装git

  1. 安装依赖
    yum install curl-devel expat-devel gettext-devel openssl-devel zlib-devel gcc perl-ExtUtils-MakeMaker -y
  1. 下载安装包https://github.com/git/git/releases
    wget https://github.com/git/git/archive/v2.21.0.tar.gz

  2. 源码安装git

    tar -zxvf v2.21.0.tar.gz #解压
    cd git-2.21.0
        make prefix=/usr/local/git all #编辑
        make prefix=/usr/local/git install #安装
  1. 编辑环境配置文件
    vim /etc/profile
    # 末尾添加
    export PATH=$PATH:/usr/local/git/bin
    # 生效环境变量
    source /etc/profile
  1. 检验安装
git --version

二、安装jdk (https://tomcat.apache.org/)

  1. 解压安装
    tar -zxvf jdk-8u221-linux-x64.tar.gz -C /usr/local/
    cd /usr/local/
    mv jdk1.8.0_151 jdk
  1. 添加环境变量
    vim /etc/bashrc
    #添加以下代码  
    JAVA_HOME=/usr/local/jdk
    CLASSPATH=$JAVA_HOME/lib/
    export PATH=$PATH:$JAVA_HOME/bin
   #重新加载环境变量
   source /etc/bashrc

3.检验安装
java -version

三、安装maven

1.下载安装包 http://mirror.bit.edu.cn/

 wget http://mirror.bit.edu.cn/apache/maven/maven-
3/3.5.4/binaries/apache-maven-3.5.4-bin.tar.gz

2. 解压安装

tar -xzvf apache-maven-3.5.4-bin.tar.gz -C  /usr/local/
        mv /usr/local/apache-maven-3.5.4-bin.tar.gz  /usr/local/maven

3.添加环境变量

        vim /etc/bashrc
        export M2_HOME=/usr/local/maven
        export M2=$M2_HOME/bin
        PATH=$M2:$PATH
        source /etc/bashrc

4.检验安装

  mvn -version

四、安装tomcat

1.解压安装

        tar xvzf apache-tomcat-9.0.1.tar.gz -C /usr/local/
        mv /usr/local/apache-tomcat-9.0.1 /usr/local/tomcat

2.添加环境变量

        vim /etc/profile
        CATALINA_HOME=/usr/local/tomcat
        export CATALINA_HOME
        source /etc/profile

3.启动与关闭

      #启动
        /usr/local/tomcat/bin/startup.sh
       #关闭
        /usr/local/tomcat/bin/shutdown.sh

五、安装jenkins

    jenkins网址:http://mirror.bit.edu.cn/jenkins/war/


1.下载jenkins

    wget http://mirror.bit.edu.cn/jenkins/war/2.167/jenkins.war

2.将jenkins.war放到tomcat中,启动tomcat时自动解压webapps下的war包

    cp jenkins.war /usr/local/tomcat/webapps/

3. 网址访问jenkins,查看密码

    cat /root/.jenkins/secrets/initialAdminPassword

4.管理插件.选择推荐安装,自动安装插件,安装插件失败后,进入主页再手动安装.以下插件为必须

    GIT plugin
    Publish Over SSH
    Maven Integration plugin
    Deploy to container
    Maven Integration
    GitHub Authenticattion plugin
    GitHub Branch Sourch Plugin
    GitHub Organization Folder Plugin

5.jenkins全局工具配置,配置git,jdk,maven的根目录

    jdk:
    去掉自动安装,JDK=jdk1.8.0,JAVA_HOME=/usr/local/jdk
    git:
    去掉自动安装,Name:Default;Path to Git executable:/usr/local/git/bin/git
    maven:
    去掉自动安装,name:maven3.5.3;MAVEN_HOME:/usr/local/maven

6.系统配置.ssh设置,手动配置ssh key,通过ssh自动化推送到远程服务器

a).jenkins服务器准备秘钥认证
    ssh-keygen #生成秘钥对,位于/root/.ssh/
    ssh-copy-id -i 139.155.39.41 #设置远程服务器免钥登录
    ssh [email protected] #免钥登录
b).jenkins系统配置中设置ssh
        Path to key=/root/.ssh/id_rsa
c).jenkins系统配置中添加ssh server远程服务器

你可能感兴趣的:(Jenkins安装使用)