• Jenkins环境初步配置


    为研究在kubernetes上的CICD,先在物理环境下安装个JenKins热热身。

    • 安装Jenkins

    在官网https://jenkins.io/下载war包,我的是http://mirrors.jenkins.io/war/latest/jenkins.war

    然后运行(必须jdk1.8版本)

    java -jar jenkins.war

    如果端口冲突,加上参数

    java -jar jenkins.war --httpPort=9090
    • 插件配置

    在http://localhost:9090/的界面,选择Manage Plugins

    安装 ant plugin,git plugin,maven integration plugin,ssh plugin, publish to ssh plugin.

    选择Manage Jenkins->Global Tool Configuration

    配置ant,maven,jdk的地址(安装过程略)

    • 构建配置 

    新建一个item,叫jenkins_test,并选择maven project.

    在Source Code Management中选择git,输入网上大侠的代码地址

    https://github.com/bingyue/easy-springmvc-maven

    Build Trigger等保持不变,但在Post step中,加入代码

    tomcat_path=/home/ericnie/apache-tomcat-7.0.82/
    project=easy-springmvc-maven
    war_name=easy-springmvc-maven.war
    war_path=http://192.168.0.104:8080/jenkins/job/jeekins-test/ws/target
    server_port=9080
    file_path=/home/ericnie/.jenkins/workspace/jenkins_test/target/
     
    now=$(date +"%Y%m%d%H%M%S")
    echo "the shell execute time is ${now}"
     
    echo `lsof -n -P -t -i :${server_port}`
    tomcat_pid=`lsof -n -P -t -i :${server_port}`
    echo "the tomcat_pid is ${tomcat_pid}"
     
    if [ "${tomcat_pid}" != "" ]; then 
       kill -9 $tomcat_pid
       echo "kill the server"
    fi 
     
    echo "rm ${tomcat_path}/webapps/${war_name}"
    rm ${tomcat_path}/webapps/${war_name}
     
    echo "rm -rf ${tomcat_path}/webapps/${project}"
    rm -rf ${tomcat_path}/webapps/${project}
     
    cd $file_path
    if [ -f ${war_name} ]; then 
       cp ${war_name} ${tomcat_path}/webapps
    else
       echo "${war_name} unexists"
    fi
     
    export JAVA_HOME=/home/ericnie/jdk1.8.0_151
    export CATALINA_HOME2=/home/ericnie/apache-tomcat-7.0.82/
    export CATALINA_BASE2=/home/ericnie/apache-tomcat-7.0.82/
    /home/ericnie/apache-tomcat-7.0.82//bin/startup.sh
    echo "server restarted"

    这段脚本还需要修改一下,目前脚本运行成功的条件是需要tomcat已经启动,并且在webapps下有个easy-springmvc-maven.war的包

    然后需要再安装一个tomcat,监听在9080.(略) 

    选择Build Now

    选择最新的build number,选择console output

    基于日志信息进行问题定位直到成功。

    + echo 'kill the server'
    kill the server
    + echo 'rm /home/ericnie/apache-tomcat-7.0.82//webapps/easy-springmvc-maven.war'
    rm /home/ericnie/apache-tomcat-7.0.82//webapps/easy-springmvc-maven.war
    + rm /home/ericnie/apache-tomcat-7.0.82//webapps/easy-springmvc-maven.war
    + echo 'rm -rf /home/ericnie/apache-tomcat-7.0.82//webapps/easy-springmvc-maven'
    rm -rf /home/ericnie/apache-tomcat-7.0.82//webapps/easy-springmvc-maven
    + rm -rf /home/ericnie/apache-tomcat-7.0.82//webapps/easy-springmvc-maven
    + cd /home/ericnie/.jenkins/workspace/jenkins_test/target/
    + '[' -f easy-springmvc-maven.war ']'
    + cp easy-springmvc-maven.war /home/ericnie/apache-tomcat-7.0.82//webapps
    + export JAVA_HOME=/home/ericnie/jdk1.8.0_151
    + JAVA_HOME=/home/ericnie/jdk1.8.0_151
    + export CATALINA_HOME2=/home/ericnie/apache-tomcat-7.0.82/
    + CATALINA_HOME2=/home/ericnie/apache-tomcat-7.0.82/
    + export CATALINA_BASE2=/home/ericnie/apache-tomcat-7.0.82/
    + CATALINA_BASE2=/home/ericnie/apache-tomcat-7.0.82/
    + /home/ericnie/apache-tomcat-7.0.82//bin/startup.sh
    Tomcat started.
    + echo 'server restarted'
    server restarted
    Finished: SUCCESS

    然后,运行http://localhost:9080/easy-springmvc-maven访问测试。

  • 相关阅读:
    2.8 Classes of Restricted Estimators
    navicat远程登录windows服务器
    面试题
    【南阳OJ分类之语言入门】80题题目+AC代码汇总
    基于‘BOSS直聘招聘信息’分析企业到底需要什么样的PHPer
    数据开源
    Pyhton爬虫实战
    Python爬虫框架Scrapy实战
    做网站用UTF-8编码还是GB2312编码?
    【南阳OJ分类之大数问题】题目+AC代码汇总
  • 原文地址:https://www.cnblogs.com/ericnie/p/7700870.html
Copyright © 2020-2023  润新知