Moved Push to S3, Clean Checkout and Build Docker before Test (#12027)
Этот коммит содержится в:
коммит произвёл
Carlos Tadeu Panato Junior
родитель
ecbc5ef5e1
Коммит
d1017a089a
@@ -110,6 +110,126 @@ pipeline {
|
||||
}
|
||||
}
|
||||
|
||||
stage('Push to S3') {
|
||||
stages {
|
||||
stage('Pull request') {
|
||||
when {
|
||||
allOf {
|
||||
expression { env.CHANGE_ID != null }
|
||||
expression { env.CHANGE_TARGET != null }
|
||||
}
|
||||
}
|
||||
steps {
|
||||
dir('src/github.com/mattermost/mattermost-server/dist') {
|
||||
step([$class: 'S3BucketPublisher', dontWaitForConcurrentBuildCompletion: false, entries: [[
|
||||
bucket: "releases.mattermost.com/mattermost-platform-pr/${CHANGE_ID}",
|
||||
excludedFile: '',
|
||||
flatten: true,
|
||||
gzipFiles: false,
|
||||
keepForever: false,
|
||||
managedArtifacts: false,
|
||||
noUploadOnFailure: true,
|
||||
selectedRegion: 'us-east-1',
|
||||
showDirectlyInBrowser: false,
|
||||
sourceFile: '*.tar.gz',
|
||||
storageClass: 'STANDARD',
|
||||
uploadFromSlave: false,
|
||||
useServerSideEncryption: false,
|
||||
userMetadata: [[key: 'Cache-Control', value: 'no-cache']]
|
||||
], [
|
||||
bucket: "releases.mattermost.com/mattermost-platform-pr/${CHANGE_BRANCH}",
|
||||
excludedFile: '',
|
||||
flatten: true,
|
||||
gzipFiles: false,
|
||||
keepForever: false,
|
||||
managedArtifacts: false,
|
||||
noUploadOnFailure: true,
|
||||
selectedRegion: 'us-east-1',
|
||||
showDirectlyInBrowser: false,
|
||||
sourceFile: '*.tar.gz',
|
||||
storageClass: 'STANDARD',
|
||||
uploadFromSlave: false,
|
||||
useServerSideEncryption: false,
|
||||
userMetadata: [[key: 'Cache-Control', value: 'no-cache']]
|
||||
]], profileName: 'Releases', userMetadAta: []])
|
||||
}
|
||||
}
|
||||
}
|
||||
stage('Branch') {
|
||||
when {
|
||||
expression { env.CHANGE_ID == null }
|
||||
}
|
||||
steps {
|
||||
dir('src/github.com/mattermost/mattermost-server/dist') {
|
||||
step([$class: 'S3BucketPublisher', dontWaitForConcurrentBuildCompletion: false, entries: [[
|
||||
bucket: "releases.mattermost.com/mattermost-platform-pr/${BRANCH_NAME}",
|
||||
excludedFile: '',
|
||||
flatten: true,
|
||||
gzipFiles: false,
|
||||
keepForever: false,
|
||||
managedArtifacts: false,
|
||||
noUploadOnFailure: true,
|
||||
selectedRegion: 'us-east-1',
|
||||
showDirectlyInBrowser: false,
|
||||
sourceFile: '*.tar.gz',
|
||||
storageClass: 'STANDARD',
|
||||
uploadFromSlave: false,
|
||||
useServerSideEncryption: false,
|
||||
userMetadata: [[key: 'Cache-Control', value: 'no-cache']]
|
||||
]], profileName: 'Releases', userMetadAta: []])
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
stage('Clean checkout') {
|
||||
when {
|
||||
expression { env.CHANGE_ID != null }
|
||||
}
|
||||
// We need to perform a clean checkout here to ge the original git commit hash from the PR
|
||||
// Jenkins now merges master in top of the PR and this generate a new git hash
|
||||
// We need to do that to build the docker image based on the original git commit and then this will be used by
|
||||
// mattermod to update the test server.
|
||||
steps {
|
||||
sh """
|
||||
mkdir -p /tmp/mattermost-server
|
||||
"""
|
||||
dir('/tmp/mattermost-server') {
|
||||
checkout([$class: 'GitSCM', branches: [[name: 'FETCH_HEAD']],
|
||||
doGenerateSubmoduleConfigurations: false, extensions: [],
|
||||
submoduleCfg: [], userRemoteConfigs: [
|
||||
[refspec: "+refs/pull/${CHANGE_ID}/head:refs/remotes/origin/PR-${CHANGE_ID}",
|
||||
credentialsId: "310159d3-f7c5-4f5d-bfa1-151e3ef2db57",url: "https://github.com/mattermost/mattermost-server.git"]]])
|
||||
sh 'git rev-parse --short HEAD'
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
stage('Build Docker Image') {
|
||||
environment {
|
||||
GIT_COMMIT_SHORT = sh(
|
||||
script: "cd /tmp/mattermost-server && printf \$(git rev-parse --short HEAD)",
|
||||
returnStdout: true
|
||||
)
|
||||
}
|
||||
when {
|
||||
expression { env.CHANGE_ID != null }
|
||||
}
|
||||
steps {
|
||||
dir('src/github.com/mattermost/mattermost-server') {
|
||||
withCredentials([usernamePassword(credentialsId: 'matterbuild-docker-hub', usernameVariable: 'DOCKER_USER', passwordVariable: 'DOCKER_PASS')]) {
|
||||
sh 'docker login --username ${DOCKER_USER} --password ${DOCKER_PASS}'
|
||||
sh """
|
||||
docker build --no-cache --build-arg MM_PACKAGE=https://releases.mattermost.com/mattermost-platform-pr/${CHANGE_ID}/mattermost-enterprise-linux-amd64.tar.gz -t mattermost/mattermost-enterprise-edition:${GIT_COMMIT_SHORT} build
|
||||
docker push mattermost/mattermost-enterprise-edition:${GIT_COMMIT_SHORT}
|
||||
docker logout
|
||||
"""
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
stage('Test') {
|
||||
environment {
|
||||
GOPATH = "/go"
|
||||
@@ -269,126 +389,6 @@ pipeline {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
stage('Push to S3') {
|
||||
stages {
|
||||
stage('Pull request') {
|
||||
when {
|
||||
allOf {
|
||||
expression { env.CHANGE_ID != null }
|
||||
expression { env.CHANGE_TARGET != null }
|
||||
}
|
||||
}
|
||||
steps {
|
||||
dir('src/github.com/mattermost/mattermost-server/dist') {
|
||||
step([$class: 'S3BucketPublisher', dontWaitForConcurrentBuildCompletion: false, entries: [[
|
||||
bucket: "releases.mattermost.com/mattermost-platform-pr/${CHANGE_ID}",
|
||||
excludedFile: '',
|
||||
flatten: true,
|
||||
gzipFiles: false,
|
||||
keepForever: false,
|
||||
managedArtifacts: false,
|
||||
noUploadOnFailure: true,
|
||||
selectedRegion: 'us-east-1',
|
||||
showDirectlyInBrowser: false,
|
||||
sourceFile: '*.tar.gz',
|
||||
storageClass: 'STANDARD',
|
||||
uploadFromSlave: false,
|
||||
useServerSideEncryption: false,
|
||||
userMetadata: [[key: 'Cache-Control', value: 'no-cache']]
|
||||
], [
|
||||
bucket: "releases.mattermost.com/mattermost-platform-pr/${CHANGE_BRANCH}",
|
||||
excludedFile: '',
|
||||
flatten: true,
|
||||
gzipFiles: false,
|
||||
keepForever: false,
|
||||
managedArtifacts: false,
|
||||
noUploadOnFailure: true,
|
||||
selectedRegion: 'us-east-1',
|
||||
showDirectlyInBrowser: false,
|
||||
sourceFile: '*.tar.gz',
|
||||
storageClass: 'STANDARD',
|
||||
uploadFromSlave: false,
|
||||
useServerSideEncryption: false,
|
||||
userMetadata: [[key: 'Cache-Control', value: 'no-cache']]
|
||||
]], profileName: 'Releases', userMetadAta: []])
|
||||
}
|
||||
}
|
||||
}
|
||||
stage('Branch') {
|
||||
when {
|
||||
expression { env.CHANGE_ID == null }
|
||||
}
|
||||
steps {
|
||||
dir('src/github.com/mattermost/mattermost-server/dist') {
|
||||
step([$class: 'S3BucketPublisher', dontWaitForConcurrentBuildCompletion: false, entries: [[
|
||||
bucket: "releases.mattermost.com/mattermost-platform-pr/${BRANCH_NAME}",
|
||||
excludedFile: '',
|
||||
flatten: true,
|
||||
gzipFiles: false,
|
||||
keepForever: false,
|
||||
managedArtifacts: false,
|
||||
noUploadOnFailure: true,
|
||||
selectedRegion: 'us-east-1',
|
||||
showDirectlyInBrowser: false,
|
||||
sourceFile: '*.tar.gz',
|
||||
storageClass: 'STANDARD',
|
||||
uploadFromSlave: false,
|
||||
useServerSideEncryption: false,
|
||||
userMetadata: [[key: 'Cache-Control', value: 'no-cache']]
|
||||
]], profileName: 'Releases', userMetadAta: []])
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
stage('Clean checkout') {
|
||||
when {
|
||||
expression { env.CHANGE_ID != null }
|
||||
}
|
||||
// We need to perform a clean checkout here to ge the original git commit hash from the PR
|
||||
// Jenkins now merges master in top of the PR and this generate a new git hash
|
||||
// We need to do that to build the docker image based on the original git commit and then this will be used by
|
||||
// mattermod to update the test server.
|
||||
steps {
|
||||
sh """
|
||||
mkdir -p /tmp/mattermost-server
|
||||
"""
|
||||
dir('/tmp/mattermost-server') {
|
||||
checkout([$class: 'GitSCM', branches: [[name: 'FETCH_HEAD']],
|
||||
doGenerateSubmoduleConfigurations: false, extensions: [],
|
||||
submoduleCfg: [], userRemoteConfigs: [
|
||||
[refspec: "+refs/pull/${CHANGE_ID}/head:refs/remotes/origin/PR-${CHANGE_ID}",
|
||||
credentialsId: "310159d3-f7c5-4f5d-bfa1-151e3ef2db57",url: "https://github.com/mattermost/mattermost-server.git"]]])
|
||||
sh 'git rev-parse --short HEAD'
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
stage('Build Docker Image') {
|
||||
environment {
|
||||
GIT_COMMIT_SHORT = sh(
|
||||
script: "cd /tmp/mattermost-server && printf \$(git rev-parse --short HEAD)",
|
||||
returnStdout: true
|
||||
)
|
||||
}
|
||||
when {
|
||||
expression { env.CHANGE_ID != null }
|
||||
}
|
||||
steps {
|
||||
dir('src/github.com/mattermost/mattermost-server') {
|
||||
withCredentials([usernamePassword(credentialsId: 'matterbuild-docker-hub', usernameVariable: 'DOCKER_USER', passwordVariable: 'DOCKER_PASS')]) {
|
||||
sh 'docker login --username ${DOCKER_USER} --password ${DOCKER_PASS}'
|
||||
sh """
|
||||
docker build --no-cache --build-arg MM_PACKAGE=https://releases.mattermost.com/mattermost-platform-pr/${CHANGE_ID}/mattermost-enterprise-linux-amd64.tar.gz -t mattermost/mattermost-enterprise-edition:${GIT_COMMIT_SHORT} build
|
||||
docker push mattermost/mattermost-enterprise-edition:${GIT_COMMIT_SHORT}
|
||||
docker logout
|
||||
"""
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
post {
|
||||
|
||||
Ссылка в новой задаче
Block a user