配置jenkins过程中遇到的坑

  • Post author:
  • Post category:其他




配置jenkins过程中遇到的坑

  1. 安装gitlab出现502报错,报错内容如下:

    502

    GitLab is not responding.

    Please contact your GitLab administrator if this problem persists

    具体安装步骤百度即可,报错原因

    1)端口被占用

    解决办法:vim /etc/gitlab/gitlab.rb

    在这里插入图片描述
    修改gitlab访问地址及端口

    2)内存不够

    解决办法:

    换一个内存够的主机咯
    在这里插入图片描述
  2. 配置jenkins无法连接数据源仓库

    Command “/usr/local/git/bin/git ls-remote -h – git@xxx:gongdan/workflow.git HEAD” returned status code 128:

    stdout:

    stderr: Permission denied, please try again.

    Permission denied, please try again.

    Permission denied (publickey,gssapi-keyex,gssapi-with-mic,password).

    fatal: Could not read from remote repository.

Please make sure you have the correct access rights

and the repository exists.
无法连接仓库报错

出现这种报错原因:

1.由于gitlab所在服务器的git,默认安装的版本较低

解决方法:升级版本

git –version

yum remove -y git

yum -y install gcc perl-ExtUtils-MakeMaker

yum -y install libcurl-devel expat-devel curl-devel gettext-devel openssl-devel zlib-devel

wget https://mirrors.edge.kernel.org/pub/software/scm/git/git-2.9.5.tar.gz

tar -zvxf git-2.9.5.tar.gz

cd git-2.9.5.tar

make prefix=/usr/local/git all

make prefix=/usr/local/git install

make prefix=/usr/local/git all

3.使用maven构建环境

在这里插入图片描述

构建后操作,复制jar包到指定位置,执行脚本

在这里插入图片描述

脚本内容:

#!/bin/bash
APP_NAME=/usr/local/java/app/workflow/workflow-0.0.1-SNAPSHOT.jar
jar_name=workflow-0.0.1-SNAPSHOT.jar
#拷贝jar包
cpjars(){
    file_path=/root/.jenkins/workspace/workflow/target
    if [ -f "$jar_name" ]
    then
    mv ./$jar_name ./backup/$jar_name.`date +%Y%m%d%H%M%S`
    fi
    cp $file_path/$jar_name .
}
is_exist(){
  pid=`ps -ef|grep $jar_name|grep -v grep|awk '{print $2}'`
  #如果不存在返回1,存在返回0     
  if [ -z "${pid}" ]; then
   return 1
  else
    return 0
  fi
}
#启动方法
start(){
  cpjars
  is_exist
  if [ $? -eq 0 ]; then
    echo "${jar_name} is already running. pid=${pid}"
  else
    nohup java -jar ${jar_name}  >robotcenter.out 2>&1 &
    echo "======${jar_name}已启动===="
  fi
}

#停止方法
stop(){
  is_exist
  if [ $? -eq "0" ]; then
    kill -9 $pid
    echo "======${jar_name}已停止===="
  else
    echo "${jar_name} is not running"
  fi  
}
#输出运行状态
status(){
  is_exist
  if [ $? -eq "0" ]; then
    echo "${jar_name} is running. Pid is ${pid}"
  else
    echo "${jar_name} is NOT running."
  fi
}

#重启
restart(){
  stop
  start
}

#根据输入参数,选择执行对应方法,不输入则执行使用说明
case "$1" in
  "start")
    start
    ;;
  "stop")
    stop
    ;;
  "status")
    status
    ;;
  "restart")
    restart
    ;;
  *)
    usage
    ;;
esac



版权声明:本文为lzhlovelyl原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接和本声明。