github.com/ashishbhate/mattermost-server@v5.11.1+incompatible/build/Jenkinsfile.k8s (about) 1 #!/usr/bin/env groovy 2 3 podTemplate(label: 'jenkins-slave', 4 containers: [ 5 containerTemplate( 6 name: 'mattermost-mysql', 7 image: 'mysql:5.7', 8 alwaysPullImage: false, 9 resourceRequestCpu: '500m', 10 resourceLimitCpu: '1000m', 11 resourceRequestMemory: '1Gi', 12 resourceLimitMemory: '2Gi', 13 ports: [portMapping(name: 'mysql', containerPort: 3306, hostPort: 3306)], 14 envVars: [ 15 envVar(key: 'MYSQL_ROOT_PASSWORD', value: 'mostest'), 16 envVar(key: 'MYSQL_USER', value: 'mmuser'), 17 envVar(key: 'MYSQL_PASSWORD', value: 'mostest'), 18 envVar(key: 'MYSQL_DATABASE', value: 'mattermost_test') 19 ] 20 ), 21 containerTemplate( 22 name: 'golang', 23 image: 'golang:1.9.1', 24 ttyEnabled: true, 25 command: 'cat', 26 alwaysPullImage: false, 27 resourceRequestCpu: '1000m', 28 resourceLimitCpu: '1000m', 29 resourceRequestMemory: '2Gi', 30 resourceLimitMemory: '4Gi' 31 ), 32 containerTemplate( 33 name: 'mattermost-inbucket', 34 image: 'jhillyerd/inbucket:release-1.2.0', 35 resourceRequestCpu: '250m', 36 resourceLimitCpu: '250m', 37 resourceRequestMemory: '256Mi', 38 resourceLimitMemory: '256Mi' 39 ), 40 containerTemplate( 41 name: 'mattermost-redis', 42 image: 'redis', 43 ports: [portMapping(name: 'redis', hostPost: 6379, containerPort: 6379)], 44 resourceRequestCpu: '250m', 45 resourceLimitCpu: '250m', 46 resourceRequestMemory: '256Mi', 47 resourceLimitMemory: '256Mi' 48 ), 49 containerTemplate( 50 name: 'mattermost-openldap', 51 image: 'osixia/openldap:1.1.9', 52 alwaysPullImage: true, 53 ports: [ 54 portMapping(name: 'openldap1', hostPost: 389, containerPort: 389), 55 portMapping(name: 'openldap2', hostPost: 636, containerPort: 636) 56 ], 57 envVars: [ 58 envVar(key: 'LDAP_TLS_VERIFY_CLIENT', value: 'never'), 59 envVar(key: 'LDAP_ORGANISATION', value: 'Mattermost Test'), 60 envVar(key: 'LDAP_DOMAIN', value: 'mm.test.com'), envVar(key: 'LDAP_ADMIN_PASSWORD', value: 'mostest') 61 ], 62 args: "--loglevel debug", 63 resourceRequestCpu: '250m', 64 resourceLimitCpu: '250m', 65 resourceRequestMemory: '256Mi', 66 resourceLimitMemory: '256Mi' 67 ), 68 containerTemplate( 69 name: 'mattermost-minio', 70 image: 'minio/minio:latest', 71 ttyEnabled: false, 72 args: 'server /data', 73 alwaysPullImage: true, 74 resourceRequestCpu: '250m', 75 resourceLimitCpu: '250m', 76 resourceRequestMemory: '256Mi', 77 resourceLimitMemory: '256Mi', 78 envVars: [ 79 envVar(key: 'MINIO_ACCESS_KEY', value: 'minioaccesskey'), 80 envVar(key: 'MINIO_SECRET_KEY', value: 'miniosecretkey') 81 ] 82 ), 83 containerTemplate( 84 name: 'mattermost-node', 85 image: 'node', 86 ttyEnabled: true, 87 command: 'cat', 88 alwaysPullImage: false, 89 resourceRequestCpu: '500m', 90 resourceLimitCpu: '1000m', 91 resourceRequestMemory: '1Gi', 92 resourceLimitMemory: '2Gi' 93 ), 94 /* 95 containerTemplate( 96 name: 'mattermost-elasticsearch', 97 image: 'grundleborg/elasticsearch:latest', 98 ports: [portMapping(name: 'elasticsearch', hostPost: 9200, containerPort: 9200)], 99 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')], 100 resourceRequestCpu: '250m', 101 resourceLimitCpu: '250m', 102 resourceRequestMemory: '256Mi', 103 resourceLimitMemory: '256Mi' 104 )*/ 105 ] 106 ) 107 { 108 node('jenkins-slave') { 109 stage('Checkout') { 110 container('golang') { 111 // Checkout mattermost-server 112 dir('mattermost-server') { 113 git branch: env.BRANCH_NAME, credentialsId: 'mattermostBuild', url: 'https://github.com/mattermost/mattermost-server.git' 114 } 115 116 dir('mattermost-webapp') { 117 git branch: 'master', credentialsId: 'mattermostBuild', url: 'https://github.com/mattermost/mattermost-webapp.git' 118 sh "git checkout ${env.BRANCH_NAME} || echo 'NO CLIENT BRANCH'" 119 } 120 121 // Checkout enterprise 122 dir('enterprise') { 123 git branch: 'master', credentialsId: 'mattermostBuild', url: 'https://github.com/mattermost/enterprise.git' 124 sh "git checkout ${env.BRANCH_NAME} || echo 'NO EE BRANCH'" 125 } 126 } 127 } 128 stage('Prep Environment') { 129 container('golang') { 130 // Link up the code to GOPATH. 131 sh 'mkdir -p /go/src/github.com/mattermost' 132 sh 'ln -s `pwd`/mattermost-server /go/src/github.com/mattermost/mattermost-server' 133 sh 'ln -s `pwd`/enterprise /go/src/github.com/mattermost/enterprise' 134 135 // Install build deps 136 sh 'apt-get update && apt-get install zip -y' 137 138 // Modify config to run on jenkins 139 sh 'mv /go/src/github.com/mattermost/mattermost-server/config/default.json /go/src/github.com/mattermost/mattermost-server/config/config.json' 140 sh 'cd /go/src/github.com/mattermost/mattermost-server && sed -i \'s/dockerhost/localhost/g\' config/config.json' 141 sh 'cd /go/src/github.com/mattermost/mattermost-server && sed -i \'s/2500/10025/g\' config/config.json' 142 } 143 144 container('mattermost-minio') { 145 // setting up the minio folder 146 sh 'mkdir -p /data/mattermost-test' 147 } 148 149 // Setup openldap container 150 /*container('mattermost-openldap') { 151 sh 'echo \\"dn: ou=testusers,dc=mm,dc=test,dc=com\\" >> user1' 152 sh 'echo \\"objectclass: organizationalunit\\" >> user1' 153 sh 'ldapadd -x -D \\"cn=admin,dc=mm,dc=test,dc=com\\" -w mostest -f user1' 154 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' 155 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' 156 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' 157 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' 158 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' 159 }*/ 160 } 161 stage('Style Checks') { 162 container('golang') { 163 sh 'cd /go/src/github.com/mattermost/mattermost-server && make check-style' 164 } 165 } 166 stage('Build') { 167 container('golang') { 168 sh "cd /go/src/github.com/mattermost/mattermost-server && make build BUILD_NUMBER=${env.BUILD_NUMBER}" 169 } 170 container('mattermost-node') { 171 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" 172 } 173 container('golang') { 174 sh "cd /go/src/github.com/mattermost/mattermost-server && make package BUILD_NUMBER=${env.BUILD_NUMBER}" 175 } 176 } 177 stage('Unit Tests') { 178 container('golang') { 179 withEnv(['CI_INBUCKET_HOST=localhost', 'CI_INBUCKET_PORT=10080', 'CI_MINIO_HOST=localhost', 'CI_MINIO_PORT=9000']) { 180 sh "cd /go/src/github.com/mattermost/mattermost-server && make test-te BUILD_NUMBER=${env.BUILD_NUMBER} TESTFLAGS= TESTFLAGSEE=" 181 } 182 } 183 } 184 stage('S3 Publish') { 185 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: []]) 186 } 187 } 188 }