golang--syncd快速发布脚本

起因

公司使用syncd搭建的发布系统,在有时候需要发布的时候需要进行一系列繁琐的操作才能发布代码。思考如何命令行一键快速发布。

研究

通过抓公司页面得到发布的关键接口。

  • 登录
    api/login

参数

参数名备注
username
passwordmd5

返回

type ResData struct {
	Code    int    `json:"code"`
	Data    Data   `json:"data"`
	Message string `json:"message"`
}
type Data struct {
	Token string `json:"token"`
}
  • 查看空间列表
    api/project/space/list
参数名备注
tokenlogin返回
offset:分页
limit:个数
type ResData struct {
	Code    int    `json:"code"`
	Data    Data   `json:"data"`
	Message string `json:"message"`
}
type List struct {
	ID          int    `json:"id"`
	Name        string `json:"name"`
	Description string `json:"description"`
	Ctime       int    `json:"ctime"`
}
type Data struct {
	List  []List `json:"list"`
	Total int    `json:"total"`
}
  • 查看项目列表
    api/project/list
    参数
参数名备注
spaceId空间ID
offset:分页
limit:每页条数
tokenlogin返回
type ResData struct {
	Code    int    `json:"code"`
	Data    Data   `json:"data"`
	Message string `json:"message"`
}
type List struct {
	ID        int    `json:"id"`
	Name      string `json:"name"`
	NeedAudit int    `json:"need_audit"` 
	Status    int    `json:"status"`
}
type Data struct {
	List  []List `json:"list"`
	Total int    `json:"total"`
}
  • 查看所有项目列表
    api/deploy/apply/project/all
参数名备注
tokenlogin返回
type ResData []struct {
	ProjectID   int    `json:"project_id"`
	ProjectName string `json:"project_name"`
	SpaceID     int    `json:"space_id"`
	SpaceName   string `json:"space_name"`
}
  • 构建任务
    api/deploy/build/start
    参数
参数名备注
id项目ID
  • 查看构建状态
    api/deploy/build/status
    参数
参数名备注
id项目ID

返回

map[string]interface{}

在这里插入图片描述
status 解释

	BUILD_STATUS_INIT    = 0
	BUILD_STATUS_RUNNING = 1
	BUILD_STATUS_DONE    = 2
	BUILD_STATUS_ERROR   = 3
  • 部署任务
    api/deploy/deploy/start
    参数
参数名备注
id项目ID
  • 部署状态
    api/deploy/deploy/status
    参数
参数名备注
id项目ID

在这里插入图片描述
status 解释

    DEPLOY_STATUS_NONE = 0
    DEPLOY_STATUS_START = 1
    DEPLOY_STATUS_SUCCESS = 2
    DEPLOY_STATUS_FAILED = 3

所以根据以上写出代码
代码放在github了
github地址:syncd-console

1.做了项目名模糊查询
2.未做回滚功能

效果

在这里插入图片描述
在这里插入图片描述

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值