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

Commit

Permalink
git支持tag标签发布
Browse files Browse the repository at this point in the history
  • Loading branch information
赵连启 committed Feb 28, 2019
1 parent 95dc056 commit 5a32a0f
Show file tree
Hide file tree
Showing 8 changed files with 117 additions and 4 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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协议支持
Expand Down
32 changes: 32 additions & 0 deletions src/controllers/walle/tag.go
Original file line number Diff line number Diff line change
@@ -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
}

}
1 change: 1 addition & 0 deletions src/routers/router.go
Original file line number Diff line number Diff line change
Expand Up @@ -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{})

Expand Down
2 changes: 2 additions & 0 deletions vue-gopub/src/common/port_uri/git.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
//获取分支
exports.branch = "/api/get/git/branch"
//获取tag
exports.getTag = "/api/get/git/tag"
//获取提交
exports.commit = "/api/get/git/commit"

Expand Down
5 changes: 4 additions & 1 deletion vue-gopub/src/pages/task/base.vue
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,11 @@
width="180">
</el-table-column>
<el-table-column
prop="branch"
label="分支">
<template scope="props">
<el-tag v-if="props.row.branch===''" type="success">Tag发布</el-tag>
<el-tag v-else type="info">{{props.row.branch}}</el-tag>
</template>
</el-table-column>
<el-table-column
prop="commit_id"
Expand Down
65 changes: 65 additions & 0 deletions vue-gopub/src/pages/task/git.vue
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,29 @@
<el-form-item label="上线单标题:" prop="Title">
<el-input v-model="form.Title" placeholder="请输入标题" style="width: 500px;"></el-input>
</el-form-item>
<el-form-item label="发布方式:" prop="isShowValue">
<el-radio-group v-model="isShowValue" @change="showStatus">
<el-radio :label="1">tag发布</el-radio>
<el-radio :label="2">分支发布</el-radio>
</el-radio-group>
</el-form-item>
<div v-if="isShowStatus">
<el-form-item label="选取tag:" prop="CommitId" label-width="100px">
<el-select v-model="form.CommitId" filterable placeholder="请选择"
style="width: 400px;">
<el-option
v-for="item in tagData"
:key="item.value"
:label="item.label"
:value="item.value">
</el-option>
</el-select>
<el-button @click.stop="get_tag_data" size="small">
<i class="fa fa-refresh"></i>
</el-button>
</el-form-item>
</div>
<div v-else>
<el-form-item label="选取分支:" prop="Branch" label-width="100px">
<el-select v-model="form.Branch" filterable placeholder="请选择" @change="get_commit"
style="width: 400px;">
Expand All @@ -34,6 +57,7 @@
</el-option>
</el-select>
</el-form-item>
</div>
<el-form-item label="灰度发布 :" >
<el-switch v-model="isShowHost" on-text="on" off-text="off">灰度发布</el-switch>
<div>
Expand Down Expand Up @@ -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,
Expand All @@ -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'}]
Expand All @@ -95,6 +124,7 @@
created(){
if (this.route_id) {
this.get_tag_data()
this.get_branch_data()
this.get_Project_data()
} else {
Expand Down Expand Up @@ -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) => {
Expand Down Expand Up @@ -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
Expand Down
5 changes: 4 additions & 1 deletion vue-gopub/src/pages/task/mylist.vue
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,11 @@
width="180">
</el-table-column>
<el-table-column
prop="branch"
label="分支">
<template scope="props">
<el-tag v-if="props.row.branch===''" type="success">Tag发布</el-tag>
<el-tag v-else type="info">{{props.row.branch}}</el-tag>
</template>
</el-table-column>
<el-table-column
prop="commit_id"
Expand Down
9 changes: 8 additions & 1 deletion vue-gopub/src/pages/task/release.vue
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,19 @@
{{task.Title}}
</el-form-item>
<span v-if='project.RepoType=="git"'>
<el-form-item label="分支:">
<div v-if="task.Branch===''">
<el-form-item label="Tag标签:">
{{task.CommitId}}
</el-form-item>
</div>
<div v-else>
<el-form-item label="分支:">
{{task.Branch}}
</el-form-item>
<el-form-item label="哈希:">
{{task.CommitId}}
</el-form-item>
</div>
</span>
<span v-if='project.RepoType=="file"'>
<el-form-item label="包地址:">
Expand Down

0 comments on commit 5a32a0f

Please sign in to comment.