Skip to content
This repository was archived by the owner on Jan 10, 2023. It is now read-only.

Commit 5a32a0f

Browse files
author
赵连启
committed
git支持tag标签发布
1 parent 95dc056 commit 5a32a0f

File tree

8 files changed

+117
-4
lines changed

8 files changed

+117
-4
lines changed

README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ gopub已持续运行近两年时间,在我们预发布和生产环境完成37000
2020
## 功能特性
2121
* Docker&k8s支持:Docker镜像仅60M,kubernetes编排文件一键部署运行
2222
* 部署简便:go二进制部署,无需安装运行环境.
23-
* gitlab发布支持:配置每个项目git地址,自动获取分支,commit选择并自动拉取代码
23+
* gitlab发布支持:配置每个项目git地址,自动获取分支/tag,commit选择并自动拉取代码
2424
* jenkins发布支持:支持jenkins可选build history一键发布
2525
* ssh执行命令/传输文件:使用golang内置ssh库高效执行命令/传输文件
2626
* BT支持:大文件和大批量机器文件传输使用BT协议支持

src/controllers/walle/tag.go

+32
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
package wallecontrollers
2+
3+
import (
4+
"controllers"
5+
"library/components"
6+
"models"
7+
)
8+
9+
type TagController struct {
10+
controllers.BaseController
11+
}
12+
13+
func (c *TagController) Get() {
14+
if c.Project == nil || c.Project.Id == 0 {
15+
c.SetJson(1, nil, "Parameter error")
16+
return
17+
}
18+
s := components.BaseComponents{}
19+
s.SetProject(c.Project)
20+
s.SetTask(&models.Task{})
21+
g := components.BaseGit{}
22+
g.SetBaseComponents(s)
23+
res, err := g.GetTagList(200)
24+
if err != nil {
25+
c.SetJson(1, nil, "获取tag错误—"+err.Error())
26+
return
27+
} else {
28+
c.SetJson(0, res, "")
29+
return
30+
}
31+
32+
}

src/routers/router.go

