码迷,mamicode.com
首页 > 其他好文 > 详细

CentOS配置Jenkins

时间:2016-08-22 12:01:42      阅读:889      评论:0      收藏:0      [点我收藏+]

标签:

本文主要记录自己在CentOS安装Jenkins时遇到的问题。希望对大家有所帮助:

 

安装步骤比较简单,Centos安装tomcat,部署Jenkins的包,然后根据需要安装插件(如git、maven等)即可。这里不再赘述。

然后在Jenkins的“系统管理”->“Global Tool Configuration”中配置JDK、Git、Maven。如下图所示:

技术分享

 

1、遇到的第一个问题:Git安装后,配置项目的git路径后,Jenkins马上在工程的git路径下面提示如下错误:

 

Failed to connect to repository : Command "git config --local credential.helper store --file=/tmp/git2956041026506359040.credentials" returned status code 129:
stdout: 
stderr: error: unknown option `local‘
usage: git config [options]

Config file location
    --global              use global config file
    --system              use system config file
    -f, --file <FILE>     use given config file

Action
    --get                 get value: name [value-regex]
    --get-all             get all values: key [value-regex]
    --get-regexp          get values for regexp: name-regex [value-regex]
    --replace-all         replace all matching variables: name value [value_regex]
    --add                 adds a new variable: name value
    --unset               removes a variable: name [value-regex]
    --unset-all           removes all matches: name [value-regex]
    --rename-section      rename section: old-name new-name
    --remove-section      remove a section: name
    -l, --list            list all
    -e, --edit            opens an editor
    --get-color <slot>    find the color configured: [default]
    --get-colorbool <slot>
                          find the color setting: [stdout-is-tty]

Type
    --bool                value is "true" or "false"
    --int                 value is decimal number
    --bool-or-int         value is --bool or --int
    --path                value is a path (file or directory name)

Other
    -z, --null            terminate values with NUL byte

原因:git版本过低。原来我是用yum install git安装的git,执行git --version,发现版本是1.7.1。而Jenkins需要1.7.4以上的git版本,才支持--local选项。

 

解决方法:网上搜了一些文章,可以自行下载git 2.1.2的源码,下载gcc然后自己编译。文章在这里,大家可以参考我转载的这篇文章《Centos 6.5升级git版本的办法》

完成后,不再报此错误。

 

2、遇到的第二个问题:git提示新的问题:

 

Failed to connect to repository : Command "/usr/local/git/bin/git -c core.askpass=true ls-remote -h http://www.xxx.com/gitlab/root/test.git HEAD" returned status code 128:
stdout: 
stderr: fatal: Unable to find remote helper for ‘http‘

或者

 

 

Failed to connect to repository : Command "git ls-remote -h git@xxxxx.com:xxx/dev_test.git HEAD" returned status code 128:
stdout: 
stderr: Permission denied, please tryagain. 
Permission denied, please try again. 
Permission denied(publickey,gssapi-keyex,gssapi-with-mic,password). 
fatal: The remote end hung up unexpectedly

原因:没有配置git的ssh key。

 

解决方法:执行下面的命令,生成key

 

ssh-keygen -t rsa -C "admin@example.com"

然后将~/.ssh/目录下的id_rsa.pub中的公钥,放到git的ssh key中。再在Jenkins中创建新的Credentials。类型是SSH Username with private key。Username使用ssh-keygen中用到的邮箱,Private Key中选择“From the Jenkins master ~/.ssh”即可。

 

修改后,问题解决。

3、安装Maven。

Maven不支持通过Centos的yum进行安装,需要手工安装。大家可以参考我转载的这篇文章:《Centos6.5安装Maven

CentOS配置Jenkins

标签:

原文地址:http://www.cnblogs.com/zhengzaipeng/p/5794696.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!