git支持tag标签发布

This commit is contained in:
赵连启 2019-02-28 22:39:51 +08:00
parent 95dc05661a
commit 5a32a0fb88
8 changed files with 117 additions and 4 deletions

View File

@ -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协议支持

View File

@ -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
}
}

View File

@ -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{})

View File

@ -1,5 +1,7 @@
//获取分支
exports.branch = "/api/get/git/branch"
//获取tag
exports.getTag = "/api/get/git/tag"
//获取提交
exports.commit = "/api/get/git/commit"

View File

@ -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"

View File

@ -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;">
@ -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>
@ -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

View File

@ -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"

View File

@ -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="包地址:">