1 How to install git by “make”
编译基础环境环境和依赖的包
yum -y install gcc make yum install -y curl curl-devel zlib-devel openssl-devel perl perl-devel cpio expat-devel gettext-devel
对于定制的一些系统,找不到依赖时,可能要修改repo源:http://mirrors.163.com/.help/centos.html:
wget http://mirrors.163.com/.help/CentOS6-Base-163.repo
如果遇到下载不了的,可以手工下载至/var/cache/yum/i386/6/base/packages类似目录
下载和安装:
wget http://www.codemonkey.org.uk/projects/git-snapshots/git/git-latest.tar.xz xz -d git-latest.tar.xz tar -xvf git-latest.tar cd git-2015-09-07/ autoconf ./configure make && make install ln -s /usr/local/bin/git /usr/bin/git
批处理命令为:
wget http://www.codemonkey.org.uk/projects/git-snapshots/git/git-latest.tar.xz; xz -d git-latest.tar.xz; tar -xvf git-latest.tar; cd git-2015-09-07; autoconf; ./configure; make && make install; ln -s /usr/local/bin/git /usr/bin/git
2 Jenkins download git repository timeout error:
Jenkins使用git作为scm时,默认N多操作使用的都是10分钟作为timeout时间的设置,当git clone的repo太大,例如超过1G或下载速度太慢时,会download不了代码:
ERROR: Timeout after 10 minutes所以要求助git jenkins插件的”Additional Behaviours“修改下timeout的时间以解决timeout问题:
3 How to download sub folder for GIT in jenkins:
当一个repository太大时,N个JOB如果没有共享workspace,则占用磁盘的空间为N*repo大小,而实际中,我们确实只需要git里面的某一个子目录而已,所以可以使用sparse checkout来解决,同样求助于Additional Behaviours来设置:
4 How to limit git scm poll change path limit:
使用GIT(Github.Gitlab,etc)的web hook的通知,可以让有代码改动时,通知到Jenkins job去自动执行,但是如果想限制某个目录的代码改动才触发Jenkins job,可以同样求助于Additional Behaviours:
5 Git Merge with remote host.
1006 git clone https://jiafu@stash-eng-chn-sjc1 /git/stach.git 1023 git remote add remotename https://jiafu@stash-eng-chn-sjc1/git-fork/stach.git 1034 git fetch remotename /feature/930 1045 git merge remotename /feature/930 1046 git status 1061 git checkout -b gate/20161202 1051 fix conflict 1052 git add/commit 1053 git push remotename gate/20161202
6 保存密码
$ git config --global credential.helper cache
# 默认缓存密码15分钟,可以改得更长, 比如1小时
$ git config --global credential.helper 'cache --timeout=3600'