您可以通过数据库访问TFS 2017构建定义吗?

时间:2017-05-31 18:19:32

标签: tfs build tfs2017 build-definition

我在一个点上创建了一些TFS 2017构建定义,并且通过对安装和数据库的一些搞乱,我失去了对这些定义的访问权限。它们不会出现在门户网站的任何地方。我也无法恢复和附加与它们相关联的项目集合,尽管我确实有项目集合数据库的实际SQL备份。

那么,有没有办法查询Tfs_Configuration,Tfs_Warehouse或Tfs_projectcollection数据库来检索构建定义信息?

如果没有,我将最终重新创建它们,但只是好奇是否有其他方式。

1 个答案:

答案 0 :(得分:1)

如果定义很简单,建议您重新创建它们,这样不会花费太多时间。

但是如果它们很复杂,你可以在另一个sql实例中恢复备份数据库,查询缺少的构建定义,然后将定义插入当前表 [Tfs_DefaultCollection]。[Build]。[tbl_Definition] < / strong>即可。 (确保在执行此操作之前备份数据库以防万一。)

只需从查询的定义中选择一行并复制(右键单击&gt; 复制在sql server中),您需要执行其他操作来添加&#39; &#39;,为每个值。

然后插入这样的值:

insert into [Tfs_DefaultCollection].[Build].[tbl_Definition] 
values 
('1',   '85',   '17',   '1',    'D4',   '1',    '7',    '0',    '5',    '8',    '1',    '', '$(date:yyyyMMdd)$(rev:.r)',    '1',    '60',   '', '1F739003-44A9-4AB6-B1A2-D3CD2A291588', '2017-04-21 19:53:49.733',  '', '[{"enabled":false,"definition":{"id":"7c555368-ca64-4199-add6-9ebaf0b0137d"},"inputs":{"multipliers":"[]","parallel":"false","continueOnError":"true","additionalFields":"{}"}},{"enabled":false,"definition":{"id":"a9db38f9-9fdc-478c-b0f9-464221e58316"},"inputs":{"workItemType":"106","assignToRequestor":"true","additionalFields":"{}"}},{"enabled":false,"definition":{"id":"57578776-4c22-4526-aeb0-86b6da17ee9c"},"inputs":{"additionalFields":"{}"}}]', '{"properties":{"labelSources":"0","tfvcMapping":"{\"mappings\":[{\"serverPath\":\"$/6553c041-5e50-4ace-bec2-c1dba2b812ca\",\"mappingType\":\"map\",\"localPath\":\"\\\\\"},{\"serverPath\":\"$/6553c041-5e50-4ace-bec2-c1dba2b812ca/Drops\",\"mappingType\":\"cloak\",\"localPath\":\"\\\\\"}]}","cleanOptions":"0"},"id":"$/","type":"TfsVersionControl","name":"6553c041-5e50-4ace-bec2-c1dba2b812ca","url":"http://win-kev0061habi:8080/tfs/DefaultCollection/","defaultBranch":"$/6553c041-5e50-4ace-bec2-c1dba2b812ca","rootFolder":"$/6553c041-5e50-4ace-bec2-c1dba2b812ca","clean":"false","checkoutSubmodules":false}',    '', '[{"enabled":true,"continueOnError":false,"alwaysRun":false,"displayName":"NuGet restore **\\*.sln","timeoutInMinutes":0,"task":{"id":"333b11bd-d341-40d9-afcf-b32d5ce6f23b","versionSpec":"0.*","definitionType":"task"},"inputs":{"solution":"**\\*.sln","nugetConfigPath":"","restoreMode":"restore","noCache":"false","nuGetRestoreArgs":"","verbosity":"-","nuGetVersion":"3.3.0","nuGetPath":""}},{"enabled":true,"continueOnError":false,"alwaysRun":false,"displayName":"Build solution **\\*.sln","timeoutInMinutes":0,"task":{"id":"71a9a2d3-a98a-4caa-96ab-affca411ecda","versionSpec":"1.*","definitionType":"task"},"inputs":{"solution":"**\\*.sln","msbuildArgs":"","platform":"$(BuildPlatform)","configuration":"$(BuildConfiguration)","clean":"false","vsVersion":"15.0","maximumCpuCount":"false","restoreNugetPackages":"false","msbuildArchitecture":"x86","logProjectEvents":"true","createLogFile":"false"}},{"enabled":true,"continueOnError":false,"alwaysRun":false,"displayName":"Test Assemblies **\\$(BuildConfiguration)\\*test*.dll;-:**\\obj\\**","timeoutInMinutes":0,"task":{"id":"ef087383-ee5e-42c7-9a53-ab56c98420f9","versionSpec":"1.*","definitionType":"task"},"inputs":{"testAssembly":"**\\$(BuildConfiguration)\\*test*.dll;-:**\\obj\\**","testFiltercriteria":"","runSettingsFile":"","overrideTestrunParameters":"","codeCoverageEnabled":"false","runInParallel":"false","vstestLocationMethod":"version","vsTestVersion":"14.0","vstestLocation":"","pathtoCustomTestAdapters":"","otherConsoleOptions":"","testRunTitle":"","platform":"$(BuildPlatform)","configuration":"$(BuildConfiguration)","publishRunAttachments":"true"}},{"enabled":true,"continueOnError":true,"alwaysRun":false,"displayName":"Publish symbols path: ","timeoutInMinutes":0,"task":{"id":"0675668a-7bba-4ccb-901d-5ad6554ca653","versionSpec":"1.*","definitionType":"task"},"inputs":{"SymbolsPath":"","SearchPattern":"**\\bin\\**\\*.pdb","SymbolsFolder":"","SkipIndexing":"false","TreatNotIndexedAsWarning":"false","SymbolsMaximumWaitTime":"","SymbolsProduct":"","SymbolsVersion":"","SymbolsArtifactName":"Symbols_$(BuildConfiguration)"}},{"enabled":true,"continueOnError":false,"alwaysRun":true,"displayName":"Copy Files to: $(build.artifactstagingdirectory)","timeoutInMinutes":0,"task":{"id":"5bfb729a-a7c8-4a78-a7c3-8d717bb7c13c","versionSpec":"2.*","definitionType":"task"},"inputs":{"SourceFolder":"$(build.sourcesdirectory)","Contents":"**\\bin\\$(BuildConfiguration)\\**","TargetFolder":"$(build.artifactstagingdirectory)","CleanTargetFolder":"false","OverWrite":"false","flattenFolders":"false"}},{"enabled":true,"continueOnError":false,"alwaysRun":true,"displayName":"Publish Artifact: drop","timeoutInMinutes":0,"task":{"id":"2ff763a7-ce83-4e1f-bc89-0ae63477cebe","versionSpec":"1.*","definitionType":"task"},"inputs":{"PathtoPublish":"$(build.artifactstagingdirectory)","ArtifactName":"drop","ArtifactType":"Container","TargetPath":"\\\\my\\share\\$(Build.DefinitionName)\\$(Build.BuildNumber)"}}]',   '{"system.debug":{"value":"false","allowOverride":true},"BuildConfiguration":{"value":"release","allowOverride":true},"BuildPlatform":{"value":"any cpu","allowOverride":true}}',   '', '[{"branches":["+refs/heads/*"],"artifacts":[],"artifactTypesToDelete":["FilePath","SymbolStore"],"daysToKeep":10,"minimumToKeep":1,"deleteBuildRecord":true,"deleteTestResults":true}]',   '0',    '0',    '1',    '')

如果你需要做很多定义,你也可以尝试合并数据库,详情请参考以下链接: http://byalexblog.net/merge-sql-databases