This repository has been archived by the owner on Dec 11, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 4
/
azure-pipelines.yml
84 lines (71 loc) · 3.08 KB
/
azure-pipelines.yml
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
pool:
vmImage: 'Ubuntu 16.04'
variables:
GOBIN: '$(GOPATH)/bin' # Go binaries path
GOROOT: '/usr/local/go1.11' # Go installation path
GOPATH: '$(system.defaultWorkingDirectory)/gopath' # Go workspace path
modulePath: '$(GOPATH)/src/github.com/$(build.repository.name)' # Path to the module's code
trigger:
branches:
include:
- master
paths:
include:
- app/*
steps:
- script: |
ls -la
cp helm/*.tgz $(Build.ArtifactStagingDirectory)/
mkdir -p '$(Build.ArtifactStagingDirectory)/manual-deploy/'
cp manual-deploy/smackapi.yaml $(Build.ArtifactStagingDirectory)/manual-deploy/
cp manual-deploy/smackapi-vs.yaml $(Build.ArtifactStagingDirectory)/manual-deploy/
cp manual-deploy/smackweb.yaml $(Build.ArtifactStagingDirectory)/manual-deploy/
cp manual-deploy/smackweb-vs.yaml $(Build.ArtifactStagingDirectory)/manual-deploy/
cp manual-deploy/destrule.yaml $(Build.ArtifactStagingDirectory)/manual-deploy/
displayName: 'copy helm chart and yaml files'
- script: |
mkdir -p '$(GOBIN)'
mkdir -p '$(GOPATH)/pkg'
mkdir -p '$(modulePath)'
shopt -s extglob
mv !(gopath) '$(modulePath)'
echo '##vso[task.prependpath]$(GOBIN)'
echo '##vso[task.prependpath]$(GOROOT)/bin'
displayName: 'Set up the Go workspace'
- script: |
go version
cd app/smackapi
go get github.com/gorilla/mux
GOOS=linux GOARCH=amd64 CGO_ENABLED=0 go build -o smackapi
go test -v
workingDirectory: '$(modulePath)'
displayName: 'Build api'
- script: |
SHORT_COMMIT=`echo $(Build.SourceVersion)| cut -c1-8`
docker build -t $(dockerId).azurecr.io/smackapi:$(Build.SourceBranchName)-$SHORT_COMMIT --build-arg BUILD_DATE=`date -u +"%Y-%m-%dT%H%M%SZ"` --build-arg IMAGE_TAG_REF=$SHORT_COMMIT --build-arg VCS_REF=$SHORT_COMMIT app/smackapi/
docker login -u $(dockerId) -p $(dockerPassword) $(dockerId).azurecr.io
docker push $(dockerId).azurecr.io/smackapi:$(Build.SourceBranchName)-$SHORT_COMMIT
workingDirectory: '$(modulePath)'
displayName: 'API - Docker build and push'
- script: |
go version
cd app/smackweb
go get github.com/gorilla/mux
GOOS=linux GOARCH=amd64 CGO_ENABLED=0 go build -o smackweb
workingDirectory: '$(modulePath)'
displayName: 'Build web ui'
- script: |
SHORT_COMMIT=`echo $(Build.SourceVersion)| cut -c1-8`
docker build -t $(dockerId).azurecr.io/smackweb:$(Build.SourceBranchName)-$SHORT_COMMIT --build-arg BUILD_DATE=`date -u +"%Y-%m-%dT%H%M%SZ"` --build-arg IMAGE_TAG_REF=$SHORT_COMMIT --build-arg VCS_REF=$SHORT_COMMIT app/smackweb/
docker login -u $(dockerId) -p $(dockerPassword) $(dockerId).azurecr.io
docker push $(dockerId).azurecr.io/smackweb:$(Build.SourceBranchName)-$SHORT_COMMIT
workingDirectory: '$(modulePath)'
displayName: 'WEB UI - Docker build and push'
- script: |
SHORT_COMMIT=`echo $(Build.SourceVersion)| cut -c1-8`
echo $(Build.SourceBranchName)-$SHORT_COMMIT > $(Build.ArtifactStagingDirectory)/imagetag
displayName: 'export variable'
- task: PublishBuildArtifacts@1
inputs:
pathtoPublish: '$(Build.ArtifactStagingDirectory)'
artifactName: 'drop'