1 Star 0 Fork 0

小小梦想--/CloudClass-Android

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
Jenkinsfile_bitbucket.groovy 3.56 KB
一键复制 编辑 原始数据 按行查看 历史
陈镜吾 提交于 2021-06-17 18:29 . release release/apaas/1.1.2
// -*- mode: groovy -*-
// vim: set filetype=groovy :
import groovy.transform.Field
import hudson.model.Result
import jenkins.model.CauseOfInterruption
import org.jenkinsci.plugins.workflow.steps.FlowInterruptedException
@Library('agora-build-pipeline-library') _
@Field def release_branch_pattern = ~/^release\/(\d+.\d+.\d+(.\d)?)_[a-z]+$|arsenal/
@Field def repo_name = "cloudclass-android"
@Field def repo_branch = ""
withWechatNotify {
withKnownErrorHandling {
timestamps {
repo_branch = env.CHANGE_BRANCH ?: env.BRANCH_NAME
abortPreviousRunningBuilds()
def build_params = [
string(name: 'build_branch', value: repo_branch),
string(name: 'ci_branch', value: 'master'),
string(name: 'build_env', value: 'dev'),
booleanParam(name: 'Package_Publish', value: false),
]
parallel( AndroidBuild: {
stage('Compile on Android') {
build job: 'AD/Agora-CloudClass-Android', parameters: build_params, wait: true
}
}, failFast: true)
}
}
}
def withKnownErrorHandling(Closure block) {
def utils = new agora.build.Utils()
try {
block()
currentBuild.result = "SUCCESS"
} catch (Exception ex) {
currentBuild.result = "FAILURE"
throw ex
}
}
def currentCommitHash() {
return commitHashForBuild( currentJenkinsBuild() )
}
@NonCPS
def currentJenkinsBuild() {
def job = Jenkins.instance.getItemByFullName( env.JOB_NAME )
return job.getBuild( env.BUILD_ID )
}
@NonCPS
def commitHashForBuild( build ) {
def scmAction = build?.actions.find { action -> action instanceof jenkins.scm.api.SCMRevisionAction }
return scmAction?.revision?.hasProperty('hash') ? scmAction?.revision?.hash : scmAction?.revision
}
def abortPreviousRunningBuilds() {
Hudson.instance.getItemByFullName(env.JOB_NAME)?.getBuilds().each{ build ->
def exec = build.getExecutor()
if (build.number != currentBuild.number && exec != null ) {
exec.interrupt(
Result.ABORTED,
new CauseOfInterruption.UserInterruption( "Aborted by #${currentBuild.number}" )
)
println("Aborted previous running build #${build.number}")
}
}
}
def withWechatNotify(Closure block) {
try {
block()
} catch (FlowInterruptedException fie) {
echo "Info: Cancelled by afterwards build, ignore warning."
} catch (Exception ex) {
if (repo_branch ==~ release_branch_pattern ) {
head = '<font color=\\"red\\">Main Branch failed </font>. Please deal with them as soon as possible.\\n'
branch = ">**${env.BRANCH_NAME}**" + '\\n'
url = ">[${env.RUN_DISPLAY_URL}](${env.RUN_DISPLAY_URL})" + '\\n'
exeception = ">Info: ${ex.toString()}"
content = "${head}${branch}${url}${exeception}"
def payload = """
{
"msgtype": "markdown",
"markdown": {
"content": \"${content}\"
}
}
"""
httpRequest httpMode: 'POST',
acceptType: 'APPLICATION_JSON_UTF8',
contentType: 'APPLICATION_JSON_UTF8',
ignoreSslErrors: true, responseHandle: 'STRING',
requestBody: payload,
url: "https://qyapi.weixin.qq.com/cgi-bin/webhook/send?key=6742e321-b00b-4efb-9c76-456a5b59e867"
}
throw ex
}
}
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/naojiangzhalie666/CloudClass-Android.git
git@gitee.com:naojiangzhalie666/CloudClass-Android.git
naojiangzhalie666
CloudClass-Android
CloudClass-Android
master

搜索帮助