具体而言,我想知道如何执行命令的'删除未版本化/忽略文件'部分。我想这样做,所以我可以模拟一个干净的结帐自己,我们的存储库很大,全面结账需要一段时间。詹金斯如何“模拟清洁结帐”选项的工作?
2
A
回答
2
不知道Jenkins如何做到这一点,但我认为它使用svn status
来查找未受版本控制/忽略的文件。
这里的2个PowerShell脚本我用它来做到这一点:
#remove_ignored.ps1 (only removes ignored files, leaves unversioned)
param([switch] $WhatIf)
# Find all items with the status of I in svn
# Strip the leading status code and whitespace
# Grab the item for said path (either FileInfo or DirectoryInfo)
$paths = (svn status --no-ignore | Where-Object {$_.StartsWith('I')} | ForEach-Object {$_.SubString(8)} | ForEach-Object {Get-Item -Force $_})
$paths | ForEach-Object {
if (-not $WhatIf) {
# Check if the path still exists, in case it was a nested directory or something strange like that
if ($_.Exists) {
# If its a directory info, tell it to perform a recursive delete
if ($_ -is [System.IO.DirectoryInfo]) { $_.Delete($true) }
else { $_.Delete() }
}
}
Write-Host "Deleted $_"
}
#remove_unversioned.ps1 (removes both ignored and unversioned files)
param([switch] $WhatIf)
# Find all items with the status of I or ? in svn
# Strip the leading status code and whitespace
# Grab the item for said path (either FileInfo or DirectoryInfo)
$paths = (svn status --no-ignore | Where-Object {$_.StartsWith('I') -or $_.StartsWith('?')} | ForEach-Object {$_.SubString(8)} | ForEach-Object {Get-Item -Force $_})
$paths | ForEach-Object {
if (-not $WhatIf) {
# Check if the path still exists, in case it was a nested directory or something strange like that
if ($_.Exists) {
# If its a directory info, tell it to perform a recursive delete
if ($_ -is [System.IO.DirectoryInfo]) { $_.Delete($true) }
else { $_.Delete() }
}
}
Write-Host "Deleted $_"
}
2
这个选项在UpdateWithCleanUpdater
实现。从source,
@Override
protected void preUpdate(ModuleLocation module, File local) throws SVNException, IOException {
listener.getLogger().println("Cleaning up " + local);
clientManager.getStatusClient().doStatus(local, null, SVNDepth.INFINITY, false, false, true, false, new ISVNStatusHandler() {
public void handleStatus(SVNStatus status) throws SVNException {
SVNStatusType s = status.getCombinedNodeAndContentsStatus();
if (s == SVNStatusType.STATUS_UNVERSIONED || s == SVNStatusType.STATUS_IGNORED || s == SVNStatusType.STATUS_MODIFIED) {
listener.getLogger().println("Deleting "+status.getFile());
try {
File f = status.getFile();
if (f.isDirectory())
hudson.Util.deleteRecursive(f);
else
f.delete();
} catch (IOException e) {
throw new SVNException(SVNErrorMessage.create(SVNErrorCode.UNKNOWN, e));
}
}
}
}, null);
}
貌似代码使用SVNKit获取SVN状态,然后删除所有未版本控制,忽略,和修改文件和目录。
令我感到惊讶的是,修改后的文件被删除而不是被还原,但它们会通过SVN更新被拉回来。
相关问题
- 1. 清洁詹金斯工作区
- 2. 有条件的svn结帐投票詹金斯工作
- 3. 从詹金斯工作
- 4. 多詹金斯工作区
- 5. 詹金斯:gitlabCommitStatus不工作
- 6. 詹金斯插件如何工作
- 7. 詹金斯挂断:请等待詹金斯准备工作
- 8. Android模拟器在詹金斯
- 9. Android模拟器插件在詹金斯
- 10. 多选择值选项詹金斯
- 11. 如何詹金斯
- 12. 如何詹金斯
- 13. 詹金斯作业Windows PowerShell脚本$ lastexitcode没有失败的詹金斯工作
- 14. 詹金斯2.0 pipline的println不工作
- 15. 詹金斯的工作失踪
- 16. 显示詹金斯的工作输出
- 17. 失败的詹金斯工作
- 18. 詹金斯工作的SBT不断OutOfMemory
- 19. 多配置詹金斯的工作
- 20. 詹金斯奴隶不工作mesos
- 21. 詹金斯2.0管道和工作DSL
- 22. 在詹金斯安排周末工作
- 23. 获得从詹金斯工作
- 24. 推标签与詹金斯工作DSL
- 25. 詹金斯管道工作条件
- 26. 詹金斯 - 工件处理
- 27. 如何在詹金斯管道Deployit配置在詹金斯
- 28. 混帐詹金斯和标签一起
- 29. 混帐+詹金斯获取问题
- 30. 詹金斯:服务帐户被锁
完美,谢谢:) – 2011-06-08 13:44:49