+1
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@ func init() {
4949
beego.Router("/api/get/git/commit", &wallecontrollers.CommitController{})
5050
beego.Router("/api/get/git/gitpull", &wallecontrollers.GitpullController{})
5151
beego.Router("/api/get/git/gitlog", &wallecontrollers.GitlogController{})
52+
beego.Router("/api/get/git/tag", &wallecontrollers.TagController{})
5253

5354
beego.Router("/api/get/jenkins/commit", &wallecontrollers.JenkinsController{})
5455

vue-gopub/src/common/port_uri/git.js

+2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
//获取分支
22
exports.branch = "/api/get/git/branch"
3+
//获取tag
4+
exports.getTag = "/api/get/git/tag"
35
//获取提交
46
exports.commit = "/api/get/git/commit"
57

vue-gopub/src/pages/task/base.vue

+4-1
Original file line numberDiff line numberDiff line change
@@ -45,8 +45,11 @@
4545
width="180">
4646
</el-table-column>
4747
<el-table-column
48-
prop="branch"
4948
label="分支">
49+
<template scope="props">
50+
<el-tag v-if="props.row.branch===''" type="success">Tag发布</el-tag>
51+
<el-tag v-else type="info">{{props.row.branch}}</el-tag>
52+
</template>
5053
</el-table-column>
5154
<el-table-column
5255
prop="commit_id"

vue-gopub/src/pages/task/git.vue

+65
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,29 @@
1010
<el-form-item label="上线单标题:" prop="Title">
1111
<el-input v-model="form.Title" placeholder="请输入标题" style="width: 500px;"></el-input>
1212
</el-form-item>
13+
<el-form-item label="发布方式:" prop="isShowValue">
14+
<el-radio-group v-model="isShowValue" @change="showStatus">
15+
<el-radio :label="1">tag发布</el-radio>
16+
<el-radio :label="2">分支发布</el-radio>
17+
</el-radio-group>
18+
</el-form-item>
19+
<div v-if="isShowStatus">
20+
<el-form-item label="选取tag:" prop="CommitId" label-width="100px">
21+
<el-select v-model="form.CommitId" filterable placeholder="请选择"
22+
style="width: 400px;">
23+
<el-option
24+
v-for="item in tagData"
25+
:key="item.value"
26+
:label="item.label"
27+
:value="item.value">
28+
</el-option>
29+
</el-select>
30+
<el-button @click.stop="get_tag_data" size="small">
31+
<i class="fa fa-refresh"></i>
32+
</el-button>
33+
</el-form-item>
34+
</div>
35+
<div v-else>
1336
<el-form-item label="选取分支:" prop="Branch" label-width="100px">
1437
<el-select v-model="form.Branch" filterable placeholder="请选择" @change="get_commit"
1538
style="width: 400px;">
@@ -34,6 +57,7 @@
3457
</el-option>
3558
</el-select>
3659
</el-form-item>
60+
</div>
3761
<el-form-item label="灰度发布 :" >
3862
<el-switch v-model="isShowHost" on-text="on" off-text="off">灰度发布</el-switch>
3963
<div>
@@ -69,12 +93,16 @@
6993
return {
7094
commitData: [],
7195
branchData: [],
96+
tagData: [],
7297
isShowHost:false,
98+
isShowStatus:false,
7399
Hosts:[],
74100
selectHosts:[],
75101
ProjectData:null,
102+
isShowValue: 2,
76103
form: {
77104
Branch: null,
105+
Tag: null,
78106
Title: null,
79107
CommitId: null,
80108
Hosts:null,
@@ -86,6 +114,7 @@
86114
load_data: false,
87115
on_submit_loading: false,
88116
rules: {
117+
Tag: [{required: true, message: '分支不能为空', trigger: 'blur'}],
89118
Branch: [{required: true, message: '分支不能为空', trigger: 'blur'}],
90119
CommitId: [{required: true, message: 'Commit不能为空', trigger: 'blur'}],
91120
Title: [{required: true, message: '标题不能为空', trigger: 'blur'}]
@@ -95,6 +124,7 @@
95124
created(){
96125
97126
if (this.route_id) {
127+
this.get_tag_data()
98128
this.get_branch_data()
99129
this.get_Project_data()
100130
} else {
@@ -184,6 +214,30 @@
184214
this.load_data = false
185215
})
186216
},
217+
get_tag_data(){
218+
this.load_data = true
219+
this.$http.get(port_git.getTag, {
220+
params: {
221+
projectId: this.form.ProjectId
222+
}
223+
})
224+
.then(({data: {data}}) => {
225+
var tagData = []
226+
for(var i in data)
227+
{
228+
if( data[i].id !== "") {
229+
tagData.push({label: data[i].message, value: data[i].id})
230+
}
231+
}
232+
console.log('--->', tagData)
233+
this.tagData = tagData
234+
this.load_data = false
235+
})
236+
.
237+
catch(() => {
238+
this.load_data = false
239+
})
240+
},
187241
//提交
188242
on_submit_form(){
189243
this.$refs.form.validate((valid) => {
@@ -215,7 +269,18 @@
215269
this.on_submit_loading = false
216270
})
217271
})
272+
},
273+
showStatus(){
274+
if (this.isShowValue === 1){
275+
this.isShowStatus = true
276+
this.form.CommitId = null
277+
this.form.Branch = null
278+
} else {
279+
this.isShowStatus = false
280+
this.form.CommitId = null
281+
this.form.Branch = null
218282
}
283+
}
219284
},
220285
components: {
221286
panelTitle

vue-gopub/src/pages/task/mylist.vue

+4-1
Original file line numberDiff line numberDiff line change
@@ -44,8 +44,11 @@
4444
width="180">
4545
</el-table-column>
4646
<el-table-column
47-
prop="branch"
4847
label="分支">
48+
<template scope="props">
49+
<el-tag v-if="props.row.branch===''" type="success">Tag发布</el-tag>
50+
<el-tag v-else type="info">{{props.row.branch}}</el-tag>
51+
</template>
4952
</el-table-column>
5053
<el-table-column
5154
prop="commit_id"

vue-gopub/src/pages/task/release.vue

+8-1
Original file line numberDiff line numberDiff line change
@@ -11,12 +11,19 @@
1111
{{task.Title}}
1212
</el-form-item>
1313
<span v-if='project.RepoType=="git"'>
14-
<el-form-item label="分支:">
14+
<div v-if="task.Branch===''">
15+
<el-form-item label="Tag标签:">
16+
{{task.CommitId}}
17+
</el-form-item>
18+
</div>
19+
<div v-else>
20+
<el-form-item label="分支:">
1521
{{task.Branch}}
1622
</el-form-item>
1723
<el-form-item label="哈希:">
1824
{{task.CommitId}}
1925
</el-form-item>
26+
</div>
2027
</span>
2128
<span v-if='project.RepoType=="file"'>
2229
<el-form-item label="包地址:">

0 commit comments

Comments
 (0)