我计划使用PowerShell为Azure数据工厂构建持续集成和部署。因此,使用VSTS完成的所有构建和发布过程都必须使用Powershell完成。如果任何人都可以共享任何链接或PowerShell脚本,那将会很有帮助。感谢
答案 0 :(得分:0)
如果您的意思是通过PowerShell创建构建/发布定义,则可以使用PowerShell通过VSTS REST完成此操作,简单代码:
$base64AuthInfo = [Convert]::ToBase64String([Text.Encoding]::ASCII.GetBytes(("{0}:{1}" -f "","{personal access token}")))
$body='{
"variables": {
"system.debug": {
"value": "false",
"allowOverride": true
}
},
"retentionRules": [
{
"branches": [
"+refs/heads/*"
],
"artifacts": [],
"artifactTypesToDelete": [
"FilePath",
"SymbolStore"
],
"daysToKeep": 10,
"minimumToKeep": 1,
"deleteBuildRecord": true,
"deleteTestResults": true
}
],
"properties": {},
"tags": [],
"jobAuthorizationScope": "projectCollection",
"jobTimeoutInMinutes": 60,
"jobCancelTimeoutInMinutes": 5,
"process": {
"phases": [
{
"steps": [
{
"environment": {},
"enabled": true,
"continueOnError": false,
"alwaysRun": false,
"displayName": "Azure PowerShell script: FilePath",
"timeoutInMinutes": 0,
"condition": "succeeded()",
"task": {
"id": "72a1931b-effb-4d2e-8fd8-f8472a07cb62",
"versionSpec": "2.*",
"definitionType": "task"
},
"inputs": {
"ConnectedServiceNameSelector": "ConnectedServiceNameARM",
"ConnectedServiceName": "",
"ConnectedServiceNameARM": "aad18bbf-0333-41bf-99ea-674181d17ada",
"ScriptType": "FilePath",
"ScriptPath": "$/Scrum2015/ClassLibraryA/dbtest.ps1",
"Inline": "# You can write your azure powershell scripts inline here. \n# You can also pass predefined and custom variables to this script using arguments",
"ScriptArguments": "",
"TargetAzurePs": "LatestVersion",
"CustomTargetAzurePs": ""
}
}
],
"name": "Phase 1",
"refName": "Phase_1",
"condition": "succeeded()",
"target": {
"executionOptions": {
"type": 0
},
"allowScriptsAuthAccessOption": false,
"type": 1
},
"jobAuthorizationScope": "projectCollection",
"jobCancelTimeoutInMinutes": 1
}
],
"type": 1
},
"repository": {
"properties": {
"cleanOptions": "0",
"tfvcMapping": "{\"mappings\":[{\"serverPath\":\"$/Scrum2015/ClassLibraryA\",\"mappingType\":\"map\",\"localPath\":\"\\\\\"},{\"serverPath\":\"$/Scrum2015/ClassLibraryA/VS2010UltimTrial.iso\",\"mappingType\":\"cloak\",\"localPath\":\"\"},{\"serverPath\":\"$/Scrum2015/ClassLibraryA/tools\",\"mappingType\":\"cloak\",\"localPath\":\"\"}]}",
"labelSources": "0",
"labelSourcesFormat": "$(build.buildNumber)"
},
"id": "$/",
"type": "TfsVersionControl",
"name": "Scrum2015",
"defaultBranch": "$/Scrum2015/ClassLibraryA",
"rootFolder": "$/Scrum2015",
"clean": "false",
"checkoutSubmodules": false
},
"processParameters": {},
"quality": "definition",
"drafts": [],
"queue": {
"id": 179
},
"name": "PowerShellRest2VNext",
"path": "\\",
"type": "build",
"queueStatus": "enabled"
}'
$result = Invoke-RestMethod -Uri $uri -Method Post -ContentType "application/json" -Headers @{Authorization=("Basic {0}" -f $base64AuthInfo)} -Body $body
注意,您可以创建示例构建/发布定义,然后通过VSTS REST API获取它以获取JSON内容。
可以帮助您的博客:VSTS/TFS REST API: The basics and working with builds and releases
如果您的意思是自定义构建/发布任务,您可以参考Add a build or release task,对于powershell,更改执行如下:
"execution": {
"PowerShell3": {
"target": "Hello.ps1",
"argumentFormat": ""
}
}
关于部署azure数据工厂,您可以参考:How to deploy Azure Data Factory pipeline and its dependencies programatically using PowerShell(不需要调用Login-AzureRMAccount
和Select-AzureRMSubscrition
,只需将Azure PowerShell任务添加到构建/发布定义中。 / p>
第三个分机:Azure Data Factory