several practices relate with git

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不了代码:

08:36:53 ERROR: Timeout after 10 minutes

所以要求助git jenkins插件的”Additional Behaviours“修改下timeout的时间以解决timeout问题:

1111111111nfig [Jenkins] - Google Chrome

3 How to download sub folder for GIT in jenkins:

当一个repository太大时,N个JOB如果没有共享workspace,则占用磁盘的空间为N*repo大小,而实际中,我们确实只需要git里面的某一个子目录而已,所以可以使用sparse checkout来解决,同样求助于Additional Behaviours来设置:

2222222222222

 

4  How to limit git scm poll change path limit:

使用GIT(Github.Gitlab,etc)的web hook的通知,可以让有代码改动时,通知到Jenkins job去自动执行,但是如果想限制某个目录的代码改动才触发Jenkins job,可以同样求助于Additional Behaviours:

hi

 

 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'

Open source: xcov

Project :    https://code.google.com/p/xcov/

Short introduce:   enhance lcov-to-cobertura-xml to support converting gcov to coberuta and working with svn diff

Open source project lcov-to-cobertura-xml provide converting the lcov data to cobertura xml so that it can be easier integrated with Jenkins.

Thus, we have to handle the gcov data at first instead of lcov sometimes, What’s more, we only want to generate code coverage with svn code diff. So this tool enhance the lcov-to-cobertura-xml to support convert gcov data or work with svn diff file base on keeping the old features available.

Basic Usage:

Converts LCOV coverage data to Coberturacompatible XML for reporting. By default, XML output will be written to ./coverage.xml

xcov.py lcovfile.info
xcov.py lcov-file-1.info lcov-file-2.info
xcov.py lcov-file.info -s svndiffFilePath
xcov.py lcovfile.info -a srcPath:gcdaPath
xcov.py -a srcPath:gcdaPath
xcov.py lcovfile.info b src/dir e test.lib o path/out.xml

Options:

-h, –help show this help message and exit -b BASE_DIR, –base-dir=BASE_DIR

Directory where source files are located

-e EXCLUDES, –excludes=EXCLUDES

Comma-separated list of regexes of packages to exclude

-a SRCDSTPAIRS, –srcdstPairs=SRCDSTPAIRS

add src:dst path, the src path is source code path, the dst path is gcda/gcno path

-o OUTPUT, –output=OUTPUT

Path to store cobertura xml file

-w, –web

create html report

-d, –delete

delete the copied gcov data

-s, –svndiff

Path to store svn diff file path

By default

(1) gcdaPath=gcnoPath=objsPath

(2) XML output will be written to ./coverage.xml

(3) svndiffFilePath can be generated by svn diff command with option –summarize such as: svn diff -r {2014-05-01}:{2014-05-10} src/ –summarize > svndifffile.txt