5

因此,我们在 Jenkins CI 构建管理器上使用 Gerrit Trigger (2.23.0) 并使用 docker 容器进行实际构建。

最近在我们的一些分支中出现的问题 Gerrit Repo 轮询失败并导致它每次都“检测到更改”,因此尽管没有任何更改,它仍在不断重建。

检查任何受影响作业的 Gerrit Repo 轮询日志会给出以下输出之一:

Started on Feb 1, 2017 3:12:25 PM
Polling SCM changes on aosp-host
[workspace] $ repo init -u http://xxx.xxx.xxx.xxx/git/project/platform/manifest.git -b branch -m branch.xml
Get https://gerrit.googlesource.com/git-repo/clone.bundle
Get https://gerrit.googlesource.com/git-repo
fatal: Not a git repository: '/home/jenkins/workspace/.repo/manifests.git'
fatal: Not a git repository: '/home/jenkins/workspace/.repo/manifests.git'
fatal: cannot obtain manifest http://xxx.xxx.xxx.xxx/git/project/platform/manifest.git
Done. Took 1 min 19 sec
Changes found

或者,如果构建已经在构建(gerrit 在执行 scm 轮询之前等待构建完成

Started on Feb 2, 2017 3:24:15 AM
Polling SCM changes on aosp-host
[workspace] $ repo init -u http://xxx.xxx.xxx.xxx/git/project/platform/manifest.git -b branch -m branch.xml
fatal: cannot make /home/jenkins/workspace/.repo/repo directory: File exists
Done. Took 2 hr 4 min
Changes found

由此故障触发的构建使用相同的命令并且工作正常:

[workspace] $ repo init -u http://xxx.xxx.xxx.xxx/git/project/platform/manifest.git -b branch -m branch.xml

导航到清单目录,我们看到了症状:

jenkins@f052b3453d95:~/workspace/.repo$ ll 
total 32 
drwxr-xr-x 1 jenkins jenkins   180 Dec 20 11:08 ./ 
drwxrwxr-x 1 jenkins jenkins   778 Dec 20 11:07 ../
-rw-r--r-- 1 jenkins jenkins 20087 Dec 20 10:14 .repo_fetchtimes.json 
lrwxrwxrwx 1 jenkins jenkins    20 Dec 20 10:13 manifest.xml -> manifests/branch.xml 
drwxr-xr-x 1 jenkins jenkins     8 Dec 16 17:33 manifests/ 
drwxr-xr-x 1 jenkins jenkins    50 Dec 16 17:33 manifests.git/ 
drwxr-xr-x 1 jenkins jenkins    28 Dec 16 17:43 project-objects/
-rw-r--r-- 1 jenkins jenkins  7756 Dec 20 10:14 project.list 
drwxr-xr-x 1 jenkins jenkins   410 Dec 16 17:46 projects/

lrwxrwxrwx 1 jenkins jenkins    20 Dec 20 10:13 manifest.xml -> manifests/branch.xml

以红色突出显示,因为branch.xml未找到相关联...所以上面的 Gerrit 日志是准确的,它未能init正确。这通过repo status主目录中的 a 得到确认:

jenkins@f052b3453d95:~/workspace$ repo status
Traceback (most recent call last):
  File "/home/jenkins/workspace/.repo/repo/main.py", line 531, in <module>
    _Main(sys.argv[1:])
  File "/home/jenkins/workspace/.repo/repo/main.py", line 507, in _Main
    result = repo._Run(argv) or 0
  File "/home/jenkins/workspace/.repo/repo/main.py", line 180, in _Run
    result = cmd.Execute(copts, cargs)
  File "/home/jenkins/workspace/.repo/repo/subcmds/status.py", line 130, in Execute
    all_projects = self.GetProjects(args)
  File "/home/jenkins/workspace/.repo/repo/command.py", line 140, in GetProjects
    all_projects_list = manifest.projects
  File "/home/jenkins/workspace/.repo/repo/manifest_xml.py", line 350, in projects
    self._Load()
  File "/home/jenkins/workspace/.repo/repo/manifest_xml.py", line 407, in _Load
    self.manifestProject.worktree))
  File "/home/jenkins/workspace/.repo/repo/manifest_xml.py", line 443, in _ParseManifestXml
    root = xml.dom.minidom.parse(path)
  File "/usr/lib/python2.7/xml/dom/minidom.py", line 1918, in parse
    return expatbuilder.parse(file)
  File "/usr/lib/python2.7/xml/dom/expatbuilder.py", line 922, in parse
    fp = open(file, 'rb')
IOError: [Errno 2] No such file or directory: '/home/jenkins/workspace/.repo/manifest.xml'

问题是,repo init -u <url> -m branch.xml通过命令行运行可以正常工作,并产生一个有效的 repo。

任何人都可以为这个问题提供任何见解?

4

0 回答 0