这个问题需要写一下,怕以后忘了。
Jenkin最近在Sonar集成上出错了,信息大概是说”同时有几个Snapshot“。Snapshot就是质量快照,应该是每次Build产生一个,保存在Sonar的数据库里,然后用于Sonar的分析。
在尝试了自己手动删除Snapshot不行之后,在网上(Here)找到解决的办法。这个错误的原因是Sonar不支持对同一个项目同时进行Sonar分析,应该属于某种并发的问题。
解决方法就是执行一段SQL语句:
MySQL
1 |
update snapshots old_snap, snapshots new_snap set old_snap.islast=0 where old_snap.islast=1 and new_snap.created_at > old_snap.created_at and new_snap.project_id = old_snap.project_id and new_snap.islast=1 |
Oracle
1 |
update sonar.snapshots old_snap set old_snap.islast=0 where islast=1 and exists(select * from sonar.snapshots new_snap where new_snap.created_at > old_snap.created_at and new_snap.project_id = old_snap.project_id and new_snap.islast=1) |
PostgreSql
1 |
update snapshots old_snap set islast=false where islast=true and exists(select * from snapshots new_snap where new_snap.created_at > old_snap.created_at and new_snap.project_id = old_snap.project_id and new_snap.islast=true) |
搞定了!Cheers!