From 5a32a0fb8862d5fd040b4121be22b2927f123f32 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=B5=B5=E8=BF=9E=E5=90=AF?= Date: Thu, 28 Feb 2019 22:39:51 +0800 Subject: [PATCH] =?UTF-8?q?git=E6=94=AF=E6=8C=81tag=E6=A0=87=E7=AD=BE?= =?UTF-8?q?=E5=8F=91=E5=B8=83?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- README.md | 2 +- src/controllers/walle/tag.go | 32 ++++++++++++++ src/routers/router.go | 1 + vue-gopub/src/common/port_uri/git.js | 2 + vue-gopub/src/pages/task/base.vue | 5 ++- vue-gopub/src/pages/task/git.vue | 65 ++++++++++++++++++++++++++++ vue-gopub/src/pages/task/mylist.vue | 5 ++- vue-gopub/src/pages/task/release.vue | 9 +++- 8 files changed, 117 insertions(+), 4 deletions(-) create mode 100644 src/controllers/walle/tag.go diff --git a/README.md b/README.md index e2454b7..9922dfb 100644 --- a/README.md +++ b/README.md @@ -20,7 +20,7 @@ gopub已持续运行近两年时间,在我们预发布和生产环境完成37000 ## 功能特性 * Docker&k8s支持:Docker镜像仅60M,kubernetes编排文件一键部署运行 * 部署简便:go二进制部署,无需安装运行环境. -* gitlab发布支持:配置每个项目git地址,自动获取分支,commit选择并自动拉取代码 +* gitlab发布支持:配置每个项目git地址,自动获取分支/tag,commit选择并自动拉取代码 * jenkins发布支持:支持jenkins可选build history一键发布 * ssh执行命令/传输文件:使用golang内置ssh库高效执行命令/传输文件 * BT支持:大文件和大批量机器文件传输使用BT协议支持 diff --git a/src/controllers/walle/tag.go b/src/controllers/walle/tag.go new file mode 100644 index 0000000..118a4a4 --- /dev/null +++ b/src/controllers/walle/tag.go @@ -0,0 +1,32 @@ +package wallecontrollers + +import ( + "controllers" + "library/components" + "models" +) + +type TagController struct { + controllers.BaseController +} + +func (c *TagController) Get() { + if c.Project == nil || c.Project.Id == 0 { + c.SetJson(1, nil, "Parameter error") + return + } + s := components.BaseComponents{} + s.SetProject(c.Project) + s.SetTask(&models.Task{}) + g := components.BaseGit{} + g.SetBaseComponents(s) + res, err := g.GetTagList(200) + if err != nil { + c.SetJson(1, nil, "获取tag错误—"+err.Error()) + return + } else { + c.SetJson(0, res, "") + return + } + +} diff --git a/src/routers/router.go b/src/routers/router.go index a333ac0..a16913f 100644 --- a/src/routers/router.go +++ b/src/routers/router.go @@ -49,6 +49,7 @@ func init() { beego.Router("/api/get/git/commit", &wallecontrollers.CommitController{}) beego.Router("/api/get/git/gitpull", &wallecontrollers.GitpullController{}) beego.Router("/api/get/git/gitlog", &wallecontrollers.GitlogController{}) + beego.Router("/api/get/git/tag", &wallecontrollers.TagController{}) beego.Router("/api/get/jenkins/commit", &wallecontrollers.JenkinsController{}) diff --git a/vue-gopub/src/common/port_uri/git.js b/vue-gopub/src/common/port_uri/git.js index eb82ee9..c74da5c 100644 --- a/vue-gopub/src/common/port_uri/git.js +++ b/vue-gopub/src/common/port_uri/git.js @@ -1,5 +1,7 @@ //获取分支 exports.branch = "/api/get/git/branch" +//获取tag +exports.getTag = "/api/get/git/tag" //获取提交 exports.commit = "/api/get/git/commit" diff --git a/vue-gopub/src/pages/task/base.vue b/vue-gopub/src/pages/task/base.vue index 5b2542d..705f3f7 100644 --- a/vue-gopub/src/pages/task/base.vue +++ b/vue-gopub/src/pages/task/base.vue @@ -45,8 +45,11 @@ width="180"> + + + + tag发布 + 分支发布 + + +
+ + + + + + + + + +
+
@@ -34,6 +57,7 @@ +
灰度发布
@@ -69,12 +93,16 @@ return { commitData: [], branchData: [], + tagData: [], isShowHost:false, + isShowStatus:false, Hosts:[], selectHosts:[], ProjectData:null, + isShowValue: 2, form: { Branch: null, + Tag: null, Title: null, CommitId: null, Hosts:null, @@ -86,6 +114,7 @@ load_data: false, on_submit_loading: false, rules: { + Tag: [{required: true, message: '分支不能为空', trigger: 'blur'}], Branch: [{required: true, message: '分支不能为空', trigger: 'blur'}], CommitId: [{required: true, message: 'Commit不能为空', trigger: 'blur'}], Title: [{required: true, message: '标题不能为空', trigger: 'blur'}] @@ -95,6 +124,7 @@ created(){ if (this.route_id) { + this.get_tag_data() this.get_branch_data() this.get_Project_data() } else { @@ -184,6 +214,30 @@ this.load_data = false }) }, + get_tag_data(){ + this.load_data = true + this.$http.get(port_git.getTag, { + params: { + projectId: this.form.ProjectId + } + }) + .then(({data: {data}}) => { + var tagData = [] + for(var i in data) + { + if( data[i].id !== "") { + tagData.push({label: data[i].message, value: data[i].id}) + } + } + console.log('--->', tagData) + this.tagData = tagData + this.load_data = false + }) + . + catch(() => { + this.load_data = false + }) + }, //提交 on_submit_form(){ this.$refs.form.validate((valid) => { @@ -215,7 +269,18 @@ this.on_submit_loading = false }) }) + }, + showStatus(){ + if (this.isShowValue === 1){ + this.isShowStatus = true + this.form.CommitId = null + this.form.Branch = null + } else { + this.isShowStatus = false + this.form.CommitId = null + this.form.Branch = null } + } }, components: { panelTitle diff --git a/vue-gopub/src/pages/task/mylist.vue b/vue-gopub/src/pages/task/mylist.vue index ed08a8d..ca8368b 100644 --- a/vue-gopub/src/pages/task/mylist.vue +++ b/vue-gopub/src/pages/task/mylist.vue @@ -44,8 +44,11 @@ width="180"> + - +
+ + {{task.CommitId}} + +
+
+ {{task.Branch}} {{task.CommitId}} +