forked from Azure/azure-databricks-operator
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathazure-pipelines.yaml
104 lines (85 loc) · 3.32 KB
/
azure-pipelines.yaml
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
96
97
98
99
100
101
102
103
104
trigger:
branches:
include:
- master
pool:
vmImage: 'Ubuntu 16.04'
variables:
GOROOT: '/usr/local/go1.12' # Go installation path
GOPATH: '$(System.DefaultWorkingDirectory)/gopath' # Go workspace path
GOBIN: '$(GOPATH)/bin' # Go binaries path
MODULE_PATH: '$(GOPATH)/src/$(Build.Repository.Name)' # Path to the module's code
IMAGE_NAME: 'candidate/k8s/azure-databricks/operator:$(Build.SourceVersion)'
# ACR_NAME: - set this value in Azure Devops variables
# AZURE_SUBSCRIPTION: - set this value in Azure Devops variables
# DATABRICKS_HOST: - set this value in Azure Devops variables
# DATABRICKS_TOKEN: - set this value in Azure Devops variables
steps:
- checkout: self # self represents the repo where the initial Pipelines YAML file was found
lfs: "true"
- script: |
set -x
ls -l /usr/local/go*
mkdir -p '$(GOBIN)'
mkdir -p '$(GOPATH)/pkg'
mkdir -p '$(MODULE_PATH)'
shopt -s extglob
mv !(gopath) '$(MODULE_PATH)'
echo '##vso[task.prependpath]$(GOBIN)'
echo '##vso[task.prependpath]$(GOROOT)/bin'
go version
go env
displayName: 'Set up the Go workspace'
env:
GO111MODULE: on
- script: |
set -x
mkdir -p '$(MODULE_PATH)/bin'
os=$(go env GOOS)
arch=$(go env GOARCH)
# download kubebuilder
curl -sL https://go.kubebuilder.io/dl/2.0.0-alpha.4/${os}/${arch} | tar -xz -C $(MODULE_PATH)/bin
mv $(MODULE_PATH)/bin/kubebuilder_2.0.0-alpha.4_${os}_${arch}/bin/* $(MODULE_PATH)/bin/
# download kustomize
curl -o $(MODULE_PATH)/bin/kustomize -sL https://go.kubebuilder.io/kustomize/${os}/${arch}
# set permission
chmod a+x $(MODULE_PATH)/bin/*
# export path
export PATH=$PATH:$(MODULE_PATH)/bin
make test
continueOnError: 'false'
displayName: 'Install kubebuilder, kustomize and Run unit tests'
env:
GO111MODULE: on
KUBEBUILDER_ASSETS: $(MODULE_PATH)/bin
DATABRICKS_HOST: $(DATABRICKS_HOST)
DATABRICKS_TOKEN: $(DATABRICKS_TOKEN)
workingDirectory: '$(MODULE_PATH)'
- script: docker build -t $(IMAGE_NAME) . # add options to this command to meet your needs
condition: and(succeeded(), ne(variables['Build.SourceBranch'], 'refs/heads/master'))
displayName: 'Docker build'
workingDirectory: '$(MODULE_PATH)'
- task: AzureCLI@1
condition: and(succeeded(), eq(variables['Build.SourceBranch'], 'refs/heads/master'))
displayName: Push to Azure Container Registry
inputs:
azureSubscription: $(AZURE_SUBSCRIPTION)
scriptLocation: inlineScript
failOnStandardError: false
workingDirectory: '$(MODULE_PATH)'
inlineScript: az acr build --registry $(ACR_NAME) --image $(IMAGE_NAME) .
- script: |
./bin/kustomize build config/default > $(Build.ArtifactStagingDirectory)/setup.yaml
set -x
echo $(IMAGE_NAME) > $(Build.ArtifactStagingDirectory)/azure-databricks-operator.txt
cp ./config/crd/bases/* $(Build.ArtifactStagingDirectory)
ls $(Build.ArtifactStagingDirectory)
continueOnError: 'false'
displayName: 'Prepare manifests for publish'
workingDirectory: '$(MODULE_PATH)'
condition: and(succeeded(), eq(variables['Build.SourceBranch'], 'refs/heads/master'))
- task: PublishBuildArtifacts@1
condition: and(succeeded(), eq(variables['Build.SourceBranch'], 'refs/heads/master'))
inputs:
pathtoPublish: $(Build.ArtifactStagingDirectory)
artifactName: drop