forked from trinodb/trino
-
Notifications
You must be signed in to change notification settings - Fork 1
/
azure-pipelines.yml
98 lines (95 loc) · 3.56 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
85
86
87
88
89
90
91
92
93
94
95
96
97
98
trigger:
batch: true
branches:
include:
- cccs-main
variables:
containerRegistry: uchimera
m2RepoNodePath: /datadisks/disk1/.m2/repository
m2RepoContainerPath: /tmp/m2/repository
jobs:
- job: PrepareNode
displayName: Prepare the node for the Container Build
pool: cauldron-vmss
steps:
- checkout: none
- bash: |
mkdir -p ${{ variables.m2RepoNodePath }}
displayName: Create required directories
- job: ContainerBuild
dependsOn:
- PrepareNode
displayName: Maven Build (Container)
pool: cauldron-vmss
variables:
containerRegistry: uchimera
imageRepository: cccs/trino-base
buildTimestamp: $[format('{0:yyyyMMddHHmmss}', pipeline.startTime)]
JAVA_TOOL_OPTIONS: " -Xmx8g"
DOCKER_BUILDKIT: 1
container:
image: uchimera.azurecr.io/cccs/dev/trino-build:460_cccs-main_20241015213533_b11038
options: --entrypoint="" --user=0
endpoint: uchimera
volumes:
- "${{ variables.m2RepoNodePath }}:${{ variables.m2RepoContainerPath }}"
steps:
- task: Bash@3
displayName: Parse Source Control Branch Name
inputs:
targetType: 'inline'
script: |
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"
- task: MavenAuthenticate@0
displayName: Authenticate to cccs-stratus Feed
inputs:
mavenServiceConnections: cccs-stratus
- task: Bash@3
displayName: Maven build
inputs:
targetType: 'inline'
script: |
$(Build.SourcesDirectory)/mvnw clean install -e -DskipTests -pl '!:trino-docs' -Dmaven.repo.local=${{ variables.m2RepoContainerPath }}
- task: Docker@2
displayName: Login to ${{ variables.containerRegistry }}
inputs:
command: login
containerRegistry: ${{ variables.containerRegistry }}
- task: Bash@3
displayName: Build Base Image
inputs:
targetType: 'inline'
script: |
cd $(Build.SourcesDirectory)/core/docker
chmod g+w ${HOME}
chmod ug+x ./build.sh
./build.sh -a amd64 -x
if [ $? -ne 0 ]; then
echo "Docker build failed"
exit 1
fi
TRINO_VERSION=$("$(Build.SourcesDirectory)/mvnw" -f "$(Build.SourcesDirectory)/pom.xml" --quiet help:evaluate -Dexpression=project.version -DforceStdout)
DOCKERFILE="FROM trino:${TRINO_VERSION}-amd64
LABEL cccs.trino.upstream.version=${TRINO_VERSION}"
DOCKERFILE_PATH=$(mktemp -d)/Dockerfile
echo "${DOCKERFILE}" > "${DOCKERFILE_PATH}"
echo "##vso[task.setvariable variable=DOCKERFILE_PATH]$DOCKERFILE_PATH"
echo "DOCKERFILE:"
echo "${DOCKERFILE}"
- task: Docker@2
displayName: Finalize, tag and push image to ${{ variables.containerRegistry }}
inputs:
command: buildAndPush
containerRegistry: ${{ variables.containerRegistry }}
repository: ${{ variables.imageRepository }}
Dockerfile: $(DOCKERFILE_PATH)
tags: |
$(BRANCH_NAME)
$(BRANCH_NAME)_$(buildTimestamp)_b$(Build.BuildId)
- task: Docker@2
displayName: Logout of ${{ variables.containerRegistry }}
inputs:
command: logout
containerRegistry: ${{ variables.containerRegistry }}
condition: always()