2 Star 0 Fork 0

mirrors_rancher/jenkins-rancher-validations

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
Jenkinsfile-standalone-builder 3.43 KB
一键复制 编辑 原始数据 按行查看 历史
Mohamed El Sayed 提交于 2017-08-17 21:51 . Standalone host builder (#12)
#!groovy
// Get the AWS prefix if it exists
def aws_prefix() {
try { if ('' != AWS_PREFIX) { return AWS_PREFIX } }
catch (MissingPropertyException e) { return false }
}
// Stop the pipeline after provision / deprovision for QA to do something manual
def pipeline_provision_stop() {
try { if ('' != PIPELINE_PROVISION_STOP) { return PIPELINE_PROVISION_STOP } }
catch (MissingPropertyException e) { return false }
}
def pipeline_deprovision_stop() {
try { if ('' != PIPELINE_DEPROVISION_STOP) { return PIPELINE_DEPROVISION_STOP } }
catch (MissingPropertyException e) { return false }
}
// SLACK_CHANNEL resolution is first via Jenkins Build Parameter SLACK_CHANNEL fed in from console,
// then from $DOCKER_TRIGGER_TAG which is sourced from the Docker Hub Jenkins plugin webhook.
def slack_channel() {
try { if ('' != SLACK_CHANNEL) { return SLACK_CHANNEL } }
catch (MissingPropertyException e) { return '#ci_cd' }
}
// simplify the generation of Slack notifications for start and finish of Job
def jenkinsSlack(type) {
channel = slack_channel()
aws_prefix = aws_prefix()
def jobInfo = "\n » ${aws_prefix} :: ${JOB_NAME} #${env.BUILD_NUMBER} (<${env.BUILD_URL}|job>) (<${env.BUILD_URL}/console|console>)"
if (type == 'start'){
slackSend channel: channel, color: 'blue', message: "build started${jobInfo}"
}
if (type == 'finish'){
def buildColor = currentBuild.result == null? "good": "warning"
def buildStatus = currentBuild.result == null? "SUCCESS": currentBuild.result
def msg = "build finished - ${buildStatus}${jobInfo}"
slackSend channel: channel, color: buildColor, message: "${msg}"
}
}
def lastBuildResult() {
def previous_build = currentBuild.getPreviousBuild()
if ( null != previous_build ) { return previous_build.result } else { return 'UKNOWN' }
}
try {
node {
wrap([$class: 'AnsiColorBuildWrapper', 'colorMapName': 'XTerm', 'defaultFg': 2, 'defaultBg':1]) {
jenkinsSlack('start')
checkout scm
stage('bootstrap') {
sh "./scripts/bootstrap.sh"
}
stage ('syntax') {
sh "docker run --rm " +
"-v jenkins_home:/var/jenkins_home " +
"rancherlabs/ci-validation-tests /bin/bash -c \'cd \"\$(pwd)\" && invoke syntax\'"
}
stage ('lint') {
sh "docker run --rm " +
"-v jenkins_home:/var/jenkins_home " +
"rancherlabs/ci-validation-tests /bin/bash -c \'cd \"\$(pwd)\" && invoke lint\'"
}
stage ('configure .env file') {
withEnv(["RANCHER_ORCHESTRATION=StandAlone", "RANCHER_VERSION=SA", "RANCHER_SERVER_OPERATINGSYSTEM=${RANCHER_AGENT_OPERATINGSYSTEM}"]) {
sh "./scripts/configure.sh"
}
}
stage ('deprovision Rancher Agents') {
sh "docker run --rm " +
"-v jenkins_home:/var/jenkins_home " +
"--env-file .env " +
"rancherlabs/ci-validation-tests /bin/bash -c \'cd \"\$(pwd)\" && invoke rancher_agents.deprovision\'"
}
if ( "false" == "${PIPELINE_DEPROVISION_STOP}" ) {
stage ('provision Standalone Rancher Agents') {
sh "docker run --rm " +
"-v jenkins_home:/var/jenkins_home " +
"--env-file .env " +
"rancherlabs/ci-validation-tests /bin/bash -c \'cd \"\$(pwd)\" && invoke rancher_agents.provisionstandalone\'"
}
} // PIPELINE_DEPROVISION_STOP
} // wrap
} // node
} catch(err) { currentBuild.result = 'FAILURE' }
jenkinsSlack('finish')
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/mirrors_rancher/jenkins-rancher-validations.git
git@gitee.com:mirrors_rancher/jenkins-rancher-validations.git
mirrors_rancher
jenkins-rancher-validations
jenkins-rancher-validations
master

搜索帮助