小赖子的英国生活和资讯

在CI编译服务器上画出每个开发者的提交次数

阅读 桌面完整版

如果你是项目经理 或者是HR, 你一定想了解每个程序员的活动情况. 比如 哪个季节月份请假的人比较多 而或哪些人平时比较积极 哪些人比较偷懒等. 我们可以根据SVN提交的记录来画出每次时间点上 每个开发者的提交次数.

通过以下命令能获得SVN历史提交记录, 生成XML输出并且通过 GREP命令筛选出只含提交者的名字 (去掉多余的标记)

1
svn log -v --xml | grep "author.*/author"
svn log -v --xml | grep "author.*/author"

使用POWERSHELL编译脚本中的DICTIONARY对象 统计每个程序员的提交次数 然后分别写入文件中. 再通过JENKINS的PLOT插件画出来即可.

<#
.DESCRIPTION
Count SVN Commits
#>

Task SVNLog {    
    Set-Location "$WorkingCopyDir"
    $log = &svn log -v --xml | grep "author.*/author"
    $dict = @{}
    $logarr = $log -replace "<author>", "" -replace "</author>", " ".Trim().Split(" ") | ForEach-Object {
        $author = $_.Trim()
        if ($author.Length -gt 2) {
            if ($dict.ContainsKey($author)) {
                $cur = $dict[$author]
                $dict[$author] = $cur + 1
            } else {
                $dict[$author] = 1
            }
        }
    }
    Write-Host "***********************************Commits Statistics************************************"    
    $dict.GetEnumerator() | Sort-Object Value -descending

    $total = 0

    foreach ($author in $dict.GetEnumerator()) {
        if ($author.Key -ne $null -and $author.Value -ne $null) {
            $file = $author.Key + ".svn.txt"
            Write-Host $file
            $filename = Join-Path "$SolutionDir" "$file"
            Write-Host $filename
            $total = $total + [convert]::ToInt32($author.Value, 10)
            Write-Host "$total"
            WritePropertyFile $filename $author.Value.ToString() "https://helloacm.com"
            Write-Host "$filename has been written." 
        }
    }

    Write-Host "******TOTAL SVN COMMITS = $total ***********************"
    $filename = Join-Path "$SolutionDir" "svn.total.txt"
    WritePropertyFile $filename $total.ToString() "https://helloacm.com"
    Write-Host "$filename has been written." 
}

画出来大概长这样子:

svn-plot-ci-server

英文: https://helloacm.com/how-to-plot-svn-commits-statistics-per-developer-along-builds-at-jenkins-continuous-integration-build-server/

强烈推荐

微信公众号: 小赖子的英国生活和资讯 JustYYUK

阅读 桌面完整版
Exit mobile version