-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
ci: provision environments for pipelines (#75)
- Loading branch information
Showing
5 changed files
with
307 additions
and
115 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,16 @@ | ||
name: $(GITVERSION_FullSemVer) | ||
|
||
trigger: none | ||
|
||
pr: | ||
- master | ||
|
||
pool: | ||
vmImage: 'windows-latest' | ||
vmImage: windows-latest | ||
|
||
stages: | ||
- stage: BuildAndTest | ||
displayName: Build and Test | ||
jobs: | ||
- template: templates/build-and-test-job.yml | ||
- template: templates/build-and-test-stages.yml | ||
parameters: | ||
environmentIdentifier: $[ coalesce(variables['System.PullRequest.PullRequestNumber'], variables['Build.BuildId']) ] | ||
environmentDisplayName: Package Deployer Template - PR | ||
environmentDomainName: pdt-pr |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
# | ||
# New-PowerAppFlowConnection.ps1 | ||
# | ||
[CmdletBinding()] | ||
param ( | ||
[string] | ||
[Parameter(Mandatory = $true)] | ||
$Username, | ||
[securestring] | ||
[Parameter(Mandatory = $true)] | ||
$Password, | ||
[Parameter(Mandatory = $true)] | ||
[string] | ||
$EnvironmentName, | ||
[Parameter(Mandatory = $true)] | ||
[string] | ||
$Region, | ||
[Parameter(Mandatory = $true)] | ||
[string] | ||
$Connector, | ||
[Parameter(Mandatory = $false)] | ||
[hashtable] | ||
$ConnectionParameters = @{}, | ||
[string] | ||
[parameter(Mandatory = $false)] | ||
$DisplayName, | ||
[string] | ||
[Parameter(Mandatory = $false)] | ||
$OutputVariable | ||
) | ||
|
||
$ErrorActionPreference = 'Stop' | ||
|
||
Install-Module -Name Microsoft.PowerApps.Administration.PowerShell -Force -Scope CurrentUser -AllowClobber | ||
|
||
Write-Host "Authenticating as $Username." | ||
Add-PowerAppsAccount -Username $Username -Password $Password | ||
|
||
if (!$ConnectionId) { | ||
$ConnectionId = [Guid]::NewGuid().ToString("N") | ||
} | ||
|
||
$body = @{ | ||
properties = @{ | ||
environment = @{ | ||
name = "$EnvironmentName" | ||
} | ||
connectionParameters = $ConnectionParameters | ||
displayName = $DisplayName | ||
} | ||
} | ||
|
||
Write-Host "Creating $Connector connection with ID $ConnectionId on environment $EnvironmentName with $($ConnectionParameters.connectionString)" | ||
|
||
$result = InvokeApi ` | ||
-Method PUT ` | ||
-Route "https://$Region.api.powerapps.com/providers/Microsoft.PowerApps/apis/$Connector/connections/$($ConnectionId)?api-version=2021-02-01&`$filter=environment eq '$EnvironmentName'" ` | ||
-Body $body ` | ||
-ThrowOnFailure | ||
|
||
Write-Host "Connection $($result.name) created." | ||
|
||
if ($OutputVariable) { | ||
Write-Host "Setting $OutputVariable variable to $($result.name)." | ||
Write-Host "##vso[task.setvariable variable=$OutputVariable]$($result.name)" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,97 +1,116 @@ | ||
jobs: | ||
- job: BuildAndTestJob | ||
displayName: Build and Test | ||
variables: | ||
- name: GitVersion.SemVer | ||
value: '' | ||
- name: solution | ||
value: '**/*.sln' | ||
- name: buildPlatform | ||
value: 'anycpu' | ||
- name: buildConfiguration | ||
value: 'Release' | ||
- group: Cap Dev - CI | ||
steps: | ||
|
||
- task: gitversion/setup@0 | ||
displayName: Install GitVersion | ||
inputs: | ||
versionSpec: '5.x' | ||
|
||
- task: gitversion/execute@0 | ||
displayName: Execute GitVersion | ||
inputs: | ||
useConfigFile: true | ||
configFilePath: '$(Build.SourcesDirectory)\GitVersion.yml' | ||
updateAssemblyInfo: false | ||
|
||
- pwsh: Write-Host "##vso[task.setvariable variable=SemVer;isOutput=true]$(GitVersion.SemVer)" | ||
name: OutputSemVerTask | ||
displayName: Output SemVer | ||
|
||
- task: DotNetCoreCLI@2 | ||
displayName: Restore NuGet packages | ||
inputs: | ||
command: restore | ||
projects: '**/*.csproj' | ||
|
||
- task: SonarCloudPrepare@1 | ||
displayName: Prepare SonarCloud | ||
inputs: | ||
SonarCloud: 'SonarCloud' | ||
organization: 'capgemini-1' | ||
scannerMode: 'MSBuild' | ||
projectKey: 'Capgemini_xrm-packagedeployer' | ||
projectName: 'xrm-packagedeployer' | ||
projectVersion: '$(GitVersion.SemVer)' | ||
extraProperties: | | ||
sonar.exclusions=**\*.css | ||
parameters: | ||
- name: environmentUrl | ||
displayName: Environment URL | ||
type: string | ||
- name: environmentName | ||
displayName: environmentName | ||
type: string | ||
- name: username | ||
displayName: Username | ||
type: string | ||
- name: password | ||
displayName: Password | ||
type: string | ||
|
||
- task: VSBuild@1 | ||
displayName: Build solution | ||
inputs: | ||
solution: '$(solution)' | ||
platform: '$(buildPlatform)' | ||
configuration: '$(buildConfiguration)' | ||
|
||
- task: VSTest@2 | ||
displayName: Run tests | ||
env: | ||
CAPGEMINI_PACKAGE_DEPLOYER_TESTS_URL: $(URL) | ||
CAPGEMINI_PACKAGE_DEPLOYER_TESTS_USERNAME: $(User ADO Integration Username) | ||
CAPGEMINI_PACKAGE_DEPLOYER_TESTS_PASSWORD: $(User ADO Integration Password) | ||
inputs: | ||
codeCoverageEnabled: true | ||
platform: '$(buildPlatform)' | ||
configuration: '$(buildConfiguration)' | ||
testAssemblyVer2: '**\*Tests.dll' | ||
searchFolder: tests | ||
|
||
- task: SonarCloudAnalyze@1 | ||
displayName: Analyse with SonarCloud | ||
|
||
- task: SonarCloudPublish@1 | ||
displayName: Publish SonarCloud results | ||
inputs: | ||
pollingTimeoutSec: '300' | ||
|
||
- task: WhiteSource Bolt@20 | ||
displayName: Detect security and licence issues | ||
inputs: | ||
cwd: '$(Build.SourcesDirectory)' | ||
|
||
- task: DotNetCoreCLI@2 | ||
displayName: Pack NuGet package | ||
inputs: | ||
command: pack | ||
packagesToPack: src\Capgemini.PowerApps.PackageDeployerTemplate\Capgemini.PowerApps.PackageDeployerTemplate.csproj | ||
modifyOutputPath: true | ||
versioningScheme: byEnvVar | ||
versionEnvVar: GitVersion.NuGetVersionV2 | ||
includesymbols: false | ||
buildProperties: Configuration=$(buildConfiguration) | ||
packDirectory: $(Build.ArtifactStagingDirectory)/out | ||
|
||
- publish: $(Build.ArtifactStagingDirectory)/out | ||
displayName: Publish NuGet artifact | ||
artifact: Capgemini.PowerApps.PackageDeployerTemplate | ||
jobs: | ||
- job: BuildAndTestJob | ||
displayName: Build and Test | ||
variables: | ||
- name: GitVersion.SemVer | ||
value: '' | ||
- name: solution | ||
value: '**/*.sln' | ||
- name: buildPlatform | ||
value: 'anycpu' | ||
- name: buildConfiguration | ||
value: 'Release' | ||
steps: | ||
- task: gitversion/setup@0 | ||
displayName: Install GitVersion | ||
inputs: | ||
versionSpec: '5.x' | ||
- task: gitversion/execute@0 | ||
displayName: Execute GitVersion | ||
inputs: | ||
useConfigFile: true | ||
configFilePath: '$(Build.SourcesDirectory)\GitVersion.yml' | ||
updateAssemblyInfo: false | ||
- pwsh: Write-Host "##vso[task.setvariable variable=SemVer;isOutput=true]$(GitVersion.SemVer)" | ||
name: OutputSemVerTask | ||
displayName: Output SemVer | ||
- task: DotNetCoreCLI@2 | ||
displayName: Restore NuGet packages | ||
inputs: | ||
command: restore | ||
projects: '**/*.csproj' | ||
- task: SonarCloudPrepare@1 | ||
displayName: Prepare SonarCloud | ||
inputs: | ||
SonarCloud: 'SonarCloud' | ||
organization: 'capgemini-1' | ||
scannerMode: 'MSBuild' | ||
projectKey: 'Capgemini_xrm-packagedeployer' | ||
projectName: 'xrm-packagedeployer' | ||
projectVersion: '$(GitVersion.SemVer)' | ||
extraProperties: | | ||
sonar.exclusions=**\*.css | ||
- task: VSBuild@1 | ||
displayName: Build solution | ||
inputs: | ||
solution: '$(solution)' | ||
platform: '$(buildPlatform)' | ||
configuration: '$(buildConfiguration)' | ||
- task: PowerShell@2 | ||
displayName: Create Approvals connection | ||
inputs: | ||
filePath: $(Build.SourcesDirectory)\scripts\New-PowerAppFlowConnection.ps1 | ||
arguments: > | ||
-Username ${{ parameters.username }} | ||
-Password (ConvertTo-SecureString -String $env:CONNECTIONOWNER_PASSWORD -AsPlainText -Force) | ||
-EnvironmentName ${{ parameters.environmentName }} | ||
-Region unitedkingdom | ||
-Connector shared_approvals | ||
-ConnectionParameters @{ } | ||
-OutputVariable "TestEnvironment.Connection.Approvals" | ||
targetType: filePath | ||
env: | ||
CONNECTIONOWNER_PASSWORD: ${{ parameters.password }} | ||
- task: VSTest@2 | ||
displayName: Run tests | ||
env: | ||
CAPGEMINI_PACKAGE_DEPLOYER_TESTS_URL: ${{ parameters.environmentUrl }} | ||
CAPGEMINI_PACKAGE_DEPLOYER_TESTS_USERNAME: ${{ parameters.username }} | ||
CAPGEMINI_PACKAGE_DEPLOYER_TESTS_PASSWORD: ${{ parameters.password }} | ||
PACKAGEDEPLOYER_SETTINGS_CONNREF_PDT_SHAREDAPPROVALS_D7DCB: $(TestEnvironment.Connection.Approvals) | ||
PACKAGEDEPLOYER_SETTINGS_ENVVAR_PDT_TESTVARIABLE: Any string | ||
PACKAGEDEPLOYER_SETTINGS_CONNBASEURL_pdt_5Fexample-20api: https://anyurl.com | ||
inputs: | ||
codeCoverageEnabled: true | ||
platform: '$(buildPlatform)' | ||
configuration: '$(buildConfiguration)' | ||
testAssemblyVer2: '**\*Tests.dll' | ||
searchFolder: tests | ||
- task: SonarCloudAnalyze@1 | ||
displayName: Analyse with SonarCloud | ||
- task: SonarCloudPublish@1 | ||
displayName: Publish SonarCloud results | ||
inputs: | ||
pollingTimeoutSec: '300' | ||
- task: WhiteSource Bolt@20 | ||
displayName: Detect security and licence issues | ||
inputs: | ||
cwd: '$(Build.SourcesDirectory)' | ||
- task: DotNetCoreCLI@2 | ||
displayName: Pack NuGet package | ||
inputs: | ||
command: pack | ||
packagesToPack: src\Capgemini.PowerApps.PackageDeployerTemplate\Capgemini.PowerApps.PackageDeployerTemplate.csproj | ||
modifyOutputPath: true | ||
versioningScheme: byEnvVar | ||
versionEnvVar: GitVersion.NuGetVersionV2 | ||
includesymbols: false | ||
buildProperties: Configuration=$(buildConfiguration) | ||
packDirectory: $(Build.ArtifactStagingDirectory)/out | ||
- publish: $(Build.ArtifactStagingDirectory)/out | ||
displayName: Publish NuGet artifact | ||
artifact: Capgemini.PowerApps.PackageDeployerTemplate |
Oops, something went wrong.