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

Jenkins’ remote build methods

某些场景下,我们需要远程执行一个job, 例如和其他工具做集成时,符合某个条件之时立即触发job。涉及远程执行的帮助文档可以随意寻找一个job的url然后加上/api(例如http://[jenkins dns]/job/jobName/api)来获取帮助,按照是否启动security可以划分为两类情况:

1 未启动security

直接发Post请求    POST  http://[jenkins dns]/job/jobName/build

可使用工具curl来执行POST:

curl -X POST http://[jenkins dns]/job/jobName/build

2 启动security

2.1   不带用户名:令牌方式

(1)  在Build Trigger设置授权Token:例如设置为1234567890

111_2

(2) 使用POST请求  POST  http://[jenkins dns]/job/jobName/build?token=1234567890

 

 2.2  带用户名:curl等工具方式:

上面的方式无法看到是具体哪个用户执行的build, 所以可以采用curl的方式执行(类似的工具还有wget,但是本文未尝试),不过缺点是curl不定在每个操作系统上都配备(Windows默认没有)

加上用户名和密码使用方式如下:

curl -X POST http://username:password@ci.jenkins.com/job/jobName/build

执行之后可以看到由具体用户start.
Started by user jiafu
[EnvInject] - Loading node environment variables.
Building remotely on TA-Win7-64-07 in workspace c:/autotest/workspace/jobName
Finished: SUCCESS
2.3  带用户名:代码方式

可参考:https://wiki.jenkins-ci.org/display/JENKINS/Authenticating+scripted+clients

 

远程执行还有很多其他特性,比如设置过多久之后的delay,带参数等等,本文不一一列举。