mozillians/Jenkinsfile

72 строки
2.3 KiB
Plaintext
Исходник Обычный вид История

2017-06-16 19:01:09 +03:00
node('master'){
2017-06-21 21:26:03 +03:00
def params
2017-06-16 19:01:09 +03:00
switch(env.BRANCH_NAME) {
case "master":
environment = "staging"
app_id_group = "/staging/"
break
case "production":
environment = "production"
app_id_group = ""
break
case "cistest":
environment = "cistest"
app_id_group = "/staging/"
break
2017-06-16 19:01:09 +03:00
default:
print "Invalid branch"
currentBuild.result = "FAILURE"
throw err
break
}
type = 'group'
2018-02-09 16:56:54 +03:00
slackSend channel: '#oi-parsys,#iam-bots', color: 'good', message: "Starting build ${BUILD_NUMBER} for ${JOB_NAME} ${environment} | <${BUILD_URL}changes | Changes>"
2017-06-16 19:01:09 +03:00
}
node('mesos') {
def image
def app_id = (environment == "cistest") ? "mozillianscistest" : "mozillians"
2017-06-16 19:01:09 +03:00
def dockerRegistry = "docker-registry.ops.mozilla.community:443"
stage('Prep') {
checkout scm
gitCommit = sh(returnStdout: true, script: 'git rev-parse HEAD').trim()
params = [string(name: 'environment', value: "production"),
string(name: 'commit_id', value: gitCommit),
string(name: 'marathon_id', value: app_id_group + app_id),
string(name: 'marathon_config', value: 'mozillians_' + environment + '.json'),
string(name: 'type', value: 'group')]
}
stage('Build') {
2017-08-21 12:25:40 +03:00
try {
image = docker.build(app_id + ":" + gitCommit, "-f docker/prod .")
}
catch(e) {
currentBuild.result = "FAILURE"
2018-02-09 16:56:54 +03:00
slackSend channel: '#oi-parsys,#iam-bots', color: 'bad', message: "Error building ${JOB_NAME} ${BUILD_NUMBER} | <${BUILD_URL}console | Console>"
2017-08-21 12:25:40 +03:00
throw e
}
2017-06-16 19:01:09 +03:00
}
stage('Push') {
2017-08-21 12:25:40 +03:00
try {
sh "docker tag ${image.imageName()} " + dockerRegistry + "/${image.imageName()}"
sh "docker push " + dockerRegistry + "/${image.imageName()}"
}
catch(e) {
currentBuild.result = "FAILURE"
2018-02-09 16:56:54 +03:00
slackSend channel: '#oi-parsys,#iam-bots', color: 'bad', message: "Error pushing ${JOB_NAME} ${BUILD_NUMBER} | <${BUILD_URL}console | Console>"
2017-08-21 12:25:40 +03:00
throw e
}
2017-06-16 19:01:09 +03:00
}
}
node('master') {
stage('Deploy') {
parallel (
"deploy": { build job: 'deploy-test', parameters: params }
)
2017-06-16 19:01:09 +03:00
}
}