forked from F5Networks/f5-ipam-controller
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathazure-pipelines.yml
More file actions
95 lines (91 loc) · 3.46 KB
/
azure-pipelines.yml
File metadata and controls
95 lines (91 loc) · 3.46 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
# Starter pipeline
# Start with a minimal pipeline that you can customize to build and deploy your code.
# Add steps that build, run tests, deploy, and more:
# https://aka.ms/yaml
trigger:
branches:
include:
- main
tags:
include:
- v*
pool:
vmImage: 'ubuntu-latest'
variables:
imageName: 'f5networks/f5-ipam-controller-devel'
quayConnection: 'quay-bot'
redhatConnection: 'redhat-bot'
dockerConnection: 'docker-bot'
scanConnection: 'fic-scan-bot'
quay_path: 'quay.io/f5networks/f5-ipam-controller-devel'
redhat_prj_name: 'f5-ipam-controller'
redhat_tag: '$(BUILD_VERSION)-rhel8'
docker_version: '$(BUILD_VERSION)'
docker_repo: 'f5networks/f5-ipam-controller'
steps:
- task: CmdLine@2
displayName: Check Go format and Suspicious constructs
inputs:
script: 'make verify'
- task: Docker@2
displayName: Login to redhat registry
inputs:
command: login
containerRegistry: $(redhatConnection)
- task: Docker@2
displayName: Login to quay registry
inputs:
command: login
containerRegistry: $(quayConnection)
- task: Docker@2
displayName: Login to docker registry
condition: startsWith(variables['build.sourceBranch'], 'refs/tags/')
inputs:
command: login
containerRegistry: $(dockerConnection)
- task: Docker@2
displayName: Login to scan registry
condition: startsWith(variables['build.sourceBranch'], 'refs/tags/')
inputs:
command: login
containerRegistry: $(scanConnection)
- task: Docker@2
displayName: Build from Red Hat Universal Base Image
inputs:
command: build
containerRegistry: $(quayConnection)
repository: $(imageName)
Dockerfile: build-tools/Dockerfile.ubi
buildContext: .
tags: $(Build.SourceVersion)
arguments: "--build-arg BUILD_INFO=azure-$(Build.BuildId)-$(Build.SourceVersion) --build-arg BUILD_VERSION=$(BUILD_VERSION) --build-arg RUN_TESTS=$(RUN_TESTS) --build-arg COVERALLS_TOKEN=$(COVERALLS_TOKEN)"
- task: Docker@2
displayName: Push image to Quay
inputs:
command: push
containerRegistry: $(quayConnection)
repository: $(imageName)
tags: $(Build.SourceVersion)
- script: |
set -ex
podman pull --authfile $(DOCKER_CONFIG)/config.json $(quay_path):$(Build.SourceVersion)
podman tag $(quay_path):$(Build.SourceVersion) scan.connect.redhat.com/$(REDHAT_PRJ_ID)/$(redhat_prj_name):$(redhat_tag)
podman push --authfile $(DOCKER_CONFIG)/config.json scan.connect.redhat.com/$(REDHAT_PRJ_ID)/$(redhat_prj_name):$(redhat_tag)
condition: and(succeeded(), startsWith(variables['build.sourceBranch'], 'refs/tags/'))
displayName: 'Push to Redhat'
continueOnError: true
- script: |
set -ex
docker pull $(quay_path):$(Build.SourceVersion)
docker tag $(quay_path):$(Build.SourceVersion) $(docker_repo):latest
docker tag $(quay_path):$(Build.SourceVersion) $(docker_repo):$(docker_version)
patch_version=`echo $(docker_version) | awk -F '.' '{print $3}'`
if [ "${patch_version}" == "0" ] ; then
stripped_version=`echo $(docker_version) | rev | cut -c3- | rev`
docker tag $(quay_path):$(Build.SourceVersion) $(docker_repo):${stripped_version}
docker push $(docker_repo):${stripped_version}
fi
docker push $(docker_repo):latest
docker push $(docker_repo):$(docker_version)
displayName: 'Push to DockerHub'
condition: startsWith(variables['build.sourceBranch'], 'refs/tags/')