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
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
|
#!/usr/bin/env groovy
podTemplate(label: 'jenkins-slave',
containers: [
containerTemplate(
name: 'mattermost-mysql',
image: 'mysql:5.7',
alwaysPullImage: false,
resourceRequestCpu: '500m',
resourceLimitCpu: '1000m',
resourceRequestMemory: '1Gi',
resourceLimitMemory: '2Gi',
ports: [portMapping(name: 'mysql', containerPort: 3306, hostPort: 3306)],
envVars: [
envVar(key: 'MYSQL_ROOT_PASSWORD', value: 'mostest'),
envVar(key: 'MYSQL_USER', value: 'mmuser'),
envVar(key: 'MYSQL_PASSWORD', value: 'mostest'),
envVar(key: 'MYSQL_DATABASE', value: 'mattermost_test')
]
),
containerTemplate(
name: 'golang',
image: 'golang:1.9.1',
ttyEnabled: true,
command: 'cat',
alwaysPullImage: false,
resourceRequestCpu: '1000m',
resourceLimitCpu: '1000m',
resourceRequestMemory: '2Gi',
resourceLimitMemory: '4Gi'
),
containerTemplate(
name: 'mattermost-inbucket',
image: 'jhillyerd/inbucket:release-1.2.0',
resourceRequestCpu: '250m',
resourceLimitCpu: '250m',
resourceRequestMemory: '256Mi',
resourceLimitMemory: '256Mi'
),
containerTemplate(
name: 'mattermost-redis',
image: 'redis',
ports: [portMapping(name: 'redis', hostPost: 6379, containerPort: 6379)],
resourceRequestCpu: '250m',
resourceLimitCpu: '250m',
resourceRequestMemory: '256Mi',
resourceLimitMemory: '256Mi'
),
containerTemplate(
name: 'mattermost-openldap',
image: 'osixia/openldap:1.1.9',
alwaysPullImage: true,
ports: [
portMapping(name: 'openldap1', hostPost: 389, containerPort: 389),
portMapping(name: 'openldap2', hostPost: 636, containerPort: 636)
],
envVars: [
envVar(key: 'LDAP_TLS_VERIFY_CLIENT', value: 'never'),
envVar(key: 'LDAP_ORGANISATION', value: 'Mattermost Test'),
envVar(key: 'LDAP_DOMAIN', value: 'mm.test.com'), envVar(key: 'LDAP_ADMIN_PASSWORD', value: 'mostest')
],
args: "--loglevel debug",
resourceRequestCpu: '250m',
resourceLimitCpu: '250m',
resourceRequestMemory: '256Mi',
resourceLimitMemory: '256Mi'
),
containerTemplate(
name: 'mattermost-minio',
image: 'minio/minio:latest',
ttyEnabled: false,
args: 'server /data',
alwaysPullImage: true,
resourceRequestCpu: '250m',
resourceLimitCpu: '250m',
resourceRequestMemory: '256Mi',
resourceLimitMemory: '256Mi',
envVars: [
envVar(key: 'MINIO_ACCESS_KEY', value: 'minioaccesskey'),
envVar(key: 'MINIO_SECRET_KEY', value: 'miniosecretkey')
]
),
containerTemplate(
name: 'mattermost-node',
image: 'node',
ttyEnabled: true,
command: 'cat',
alwaysPullImage: false,
resourceRequestCpu: '500m',
resourceLimitCpu: '1000m',
resourceRequestMemory: '1Gi',
resourceLimitMemory: '2Gi'
),
/*
containerTemplate(
name: 'mattermost-elasticsearch',
image: 'grundleborg/elasticsearch:latest',
ports: [portMapping(name: 'elasticsearch', hostPost: 9200, containerPort: 9200)],
envVars: [envVar(key: 'http.host', value: '0.0.0.0'), envVar(key: 'transport.host', value: '127.0.0.1'), envVar(key: 'ES_JAVA_OPTS', value: '-Xmx250m -Xmx250m')],
resourceRequestCpu: '250m',
resourceLimitCpu: '250m',
resourceRequestMemory: '256Mi',
resourceLimitMemory: '256Mi'
)*/
]
)
{
node('jenkins-slave') {
stage('Checkout') {
container('golang') {
// Checkout mattermost-server
dir('mattermost-server') {
git branch: env.BRANCH_NAME, credentialsId: 'mattermostBuild', url: 'https://github.com/mattermost/mattermost-server.git'
}
dir('mattermost-webapp') {
git branch: 'master', credentialsId: 'mattermostBuild', url: 'https://github.com/mattermost/mattermost-webapp.git'
sh "git checkout ${env.BRANCH_NAME} || echo 'NO CLIENT BRANCH'"
}
// Checkout enterprise
dir('enterprise') {
git branch: 'master', credentialsId: 'mattermostBuild', url: 'https://github.com/mattermost/enterprise.git'
sh "git checkout ${env.BRANCH_NAME} || echo 'NO EE BRANCH'"
}
}
}
stage('Prep Environment') {
container('golang') {
// Link up the code to GOPATH.
sh 'mkdir -p /go/src/github.com/mattermost'
sh 'ln -s `pwd`/mattermost-server /go/src/github.com/mattermost/mattermost-server'
sh 'ln -s `pwd`/enterprise /go/src/github.com/mattermost/enterprise'
// Install build deps
sh 'apt-get update && apt-get install zip -y'
// Modify config to run on jenkins
sh 'mv /go/src/github.com/mattermost/mattermost-server/config/default.json /go/src/github.com/mattermost/mattermost-server/config/config.json'
sh 'cd /go/src/github.com/mattermost/mattermost-server && sed -i \'s/dockerhost/localhost/g\' config/config.json'
sh 'cd /go/src/github.com/mattermost/mattermost-server && sed -i \'s/2500/10025/g\' config/config.json'
}
container('mattermost-minio') {
// setting up the minio folder
sh 'mkdir -p /data/mattermost-test'
}
// Setup openldap container
/*container('mattermost-openldap') {
sh 'echo \\"dn: ou=testusers,dc=mm,dc=test,dc=com\\" >> user1'
sh 'echo \\"objectclass: organizationalunit\\" >> user1'
sh 'ldapadd -x -D \\"cn=admin,dc=mm,dc=test,dc=com\\" -w mostest -f user1'
sh 'echo -e \\"dn: uid=test.one,ou=testusers,dc=mm,dc=test,dc=com\\nobjectclass: iNetOrgPerson\\nsn: User\\ncn: Test1\\nmail: success+testone@simulator.amazonses.com\\" | ldapadd -x -D \\"cn=admin,dc=mm,dc=test,dc=com\\" -w mostest'
sh 'ldappasswd -s Password1 -D \\"cn=admin,dc=mm,dc=test,dc=com\\" -x \\"uid=test.one,ou=testusers,dc=mm,dc=test,dc=com\\" -w mostest'
sh 'echo -e \\"dn: uid=test.two,ou=testusers,dc=mm,dc=test,dc=com\\nobjectclass: iNetOrgPerson\\nsn: User\\ncn: Test2\\nmail: success+testtwo@simulator.amazonses.com\\" | ldapadd -x -D \\"cn=admin,dc=mm,dc=test,dc=com\\" -w mostest'
sh 'ldappasswd -s Password1 -D \\"cn=admin,dc=mm,dc=test,dc=com\\" -x \\"uid=test.two,ou=testusers,dc=mm,dc=test,dc=com\\" -w mostest'
sh 'echo -e \\"dn: cn=tgroup,ou=testusers,dc=mm,dc=test,dc=com\\nobjectclass: groupOfUniqueNames\\nuniqueMember: uid=test.one,ou=testusers,dc=mm,dc=test,dc=com\\" | ldapadd -x -D \\"cn=admin,dc=mm,dc=test,dc=com\\" -w mostest'
}*/
}
stage('Style Checks') {
container('golang') {
sh 'cd /go/src/github.com/mattermost/mattermost-server && make check-style'
}
}
stage('Build') {
container('golang') {
sh "cd /go/src/github.com/mattermost/mattermost-server && make build BUILD_NUMBER=${env.BUILD_NUMBER}"
}
container('mattermost-node') {
sh "cd mattermost-webapp && curl -f -o ./dist.tar.gz https://releases.mattermost.com/mattermost-webapp/commit/`git rev-parse HEAD`/mattermost-webapp.tar.gz && mkdir ./dist && tar -xvf ./dist.tar.gz -C ./dist --strip-components=1 || make build"
}
container('golang') {
sh "cd /go/src/github.com/mattermost/mattermost-server && make package BUILD_NUMBER=${env.BUILD_NUMBER}"
}
}
stage('Unit Tests') {
container('golang') {
withEnv(['CI_HOST=localhost', 'CI_INBUCKET_PORT=10080', 'CI_MINIO_PORT=9000']) {
sh "cd /go/src/github.com/mattermost/mattermost-server && make test-te BUILD_NUMBER=${env.BUILD_NUMBER} TESTFLAGS= TESTFLAGSEE="
}
}
}
stage('S3 Publish') {
step([$class: 'S3BucketPublisher', dontWaitForConcurrentBuildCompletion: false, entries: [[bucket: 'releases.mattermost.com/mattermost-server/${env.BRANCH_NAME}', excludedFile: '', flatten: true, gzipFiles: false, keepForever: false, managedArtifacts: false, noUploadOnFailure: true, selectedRegion: 'us-east-1', showDirectlyInBrowser: false, sourceFile: 'src/github.com/mattermost/platform/dist/mattermost-enterprise*', storageClass: 'STANDARD', uploadFromSlave: false, useServerSideEncryption: false, userMetadata: [[key: 'Cache-Control', value: 'no-cache']]]], profileName: 'Releases', userMetadata: []])
}
}
}
|