用于为Azure数据工厂构建CI/CD的Powershell脚本
我计划使用PowerShell为Azure数据工厂构建持续集成和部署。因此,所有可以使用VST完成的构建和发布过程都必须使用Powershell完成。如果有人可以共享任何链接或powershell脚本,这将非常有用。谢谢如果您的意思是通过PowerShell创建构建/发布定义,您可以通过PowerShell完成,简单代码:用于为Azure数据工厂构建CI/CD的Powershell脚本,powershell,azure,msbuild,azure-devops,Powershell,Azure,Msbuild,Azure Devops,我计划使用PowerShell为Azure数据工厂构建持续集成和部署。因此,所有可以使用VST完成的构建和发布过程都必须使用Powershell完成。如果有人可以共享任何链接或powershell脚本,这将非常有用。谢谢如果您的意思是通过PowerShell创建构建/发布定义,您可以通过PowerShell完成,简单代码: $base64AuthInfo = [Convert]::ToBase64String([Text.Encoding]::ASCII.GetBytes(("{0}:{1}"
$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内容
可以帮助您的博客:
如果您指的是自定义生成/发布任务,那么对于powershell,您可以参考如下更改执行:
"execution": {
"PowerShell3": {
"target": "Hello.ps1",
"argumentFormat": ""
}
}
关于部署azure数据工厂,您可以参考:(无需调用登录AzurerAccount
和选择AzurerSubscription
,只需将azure PowerShell任务添加到构建/发布定义中即可)
第三个扩展:MS为ADFv2提供了一系列cmdlet:您的问题可能很快就被关闭,因为您要求的是资源/方法建议,而不是一个特定的缩小范围的问题。尽量更具体地说明您面临的问题,这样您就更有可能获得帮助。我正在寻找使用Powershell脚本的生成任务。我已经使用VST完成了CI/CD,但需要使用Powershell脚本创建构建和发布活动(CI/CD)。没有足够的链接可供使用。谢谢。我正在寻找第一个选项,其中我需要在单个powershell脚本中执行所有生成和发布任务,该脚本可用于CI/CD。所以我需要创建一个json文件,并在构建中调用该json文件。如果我需要执行其他任务,如nuget还原、复制文件、发布工件,我该如何执行这些..如果我需要在我的专用代理中运行这些..我需要遵循的所有步骤是什么..以及哪种是最佳做法..使用vsts任务或单个powershell脚本进行CI/CD@ArunS只需更新JSON数据,您可以创建一个示例生成/发布定义,然后通过获取详细的JSON数据,然后根据结果更新JSON。对于VSTS任务,您只需要添加到生成/发布定义,但是对于PowerShell任务,您还需要指定另一个脚本文件(或内联脚本)。感谢Chen的输入。你能建议哪一种是CI/CD的最佳实践吗。选项1-使用VSTS任务构建CI&CD。选项2-使用Powershell构建CI&CD。