Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Helm chart should always use the correct image tag #1199

Merged
merged 30 commits into from
Sep 1, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
30 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions build/azure-devops/agents-ci-discovery.yml
Original file line number Diff line number Diff line change
Expand Up @@ -142,13 +142,13 @@ stages:
activeDirectoryAppId: '$(Agent.ResourceDiscovery.Auth.AppId)'
activeDirectoryAppSecret: '$(Agent.ResourceDiscovery.Auth.AppSecret)'
os: '$(OS.Name)'
- template: ./templates/docker/show-running-containers.yml
- 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
- template: templates/docker/show-container-logs.yml
parameters:
containerName: '$(Container.Name)'
- ${{ if eq(variables['Build.Reason'], 'PullRequest') }}:
Expand Down Expand Up @@ -197,7 +197,7 @@ stages:
activeDirectoryAppId: '$(Agent.ResourceDiscovery.Auth.AppId)'
activeDirectoryAppSecret: '$(Agent.ResourceDiscovery.Auth.AppSecret)'
os: '$(OS.Name)'
- template: ./templates/docker/show-running-containers.yml
- template: templates/docker/show-running-containers.yml
- template: templates/tests/run-integration-tests.yml
parameters:
agentName: 'Resource Discovery'
Expand Down
79 changes: 33 additions & 46 deletions build/azure-devops/agents-ci-scraper.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,15 @@ pr:
- charts/promitor-agent-scraper/*
variables:
- template: ./variables/build.yml
- template: ./variables/helm.yml
- name: Image.Name
value: 'tomkerkhove/promitor-agent-scraper-ci'
- name: Image.TaggedName
value: '$(Image.Name):$(Tags.PR)'
- name: Helm.Chart.Version
- name: App.Version
value: '0.0.0-$(Image.Tag)'
- name: Helm.Chart.Official.Name
value: 'promitor-agent-scraper'
- name: Helm.Chart.Version
value: '0.0.0-$(App.Version)'
- name: Helm.Chart.CI.Name
value: 'promitor-agent-scraper-ci'
stages:
Expand Down Expand Up @@ -115,8 +116,6 @@ stages:
value: 'ci-network'
- name: Image.ResourceDiscovery.Name
value: 'local/promitor-resource-discovery:dev'
- name: App.Version
value: '0.0.0-$(Image.Tag)'
jobs:
- job: DockerBuildLinux
displayName: Build Docker Image (Linux)
Expand Down Expand Up @@ -153,7 +152,7 @@ stages:
tags: '--tag dev'
buildArgs: 'VERSION="$(App.Version)"'
os: '$(OS.Name)'
- template: ./templates/docker/create-network.yml
- template: templates/docker/create-network.yml
parameters:
networkName: '$(Container.Network.Name)'
- template: templates/agents/run-scraper-image.yml
Expand All @@ -176,16 +175,16 @@ stages:
activeDirectoryAppSecret: '$(Agent.ResourceDiscovery.Auth.AppSecret)'
networkName: '$(Container.Network.Name)'
os: '$(OS.Name)'
- template: ./templates/docker/show-running-containers.yml
- template: templates/docker/show-running-containers.yml
- template: templates/tests/run-integration-tests.yml
parameters:
agentName: 'Scraper'
dotnetVersion: '$(DotNet.Sdk.Version)'
buildConfiguration: '$(DotNet.Configuration)'
- template: ./templates/docker/show-container-logs.yml
- template: templates/docker/show-container-logs.yml
parameters:
containerName: '$(Container.Scraper.Name)'
- template: ./templates/docker/show-container-logs.yml
- template: templates/docker/show-container-logs.yml
parameters:
containerName: '$(Container.ResourceDiscovery.Name)'
- ${{ if eq(variables['Build.Reason'], 'PullRequest') }}:
Expand Down Expand Up @@ -231,7 +230,7 @@ stages:
buildArgs: 'VERSION="$(App.Version)"'
tags: '--tag promitor-agent-scraper-ci'
os: '$(OS.Name)'
- template: ./templates/docker/create-network.yml
- template: templates/docker/create-network.yml
parameters:
networkName: '$(Container.Network.Name)'
driverName: 'nat'
Expand All @@ -255,16 +254,16 @@ stages:
activeDirectoryAppSecret: '$(Agent.ResourceDiscovery.Auth.AppSecret)'
networkName: '$(Container.Network.Name)'
os: '$(OS.Name)'
- template: ./templates/docker/show-running-containers.yml
- template: templates/docker/show-running-containers.yml
- template: templates/tests/run-integration-tests.yml
parameters:
agentName: 'Scraper'
dotnetVersion: '$(DotNet.Sdk.Version)'
buildConfiguration: '$(DotNet.Configuration)'
- template: ./templates/docker/show-container-logs.yml
- template: templates/docker/show-container-logs.yml
parameters:
containerName: '$(Container.Scraper.Name)'
- template: ./templates/docker/show-container-logs.yml
- template: templates/docker/show-container-logs.yml
parameters:
containerName: '$(Container.ResourceDiscovery.Name)'
- ${{ if eq(variables['Build.Reason'], 'PullRequest') }}:
Expand All @@ -283,10 +282,10 @@ stages:
pool:
vmImage: ubuntu-16.04
steps:
- template: ./templates/helm/lint-chart.yml
- template: templates/helm/lint-chart.yml
parameters:
helmVersion: '$(Helm.Version)'
chartName: '$(Helm.Chart.Official.Name)'
chartName: '$(Chart.Scraper.Name)'
- stage: Helm3
displayName: Helm Chart (3.x)
dependsOn: Docker
Expand All @@ -304,36 +303,24 @@ stages:
- template: templates/utils/read-variable-on-linux.yml
parameters:
variableName: 'Image.Tag'
- template: ./templates/helm/lint-chart.yml
- template: templates/helm/lint-chart.yml
parameters:
helmVersion: '$(Helm.Version)'
chartName: '$(Helm.Chart.Official.Name)'
- task: PowerShell@2
displayName: 'Transform Helm Chart in CI Chart'
inputs:
targetType: filePath
filePath: ./build/helm/CI/Transform-Chart.ps1
arguments: '-chartName "$(Helm.Chart.CI.Name)" -imageName "$(Image.Name)" -imageTag "$(Image.Tag)"'
workingDirectory: 'charts'
- task: PowerShell@2
displayName: 'Package Helm Chart'
inputs:
targetType: filePath
filePath: ./build/helm/CI/Package-Chart.ps1
arguments: '-chartName "$(Helm.Chart.CI.Name)" -chartVersion "$(Helm.Chart.Version)"'
workingDirectory: 'charts'
- task: AzureCLI@1
displayName: 'Push Helm Chart to Azure Container Registry'
inputs:
azureSubscription: 'Visual Studio Enterprise (0f9d7fea-99e8-4768-8672-06a28514f77e)'
scriptLocation: inlineScript
inlineScript: |
az configure --defaults acr=promitor
az acr helm push --name promitor charts/output/$(Helm.Chart.CI.Name)-$(Helm.Chart.Version).tgz --force
condition: eq(variables['Build.Reason'], 'PullRequest')
- task: PublishBuildArtifacts@1
displayName: 'Publish Helm Chart'
inputs:
PathtoPublish: charts/output/$(Helm.Chart.CI.Name)-$(Helm.Chart.Version).tgz
ArtifactName: helm
condition: eq(variables['Build.Reason'], 'PullRequest')
chartName: '$(Chart.Scraper.Name)'
- template: templates/helm/package-preview-chart.yml
parameters:
chartName: '$(Helm.Chart.CI.Name)'
chartVersion: '$(Helm.Chart.Version)'
appVersion: '$(App.Version)'
imageName: '$(Image.Name)'
- ${{ if eq(variables['Build.Reason'], 'PullRequest') }}:
- template: templates/helm/push-chart.yml
parameters:
chartName: '$(Helm.Chart.CI.Name)'
chartVersion: '$(Helm.Chart.Version)'
- ${{ if eq(variables['Build.Reason'], 'PullRequest') }}:
- task: PublishBuildArtifacts@1
displayName: 'Publish Helm Chart'
inputs:
PathtoPublish: charts/output/$(Helm.Chart.CI.Name)-$(Helm.Chart.Version).tgz
ArtifactName: helm
58 changes: 36 additions & 22 deletions build/azure-devops/agents-scraper-release-official-helm.yml
Original file line number Diff line number Diff line change
@@ -1,13 +1,28 @@
name: $(Helm.Chart.Version)
resources:
- repo: self

trigger: none
pr: none

parameters:
- name: appVersion
displayName: App Version
type: string
default: 0.1.0
- name: chartVersion
displayName: Helm Chart Version
type: string
default: 0.1.0

variables:
Release.TagName: 'helm-$(Helm.Chart.Version)'
Release.Title: 'Helm v$(Helm.Chart.Version) for Promitor Scraper v$(Helm.App.Version)'
# Helm.App.Version is configured in the build definition as settable at queue time
# Helm.Chart.Version is configured in the build definition as settable at queue time
- name: 'Release.TagName'
value: 'helm-$(Helm.Chart.Version)'
- name: 'Release.Title'
value: 'Helm v$(Helm.Chart.Version) for Promitor Scraper v$(Helm.App.Version)'
- name: 'Helm.App.Version'
value: '${{ parameters.appVersion }}'
- name: 'Helm.Chart.Version'
value: '${{ parameters.chartVersion }}'

stages:
- stage: ReleaseHelm
displayName: Release Helm Chart
Expand All @@ -16,23 +31,22 @@ stages:
displayName: Push Helm Chart to ACR
pool:
vmImage: ubuntu-16.04
variables:
- template: ./variables/helm.yml
steps:
- task: HelmInstaller@0
inputs:
helmVersion: '2.9.1'
- powershell: |
mkdir output/
helm package promitor-agent-scraper/ --app-version $(Helm.App.Version) --version $(Helm.Chart.Version) --destination output/
workingDirectory: charts
displayName: 'Package Helm Chart'
- task: AzureCLI@1
displayName: 'Push Helm Chart to Azure Container Registry'
inputs:
azureSubscription: 'Visual Studio Enterprise (0f9d7fea-99e8-4768-8672-06a28514f77e)'
scriptLocation: inlineScript
inlineScript: |
az configure --defaults acr=promitor
az acr helm push --name promitor charts/output/promitor-agent-scraper-$(Helm.Chart.Version).tgz --force
- template: templates/helm/lint-chart.yml
parameters:
helmVersion: '$(Helm.Version)'
chartName: '$(Chart.Scraper.Name)'
- template: templates/helm/package-official-chart.yml
parameters:
chartName: '$(Chart.Scraper.Name)'
chartVersion: '$(Helm.Chart.Version)'
appVersion: '$(Helm.App.Version)'
- template: templates/helm/push-chart.yml
parameters:
chartName: '$(Chart.Scraper.Name)'
chartVersion: '$(Helm.Chart.Version)'

- stage: ReleaseGitHub
displayName: Release on GitHub
Expand Down
49 changes: 23 additions & 26 deletions build/azure-devops/agents-scraper-release-official.yml
Original file line number Diff line number Diff line change
Expand Up @@ -75,8 +75,6 @@ stages:
value: 'ci-network'
- name: Image.ResourceDiscovery.Name
value: 'local/promitor-resource-discovery:dev'
- name: App.Version
value: '0.0.0-$(Image.Version)'
- name: Agent.Scraper.Version
value: $(App.Version)
- name: Agent.Scraper.BaseUrl
Expand Down Expand Up @@ -118,7 +116,7 @@ stages:
tags: '--tag dev'
buildArgs: 'VERSION="$(App.Version)"'
os: '$(OS.Name)'
- template: ./templates/docker/create-network.yml
- template: templates/docker/create-network.yml
parameters:
networkName: '$(Container.Network.Name)'
- template: templates/agents/run-scraper-image.yml
Expand All @@ -141,16 +139,16 @@ stages:
activeDirectoryAppSecret: '$(Agent.ResourceDiscovery.Auth.AppSecret)'
networkName: '$(Container.Network.Name)'
os: '$(OS.Name)'
- template: ./templates/docker/show-running-containers.yml
- template: templates/docker/show-running-containers.yml
- template: templates/tests/run-integration-tests.yml
parameters:
agentName: 'Scraper'
dotnetVersion: '$(DotNet.Sdk.Version)'
buildConfiguration: '$(DotNet.Configuration)'
- template: ./templates/docker/show-container-logs.yml
- template: templates/docker/show-container-logs.yml
parameters:
containerName: '$(Container.Scraper.Name)'
- template: ./templates/docker/show-container-logs.yml
- template: templates/docker/show-container-logs.yml
parameters:
containerName: '$(Container.ResourceDiscovery.Name)'
- template: templates/docker/push-image.yml
Expand Down Expand Up @@ -208,7 +206,7 @@ stages:
buildArgs: 'VERSION="$(App.Version)"'
tags: '--tag $(Image.Name):$(Image.MajorMinorVersion)-$(OS.Name) --tag $(Image.Name):latest-$(OS.Name)'
os: '$(OS.Name)'
- template: ./templates/docker/create-network.yml
- template: templates/docker/create-network.yml
parameters:
networkName: '$(Container.Network.Name)'
driverName: 'nat'
Expand All @@ -232,16 +230,16 @@ stages:
activeDirectoryAppSecret: '$(Agent.ResourceDiscovery.Auth.AppSecret)'
networkName: '$(Container.Network.Name)'
os: '$(OS.Name)'
- template: ./templates/docker/show-running-containers.yml
- template: templates/docker/show-running-containers.yml
- template: templates/tests/run-integration-tests.yml
parameters:
agentName: 'Scraper'
dotnetVersion: '$(DotNet.Sdk.Version)'
buildConfiguration: '$(DotNet.Configuration)'
- template: ./templates/docker/show-container-logs.yml
- template: templates/docker/show-container-logs.yml
parameters:
containerName: '$(Container.Scraper.Name)'
- template: ./templates/docker/show-container-logs.yml
- template: templates/docker/show-container-logs.yml
parameters:
containerName: '$(Container.ResourceDiscovery.Name)'
- template: templates/docker/push-image.yml
Expand Down Expand Up @@ -360,20 +358,19 @@ stages:
displayName: Push Helm Chart to ACR
pool:
vmImage: ubuntu-16.04
variables:
- template: ./variables/helm.yml
steps:
- task: HelmInstaller@0
inputs:
helmVersion: '2.9.1'
- powershell: |
mkdir output/
helm package promitor-agent-scraper/ --app-version $(Helm.App.Version) --version $(Helm.Chart.Version) --destination output/
workingDirectory: charts
displayName: 'Package Helm Chart'
- task: AzureCLI@1
displayName: 'Push Helm Chart to Azure Container Registry'
inputs:
azureSubscription: 'Visual Studio Enterprise (0f9d7fea-99e8-4768-8672-06a28514f77e)'
scriptLocation: inlineScript
inlineScript: |
az configure --defaults acr=promitor
az acr helm push --name promitor charts/output/promitor-agent-scraper-$(Helm.Chart.Version).tgz --force
- template: templates/helm/lint-chart.yml
parameters:
helmVersion: '$(Helm.Version)'
chartName: '$(Chart.Scraper.Name)'
- template: templates/helm/package-official-chart.yml
parameters:
chartName: '$(Chart.Scraper.Name)'
chartVersion: '$(Helm.Chart.Version)'
appVersion: '$(Helm.App.Version)'
- template: templates/helm/push-chart.yml
parameters:
chartName: '$(Chart.Scraper.Name)'
chartVersion: '$(Helm.Chart.Version)'
22 changes: 5 additions & 17 deletions build/azure-devops/templates/helm/lint-chart.yml
Original file line number Diff line number Diff line change
@@ -1,23 +1,11 @@
parameters:
helmVersion: '3.1.2'
chartName: ''
- name: helmVersion
type: string
default: '$(Helm.Version)'
- name: chartName
type: string

steps:
- bash: |
echo "Variable 'helmVersion' found with value '$HELM_VERSION'"
if [ -z "$HELM_VERSION" ]; then
echo "##vso[task.logissue type=error;]Missing template parameter \"helmVersion\""
echo "##vso[task.complete result=Failed;]"
fi
echo "Variable 'chartName' found with value '$CHART_NAME'"
if [ -z "$CHART_NAME" ]; then
echo "##vso[task.logissue type=error;]Missing template parameter \"chartName\""
echo "##vso[task.complete result=Failed;]"
fi
env:
CHART_NAME: ${{ parameters.chartName }}
HELM_VERSION: ${{ parameters.helmVersion }}
displayName: Check for required parameters in YAML template
- task: HelmInstaller@1
displayName: 'Install Helm (${{ parameters.helmVersion }}'
inputs:
Expand Down
Loading