mirror of
https://github.com/mattermost/mattermost.git
synced 2025-02-25 18:55:24 -06:00
189 lines
9.0 KiB
Groovy
189 lines
9.0 KiB
Groovy
#!/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: []])
|
|
}
|
|
}
|
|
}
|