forked from minio/minio
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Jenkinsfile
125 lines (122 loc) · 4.76 KB
/
Jenkinsfile
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
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
pipeline {
agent {
node {
label 'dev'
customWorkspace "${env.JOB_NAME}/${env.BUILD_TAG}"
}
}
options {
ansiColor('xterm')
}
environment {
dockerRegistry = "aplregistry.aarnet.edu.au"
ImageTag = "ci-${env.BUILD_NUMBER}"
ImageName = "${dockerRegistry}/cloudservices/minio/shard:${ImageTag}"
buildImageName = "minio-eos-build-${env.BUILD_NUMBER}"
}
stages {
stage('Setup') {
steps {
script {
try {
if ( gitlabActionType && gitlabActionType == "PUSH" ) {
currentBuild.description = "Build of '$env.gitlabBranch' started by $env.gitlabUserName"
}
}
catch (MissingPropertyException e) {
// Just don't error if gitlabActionType is not set
}
}
sh script: "docker build . -f Dockerfile.jenkins -t ${buildImageName}", label: "Build docker environment"
}
}
stage('Lint & Formatting') {
steps {
catchError(buildResult: 'UNSTABLE', stageResult: 'FAILURE') {
sh script: "docker run -t --rm ${buildImageName} make verifiers", label: "Run style verifiers"
}
}
}
stage('Build minio') {
steps {
sh script: "docker run -t --rm ${buildImageName} make build", label: "Build minio binary"
}
}
stage ('Build and Test docker image') {
steps {
withDockerRegistry(url: 'https://aplregistry.aarnet.edu.au', credentialsId: 'jenkins-cloudservices-docker') {
sh script: "docker build -t ${ImageName} -f Dockerfile.aarnet .", label: "Build cloudstor-s3-gateway docker image"
sh script: "( cd aarnet/devenv && BUILD_TAG=${ImageTag} ./devenv -a -j )", label: "Start EOS and minio"
}
sleep 5
// Skipping running mint as it always fails as we do not have the full implementation in the minio gateway
catchError(buildResult: 'UNSTABLE', stageResult: 'UNSTABLE') {
// sh script: "docker run --network devenvminio_shard -e SERVER_ENDPOINT=minio.shard:9000 -e ACCESS_KEY=minioadmin -e SECRET_KEY=minioadmin -e ENABLE_HTTPS=0 minio/mint", label: "Running Mint Tests"
retry(5) {
sh script: "( cd aarnet/devenv && docker-compose exec -T mgm bash -c 'eos mkdir -p /eos/shard/data/gateways/miniodev/.healthcheck && eos touch eos/shard/data/gateways/miniodev/.healthcheck/.minio-healthcheck' )", label: "Create healthcheck file"
sh script: "( cd aarnet/devenv && docker-compose exec -T minio bash -c 'DEBUG=true /scripts/minio-healthcheck' )", label: "Testing minio-healthcheck"
sleep 1 // Just wait a bit okay.
}
sh script: "( cd aarnet/devenv && docker-compose exec -T minio bash /scripts/test-gateway.sh )", label: "Running basic tests using minio client"
}
}
post {
success {
withDockerRegistry(url: 'https://aplregistry.aarnet.edu.au', credentialsId: 'jenkins-cloudservices-docker') {
sh script: "docker push ${ImageName}", label: "Push image to registry"
script {
currentBuild.description = "${currentBuild.description}\n\n${ImageName}"
}
}
}
unstable {
withDockerRegistry(url: 'https://aplregistry.aarnet.edu.au', credentialsId: 'jenkins-cloudservices-docker') {
sh script: "docker push ${ImageName}", label: "Push image to registry"
script {
currentBuild.description = "${currentBuild.description}\n\n${ImageName}"
}
}
}
cleanup {
sh script: "( cd aarnet/devenv && BUILD_TAG=${ImageTag} ./devenv -d -j )", label: "Tear down EOS and minio"
sh script: "docker rmi ${ImageName}", label: "Cleanup cloudstor-s3-gateway docker image"
}
}
}
}
post {
success {
slackSend(
channel: 'apl-cs-pipeline',
notifyCommitters: true,
tokenCredentialId: 'slack-notifications-apl-cs-pipeline',
baseUrl: 'https://aarnet.slack.com/services/hooks/jenkins-ci/',
color: 'good',
message: "${currentBuild.projectName} #${currentBuild.number} completed successfully.\n" + "${currentBuild.description}\n" + "${env.BUILD_URL}\n"
)
}
unstable {
slackSend(
channel: 'apl-cs-pipeline',
notifyCommitters: true,
tokenCredentialId: 'slack-notifications-apl-cs-pipeline',
baseUrl: 'https://aarnet.slack.com/services/hooks/jenkins-ci/',
color: 'warning',
message: "${currentBuild.projectName} #${currentBuild.number} built successfully but marked as unstable.\n" + "${currentBuild.description}\n" + "${env.BUILD_URL}\n"
)
}
failure {
slackSend(
channel: 'apl-cs-pipeline',
notifyCommitters: true,
tokenCredentialId: 'slack-notifications-apl-cs-pipeline',
baseUrl: 'https://aarnet.slack.com/services/hooks/jenkins-ci/',
color: 'danger',
message: "${currentBuild.projectName} #${currentBuild.number} failed.\n" + "${currentBuild.description}\n" + "${env.BUILD_URL}\n"
)
}
cleanup {
sh script: "docker rmi ${buildImageName}", label: "Cleanup docker environment image"
}
}
};