forked from eclipse-che/che-server
-
Notifications
You must be signed in to change notification settings - Fork 0
/
azure-pipelines.yml
71 lines (65 loc) · 2.25 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
trigger:
batch: true
branches:
include:
- cccs-*
variables:
containerRegistry: uchimera
organization: cccs
imagePrefix: che
imageName: server
buildTimestamp: $[format('{0:yyyyMMddHHmmss}', pipeline.startTime)]
DOCKER_BUILDKIT: 1
pool:
vmImage: ubuntu-latest
steps:
- bash: |
BRANCH_NAME=$(echo "$SYSTEM_PULLREQUEST_SOURCEBRANCH $BUILD_SOURCEBRANCH" | sed -r 's/^\s*(refs\/heads\/)?(\S*).*$/\2/' | sed 's/\//_/g')
echo "##vso[task.setvariable variable=BRANCH_NAME]$BRANCH_NAME"
displayName: Parse Source Control Branch Name
- task: Maven@3
inputs:
mavenPomFile: 'pom.xml'
publishJUnitResults: true
testResultsFiles: '**/surefire-reports/TEST-*.xml'
javaHomeOption: 'JDKVersion'
mavenVersionOption: 'Default'
mavenAuthenticateFeed: false
effectivePomSkip: false
sonarQubeRunAnalysis: false
displayName: Maven build
- bash: |
CHE_VERSION=$(mvn --quiet help:evaluate -Dexpression=project.version -DforceStdout)
cd $(Build.SourcesDirectory)/dockerfiles/che
./build.sh --organization:$(organization) --prefix:$(imagePrefix) --name:$(imageName) --tag:${CHE_VERSION}
if [ $? -ne 0 ]; then
echo "Docker build failed"
exit 1
fi
DOCKERFILE="FROM $(organization)/$(imagePrefix)-$(imageName):${CHE_VERSION}
LABEL cccs.che.upstream.version=${CHE_VERSION}"
DOCKERFILE_PATH=$(mktemp -d)/Dockerfile
echo "${DOCKERFILE}" > "${DOCKERFILE_PATH}"
echo "##vso[task.setvariable variable=DOCKERFILE_PATH]$DOCKERFILE_PATH"
displayName: Docker build
- task: Docker@2
displayName: Login to $(containerRegistry)
inputs:
command: login
containerRegistry: $(containerRegistry)
- task: Docker@2
displayName: Finalize, tag and push image to $(containerRegistry)
inputs:
command: buildAndPush
containerRegistry: $(containerRegistry)
repository: $(organization)/$(imagePrefix)-$(imageName)
Dockerfile: $(DOCKERFILE_PATH)
tags: |
$(BRANCH_NAME)
$(BRANCH_NAME)_$(buildTimestamp)_b$(Build.BuildId)
- task: Docker@2
displayName: Logout of $(containerRegistry)
inputs:
command: logout
containerRegistry: $(containerRegistry)
condition: always()