Skip to content

Commit

Permalink
Migrate to "Use .NET Core 2.*" task and introduce parameters with val…
Browse files Browse the repository at this point in the history
…idation (#1227)
  • Loading branch information
tomkerkhove authored Aug 19, 2020
1 parent c4896ea commit cb4bc2f
Show file tree
Hide file tree
Showing 13 changed files with 100 additions and 146 deletions.
5 changes: 3 additions & 2 deletions build/azure-devops/agents-ci-discovery.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ stages:
vmImage: ubuntu-16.04
steps:
- ${{ if eq(variables['Build.Reason'], 'PullRequest') }}:
- template: templates/utils/determine-pr-version.yml
- template: templates/versioning/determine-pr-version.yml
- template: templates/utils/persist-variable.yml
parameters:
currentVariableName: 'Build.BuildNumber'
Expand Down Expand Up @@ -172,7 +172,7 @@ stages:
parameters:
variableName: 'Image.Tag'
- ${{ if eq(variables['Build.Reason'], 'PullRequest') }}:
- template: templates/utils/determine-pr-version.yml
- template: templates/versioning/determine-pr-version.yml
- template: templates/agents/prepare-discovery-ci-config.yml
- ${{ if not(eq(variables['Build.Reason'], 'PullRequest')) }}:
- template: templates/build-discovery-image.yml
Expand Down Expand Up @@ -200,6 +200,7 @@ stages:
- template: ./templates/docker/show-running-containers.yml
- template: templates/tests/run-integration-tests.yml
parameters:
agentName: 'Resource Discovery'
dotnetVersion: '$(DotNet.Sdk.Version)'
buildConfiguration: '$(DotNet.Configuration)'
- template: templates/docker/show-container-logs.yml
Expand Down
4 changes: 2 additions & 2 deletions build/azure-devops/agents-ci-scraper.yml
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ stages:
vmImage: ubuntu-16.04
steps:
- ${{ if eq(variables['Build.Reason'], 'PullRequest') }}:
- template: templates/utils/determine-pr-version.yml
- template: templates/versioning/determine-pr-version.yml
- template: templates/utils/persist-variable.yml
parameters:
currentVariableName: 'Build.BuildNumber'
Expand Down Expand Up @@ -209,7 +209,7 @@ stages:
parameters:
variableName: 'Image.Tag'
- ${{ if eq(variables['Build.Reason'], 'PullRequest') }}:
- template: templates/utils/determine-pr-version.yml
- template: templates/versioning/determine-pr-version.yml
- ${{ if not(eq(variables['Build.Reason'], 'PullRequest')) }}:
- template: templates/build-scraper-image.yml
parameters:
Expand Down
30 changes: 8 additions & 22 deletions build/azure-devops/agents-scraper-release-official.yml
Original file line number Diff line number Diff line change
Expand Up @@ -51,13 +51,7 @@ stages:
pool:
vmImage: ubuntu-16.04
steps:
- powershell: |
Write-Host "Determining '{major}.{minor}' for '$(Image.Version)'"
$index = "$(Image.Version)".IndexOf(".", 2);
$majorMinorVersion = "$(Image.Version)".Substring(0, $index);
Write-Host "Found version '$majorMinorVersion'"
Write-Output ("##vso[task.setvariable variable=Image.MajorMinorVersion;]$majorMinorVersion")
displayName: 'Determine ''{major}.{minor}'' version'
- template: templates/versioning/determine-major-minor-version.yml
- template: templates/utils/persist-variable.yml
parameters:
currentVariableName: 'Image.MajorMinorVersion'
Expand Down Expand Up @@ -104,10 +98,9 @@ stages:
- template: templates/utils/read-variable-on-linux.yml
parameters:
variableName: 'Image.MajorMinorVersion'
- task: DotNetCoreInstaller@0
displayName: 'Install .NET SDK'
inputs:
version: '$(DotNet.SDK.Version)'
- template: templates/build/install-sdk.yml
parameters:
dotnetVersion: '$(DotNet.SDK.Version)'
- task: DotNetCoreCLI@2
displayName: 'Run Unit Tests'
inputs:
Expand Down Expand Up @@ -192,17 +185,10 @@ stages:
variables:
OS.Name: 'windows'
steps:
- powershell: |
Write-Host "Determining '{major}.{minor}' for '$(Image.Version)'"
$index = "$(Image.Version)".IndexOf(".", 2);
$majorMinorVersion = "$(Image.Version)".Substring(0, $index);
Write-Host "Found version '$majorMinorVersion'"
Write-Output ("##vso[task.setvariable variable=Image.MajorMinorVersion;]$majorMinorVersion")
displayName: 'Determine ''{major}.{minor}'' version'
- task: DotNetCoreInstaller@0
displayName: 'Install .NET SDK'
inputs:
version: '$(DotNet.SDK.Version)'
- template: templates/versioning/determine-major-minor-version.yml
- template: templates/build/install-sdk.yml
parameters:
dotnetVersion: '$(DotNet.SDK.Version)'
- task: DotNetCoreCLI@2
displayName: 'Run Unit Tests'
inputs:
Expand Down
17 changes: 13 additions & 4 deletions build/azure-devops/templates/build-discovery-image.yml
Original file line number Diff line number Diff line change
@@ -1,8 +1,17 @@
parameters:
imageName: ''
buildArgs: ''
tags: '--tag promitor-agent-discovery-ci'
os: ''
- name: imageName
type: string
- name: dockerFile
type: string
default: './src/Promitor.Agents.ResourceDiscovery/Dockerfile.linux'
- name: buildArgs
type: string
default: ''
- name: tags
type: string
default: '--tag promitor-agent-discovery-ci'
- name: os
type: string

steps:
- template: docker/build-image.yml
Expand Down
17 changes: 13 additions & 4 deletions build/azure-devops/templates/build-scraper-image.yml
Original file line number Diff line number Diff line change
@@ -1,8 +1,17 @@
parameters:
imageName: ''
buildArgs: ''
tags: '--tag promitor-agent-scraper-ci'
os: ''
- name: imageName
type: string
- name: dockerFile
type: string
default: './src/Promitor.Agents.Scraper/Dockerfile.linux'
- name: buildArgs
type: string
default: ''
- name: tags
type: string
default: '--tag promitor-agent-scraper-ci'
- name: os
type: string

steps:
- template: docker/build-image.yml
Expand Down
37 changes: 9 additions & 28 deletions build/azure-devops/templates/build/build-solution.yml
Original file line number Diff line number Diff line change
@@ -1,34 +1,15 @@
parameters:
dotnetVersion: ''
buildConfiguration: ''
targetFolder: ''
- name: dotnetVersion
type: string
- name: buildConfiguration
type: string
- name: targetFolder
type: string

steps:
- bash: |
echo "Variable 'dotnetVersion' found with value '$DOTNET_VERSION'"
if [ -z "$DOTNET_VERSION" ]; then
echo "##vso[task.logissue type=error;]Missing template parameter \"dotnetVersion\""
echo "##vso[task.complete result=Failed;]"
fi
echo "Variable 'buildConfiguration' found with value '$BUILD_CONFIG'"
if [ -z "$BUILD_CONFIG" ]; then
echo "##vso[task.logissue type=error;]Missing template parameter \"buildConfiguration\""
echo "##vso[task.complete result=Failed;]"
fi
echo "Variable 'targetFolder' found with value '$TARGET_FOLDER'"
if [ -z "$TARGET_FOLDER" ]; then
echo "##vso[task.logissue type=error;]Missing template parameter \"targetFolder\""
echo "##vso[task.complete result=Failed;]"
fi
env:
DOTNET_VERSION: ${{ parameters.dotnetVersion }}
BUILD_CONFIG: ${{ parameters.buildConfiguration }}
TARGET_FOLDER: ${{ parameters.targetFolder }}
displayName: Check for required parameters in YAML template
- task: DotNetCoreInstaller@0
displayName: 'Install .NET SDK'
inputs:
version: '${{ parameters.dotnetVersion }}'
- template: install-sdk.yml
parameters:
dotnetVersion: '${{ parameters.dotnetVersion }}'
- task: DotNetCoreCLI@2
displayName: 'dotnet build'
inputs:
Expand Down
10 changes: 10 additions & 0 deletions build/azure-devops/templates/build/install-sdk.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
parameters:
- name: dotnetVersion
type: string

steps:
- task: UseDotNet@2
displayName: 'Install .Net Core SDK (${{ parameters.dotnetVersion }})'
inputs:
packageType: 'sdk'
version: '${{ parameters.dotnetVersion }}'
38 changes: 12 additions & 26 deletions build/azure-devops/templates/docker/build-image.yml
Original file line number Diff line number Diff line change
@@ -1,32 +1,18 @@
parameters:
imageName: ''
dockerFile: './src/Promitor.Agents.Scraper/Dockerfile'
buildArgs: ''
tags: '--tag promitor-agent-scraper-ci'
os: ''
- name: imageName
type: string
- name: dockerFile
type: string
- name: buildArgs
type: string
default: ''
- name: tags
type: string
default: '--tag promitor-agent-scraper-ci'
- name: os
type: string

steps:
- bash: |
echo "Variable 'imageName' found with value '$IMAGE_NAME'"
if [ -z "$IMAGE_NAME" ]; then
echo "##vso[task.logissue type=error;]Missing template parameter \"imageName\""
echo "##vso[task.complete result=Failed;]"
fi
echo "Variable 'dockerFile' found with value '$DOCKER_FILE'"
if [ -z "$DOCKER_FILE" ]; then
echo "##vso[task.logissue type=error;]Missing template parameter \"dockerFile\""
echo "##vso[task.complete result=Failed;]"
fi
echo "Variable 'os' found with value '$OS'"
if [ -z "$OS" ]; then
echo "##vso[task.logissue type=error;]Missing template parameter \"os\""
echo "##vso[task.complete result=Failed;]"
fi
env:
IMAGE_NAME: ${{ parameters.imageName }}
DOCKER_FILE: ${{ parameters.dockerFile }}
OS: ${{ parameters.os }}
displayName: Check for required parameters in YAML template
- task: Docker@1
displayName: 'Build ${{ parameters.imageName }} image (${{ parameters.os }})'
inputs:
Expand Down
17 changes: 5 additions & 12 deletions build/azure-devops/templates/quality/run-code-quality.yml
Original file line number Diff line number Diff line change
@@ -1,19 +1,12 @@
parameters:
dotnetVersion: ''
- name: dotnetVersion
type: string

steps:
- bash: |
echo "Variable 'dotnetVersion' found with value '$DOTNET_VERSION'"
if [ -z "$DOTNET_VERSION" ]; then
echo "##vso[task.logissue type=error;]Missing template parameter \"dotnetVersion\""
echo "##vso[task.complete result=Failed;]"
fi
env:
DOTNET_VERSION: ${{ parameters.dotnetVersion }}
displayName: Check for required parameters in YAML template
- task: DotNetCoreInstaller@0
displayName: 'Import .Net Core Sdk (${{ parameters.dotnetVersion }})'
- task: UseDotNet@2
displayName: 'Install .Net Core Sdk (${{ parameters.dotnetVersion }})'
inputs:
packageType: 'sdk'
version: '${{ parameters.dotnetVersion }}'
- task: DotNetCoreCLI@2
displayName: 'Restore NuGet Packages'
Expand Down
37 changes: 10 additions & 27 deletions build/azure-devops/templates/tests/run-integration-tests.yml
Original file line number Diff line number Diff line change
@@ -1,36 +1,19 @@
parameters:
agentName: ''
dotnetVersion: ''
buildConfiguration: ''
- name: agentName
type: string
- name: dotnetVersion
type: string
- name: buildConfiguration
type: string

steps:
- bash: |
echo "Variable 'agentName' found with value '$AGENT_NAME'"
if [ -z "$AGENT_NAME" ]; then
echo "##vso[task.logissue type=error;]Missing template parameter \"agentName\""
echo "##vso[task.complete result=Failed;]"
fi
echo "Variable 'dotnetVersion' found with value '$DOTNET_VERSION'"
if [ -z "$DOTNET_VERSION" ]; then
echo "##vso[task.logissue type=error;]Missing template parameter \"dotnetVersion\""
echo "##vso[task.complete result=Failed;]"
fi
echo "Variable 'buildConfiguration' found with value '$BUILD_CONFIG'"
if [ -z "$BUILD_CONFIG" ]; then
echo "##vso[task.logissue type=error;]Missing template parameter \"buildConfiguration\""
echo "##vso[task.complete result=Failed;]"
fi
env:
AGENT_NAME: ${{ parameters.agentName }}
DOTNET_VERSION: ${{ parameters.dotnetVersion }}
BUILD_CONFIG: ${{ parameters.buildConfiguration }}
displayName: Check for required parameters in YAML template
- task: DotNetCoreInstaller@0
displayName: 'Import .Net Core Sdk (${{ parameters.dotnetVersion }})'
- task: UseDotNet@2
displayName: 'Install .Net Core Sdk (${{ parameters.dotnetVersion }})'
inputs:
packageType: 'sdk'
version: '${{ parameters.dotnetVersion }}'
- task: replacetokens@3
displayName: Replace Tokens in Integration Test Configuration
displayName: Replace Tokens in Integration Test Configuration (${{ parameters.agentName }} Agent)
inputs:
rootDirectory: './src'
targetFiles: '**/appsettings.json'
Expand Down
26 changes: 7 additions & 19 deletions build/azure-devops/templates/tests/run-unit-tests.yml
Original file line number Diff line number Diff line change
@@ -1,26 +1,14 @@
parameters:
dotnetVersion: ''
buildConfiguration: ''
- name: dotnetVersion
type: string
- name: buildConfiguration
type: string

steps:
- bash: |
echo "Variable 'dotnetVersion' found with value '$DOTNET_VERSION'"
if [ -z "$DOTNET_VERSION" ]; then
echo "##vso[task.logissue type=error;]Missing template parameter \"dotnetVersion\""
echo "##vso[task.complete result=Failed;]"
fi
echo "Variable 'buildConfiguration' found with value '$BUILD_CONFIG'"
if [ -z "$BUILD_CONFIG" ]; then
echo "##vso[task.logissue type=error;]Missing template parameter \"buildConfiguration\""
echo "##vso[task.complete result=Failed;]"
fi
env:
DOTNET_VERSION: ${{ parameters.dotnetVersion }}
BUILD_CONFIG: ${{ parameters.buildConfiguration }}
displayName: Check for required parameters in YAML template
- task: DotNetCoreInstaller@0
displayName: 'Import .Net Core Sdk (${{ parameters.dotnetVersion }})'
- task: UseDotNet@2
displayName: 'Install .Net Core Sdk (${{ parameters.dotnetVersion }})'
inputs:
packageType: 'sdk'
version: '${{ parameters.dotnetVersion }}'
- task: DotNetCoreCLI@2
displayName: 'dotnet test'
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
steps:
- powershell: |
Write-Host "Determining '{major}.{minor}' for '$(Image.Version)'"
$index = "$(Image.Version)".IndexOf(".", 2);
$majorMinorVersion = "$(Image.Version)".Substring(0, $index);
Write-Host "Found version '$majorMinorVersion'"
Write-Output ("##vso[task.setvariable variable=Image.MajorMinorVersion;]$majorMinorVersion")
displayName: 'Determine ''{major}.{minor}'' version'

0 comments on commit cb4bc2f

Please sign in to comment.