Git 历史统计信息生成器

如果你是研发效能组的一员或者在从事 CI/CD 或 DevOps,除了提供基础设施,指标和数据是也是一个很重要的一环,比如需要分析下某个 Git 仓库代码提交情况:

  • 这个仓库的代码谁提交的代码最多
  • 这个仓库的活跃度是什么样子的
  • 各个时段的提交分析数据
  • 每个版本的贡献排名
  • 每周/每月/每年的贡献排名等等

几天前发现一个 Git 历史统计信息生成工具叫 GitStats (https://github.com/shenxianpeng/gitstats)

Read More

Black Duck 与 Jenkins 集成

最近做了 Black Duck 与 Jenkins 的集成,目标是给测试和开发提供定制化、定时的对各个开发代码仓库的进行源码扫描。

为什么要做源码扫描

Read More

Docker 常用命令

Docker 常用命令小纸条

Docker start|stop|restart

# 查看 Docker 版本
docker -v # or docker --version
# 重启 docker
sudo systemctl restart docker.service
# 停止 docker
sudo systemctl stop docker.service
# 启动 docker
sudo systemctl start docker.service

Read More

北京48小时:记一次参加 DevOps 训练营

本周二下班我没有像往常一样加会班(我一般都会赶在晚6点后下班来躲过晚高峰期),而是直接挤地铁奔向机场,准备坐八点半去往北京的一班飞机,因为第二天要参加 JFrog 中国在北京望京举办的 Jenkins, Artifactory & Kubernetes 实战训练营。

Read More

Docker 版本概述

Docker 可分为三个版本

  • Docker Engine - Community
  • Docker Engine - Enterprise

Read More

定制一个 Docker 版 Jenkins 镜像

对于如何备份 Jenkins 除了用 Jenkins 插件来定期备份之外,如果把 Jenkins 安装到 Docker 里,定期备份一个 Docker Image 最后传到 Artifactory 中,也是一个不错的方案。

Read More

Artifactory 与 Jenkins 集成

上一篇 初识 JFrog Artifactory,介绍了什么是 Artifactory,以及如何安装、启动和升级。

本篇介绍 Artifactory 与 Jenkins 的集成,因为没有与 CI 工具集成的 Artifactory 是没有灵魂的。

通过集成,可以让 Jenkins 在完成构建之后,可以直接将制品(比如 build)推送到 Artifactory,供测试下载、部署或是后续的 Jenkins 任务去继续进行持续集成。

Read More

初识 JFrog Artifactory

什么是 Artifactory

Artifactory 是 JFrog 的一个产品,用作二进制存储库管理器。二进制存储库可以将所有这些二进制统一托管,从而使团队的管理更加高效和简单。

就跟你用 Git 一样,Git 是用来管理代码的,Artifactory 是用来管理二进制文件的,通常是指 jar, war, pypi, DLL, EXE 等 build 文件。

我觉得使用 Artifactory 的最大优势是创造了更好的持续集成环境,有助于其他持续集成任务去 Artifactory 里调用,再部署到不同的测试或开发环境,这对于实施 DevOps 至关重要。

Read More

Jenkins Console Output 显示彩色

如果想让 Jenkins Console Output 出来一些重要日志醒目的显示,可以让一些日志显示颜色方便查看

  1. 首先需要安装插件: https://wiki.jenkins.io/display/JENKINS/AnsiColor+Plugin

Read More

Jenkins privilege management

如何针对 Jenkins 里的不同 Job 进行不同的策略管理。比如某个 Job 所有人都可以查看,但仅限于某些人可以执行,这时候就需要对 Job 行程权限设置。

这里用的插件是 Role-based Authorization Strategy。安装成功后,打开要设置的 Job, 设置如下:

Read More

如何设置 NFS 共享以及在不同的平台 Windows/Linux/Unix 进行挂载

例如我有一个共享仓库的代码所在用的空间非常大(超过 20 G),在每个产品构建时候都需要用到这个仓库的代码(从里面 copy 第三方库),如果每个人都要 git clone 这个第三方仓库,一是网络开销非常大,二是 git clone 时间长,而且占用大量的物理空间。

这可以通过 NFS 共享来解决。

另外希望这个代码仓库能自动更新,这里引入了 Jenkins。用它来检查如果这个容量巨大的仓库有代码提交就自动执行 git pull 操作,更新最新的代码到共享服务器上。

Read More

解决 Could not read from remote repository 问题

最近我在运行 Jenkins Job 时候突然发现 git clone 代码的时候突然报了这个错误:

$ git clone ssh://git@git.companyname.com:7999/repo/opensrc.git
Cloning into 'opensrc'...
fatal: Could not read from remote repository.

Please make sure you have the correct access rights
and the repository exists.

这个错误只在我刚开始使用 git 的时候遇到过,那时候我还不知道如何使用 ssh 的方式来 clone 代码。怎么会出现这个错误呢?我也没改过什么,非常不理解。

常见解决方案

Read More

Git Commit Squash

If your commits on local not pushed to remote

combine local commits, you could follow this flow

Read More

Jenkins troubleshooting summary

ERROR: Error cloning remote repo ‘origin’ timeout=10

Recently, my Jenkins build failed when execute git clone with following this error message: ERROR: Error cloning remote repo ‘origin’.

  1. first I suspect it is the network reason, maybe because clone from Bitbucket need took up a lot bandwidth during git clone and causing this disconnection. but when I try to git clone on the agent, it works well.
  2. Then I noticed the there is timeout=10 in the Jenkins console log, I suddenly remembered that I deleted a very large folder a few days ago from git repo, and this may cause the repo more bigger, so it may take more time do a complete clone and it exceeds the Jenkins default clone timeout 10.

Googling and finally I found this issue JENKINS-47660 which is the same problem as mine.

Read More

如何通过 Jenkins 进行资源的锁定和释放

业务场景

日常工作中需要切换到不同平台(包括 Linux, AIX, Windows, Solris, HP-UX)不同的版本进行开发和验证问题,但是由于虚拟机有限,并不能保证每个开发和测试都有所以平台的虚拟机并且安装了不同的版本,因此准备各种各样的开发和测试环境会花费很长时间。

Read More