package
0.0.0-20240402064421-6a6ccb368c42
Repository: https://github.com/tqtcloud/workflow-backend.git
Documentation: pkg.go.dev

# README

jenkins API 模块

Create Job Post

请求:

{
    "jobName":"apijob0925",
    "create_by":"xxx",
    "env":"DEV",
    "gitUrl": "https://github.com/tqtcloud/workflow-backend.git",
    "branch": "sit",
    "description": "0925 test api job",
    "appName": "apijob0925",
    //buildeshell 此处可不填,应用模板的打包命令  postman提交的时候请删除
    //"buildeshell": "echo 1111",
    "folder": "test2",
    "templateName": "jobtemplate/job/go-backend-template"
}

字段解释

参数名类型描述默认值是否必须
jobNamestringjenkins job 名称默认为空must
create_bystring任务发起创建人默认为空must
envstringJenkins环境:dev,qa,uat,lpt,prod默认为空must
gitUrlstringGit 地址默认为空must
branchstringGit 默认分支默认为空must
descriptionstringjob 描述信息默认为空must
appNamestring应用名称默认为空must
buildeshellstring打包shell默认为templateoptional
folderstringjenkins 文件夹默认为空must
templateNamestring基于的jenkins模板job默认为空must

注意:

templateName字段为job类型模板字段,按照现有思路作为一个固定参数由前端直接传递

例如:前端为一个下拉框,可以选择后端模板为:go,Java,nodejs等

正常返回

{
    "code": 0,
    "data": {
        "id": "cco15vbehud2k23mhs10",
        "create_at": 1664094973994602,
        "update_at": 0,
        "update_by": "",
        "data": {
            "create_by": "tqt",
            "jobName": "apijob0925",
            "Env": "DEV",
            "gitUrl": "https://github.com/tqtcloud/workflow-backend.git",
            "branch": "sit",
            "appName": "apijob0925",
            "description": "0925 test api job",
            "buildeshell": "",
            "buildenv": "",
            "folder": "test2",
            "oldjobName": "",
            "newjobName": "",
            "templateName": "jobtemplate/job/go-backend-template"
        }
    }
}

Get Job Get

请求:

# 访问地址:/workflow-backend/api/v1/task/{env}/{folder}/{jobname}
例如:
http://127.0.0.1:8050/workflow-backend/api/v1/task/dev/test2/apideljob111

字段解释

参数名类型描述默认值是否必须
jobnamestringjenkins job 名称默认为空must
envstringJenkins环境:dev,qa,uat,lpt,prod默认为空must
folderstringjenkins 文件夹默认为空must

注意:

如果你不写放回 404

删除 jenkins 根的job {folder} 置 root

http://127.0.0.1:8050/workflow-backend/api/v1/task/dev/root/apideljob111

正常返回

{
    "code": 0,
    "data": {
        "id": "9cf81a77-eea0-41dc-8519-afeecfbf065d",
        "create_at": 1664359420914578,
        "update_at": 0,
        "update_by": "",
        "data": {
            "create_by": "",
            "jobName": "test2/job/apijob0927",
            "Env": "DEV",
            "gitUrl": "https://github.com/tqtcloud/workflow-backend.git",
            "branch": "sit",
            "appName": "apijob0927",
            "description": "api调用测试job,请勿启动运行",
            "buildeshell": "echo 1111",
            "buildenv": "",
            "folder": "test2",
            "oldjobName": "",
            "newjobName": "",
            "templateName": ""
        }
    }
}

Delete Job Get

请求:

# 访问地址:/workflow-backend/api/v1/task/{env}/{folder}/{jobname}
例如:
http://127.0.0.1:8050/workflow-backend/api/v1/task/dev/test2/apideljob111

字段解释

参数名类型描述默认值是否必须
jobnamestringjenkins job 名称默认为空must
envstringJenkins环境:dev,qa,uat,lpt,prod默认为空must
folderstringjenkins 文件夹默认为空must

注意:

如果你不写放回 404

删除 jenkins 根的job {folder} 置 root

http://127.0.0.1:8050/workflow-backend/api/v1/task/dev/root/apideljob111

正常返回

{
    "code": 0,
    "data": {
        "id": "9cf81a77-eea0-41dc-8519-afeecfbf065d",
        "create_at": 1664359420914578,
        "update_at": 0,
        "update_by": "",
        "data": {
            "create_by": "",
            "jobName": "test2/job/apijob0927",
            "Env": "DEV",
            "gitUrl": "https://github.com/tqtcloud/workflow-backend.git",
            "branch": "sit",
            "appName": "apijob0927",
            "description": "api调用测试job,请勿启动运行",
            "buildeshell": "echo 1111",
            "buildenv": "",
            "folder": "test2",
            "oldjobName": "",
            "newjobName": "",
            "templateName": ""
        }
    }
}

Update Job Patch

请求:

# 访问地址:/workflow-backend/api/v1/task/{env}/{folder}/{jobname}
例如:
http://127.0.0.1:8050/workflow-backend/api/v1/task/dev/test2/apideljob111
{
    "jobName":"apijob0927",
    "create_by":"tqt44444",
    "env":"test",
    "branch": "sit",
    "gitUrl": "https://github.com/tqtcloud/workflow-backend.git",
    "description": "api调用测试job,请勿启动运行44444put",
    "appName": "apijob0927",
    "buildeshell": "echo api调用测试job,请勿启动运行44444put",
    "folder": "test2",
    "templateName": "apijob0927"
}

字段解释

参数名类型描述默认值是否必须
jobNamestringjenkins job 名称默认为空must
create_bystring任务发起创建人默认为空must
envstringJenkins环境:dev,qa,uat,lpt,prod默认为空must
gitUrlstring修改后Git 地址默认为空must
branchstring修改后Git 默认分支默认为空must
descriptionstring修改后 job 描述信息默认为空must
appNamestring修改后 应用名称默认为空must
buildeshellstring修改后 打包shell默认为templateoptional
folderstringjenkins 文件夹默认为空must
templateNamestring基于的jenkins模板job,随意默认为空must

正常返回

{
    "code": 0,
    "data": {
        "id": "0c2c022f-c03d-4e6d-a0e7-eac2fb1c96d6",
        "create_at": 1664456694821648,
        "update_at": 1664456694821648,
        "update_by": "",
        "data": {
            "create_by": "tqt44444",
            "jobName": "apijob0927",
            "Env": "TEST",
            "gitUrl": "https://github.com/tqtcloud/workflow-backend.git",
            "branch": "sit",
            "appName": "apijob0927",
            "description": "api调用测试job,请勿启动运行44444put",
            "buildeshell": "echo api调用测试job,请勿启动运行44444put",
            "buildenv": "",
            "folder": "test2",
            "oldjobName": "",
            "newjobName": "",
            "templateName": "apijob0927"
        }
    }
}

Update Job Put

请求:

# 访问地址:/workflow-backend/api/v1/task/{env}/{folder}/{jobname}
例如:
http://127.0.0.1:8050/workflow-backend/api/v1/task/dev/test2/apideljob111
{
    "jobName":"apijob0927",
    "create_by":"tqt44444",
    "env":"test",
    "branch": "sit",
    "gitUrl": "https://github.com/tqtcloud/workflow-backend.git",
    "description": "api调用测试job,请勿启动运行44444put",
    "appName": "apijob0927",
    "buildeshell": "echo api调用测试job,请勿启动运行44444put",
    "folder": "test2",
    "templateName": "apijob0927"
}

字段解释

参数名类型描述默认值是否必须
jobNamestringjenkins job 名称默认为空must
create_bystring任务发起创建人默认为空must
envstringJenkins环境:dev,qa,uat,lpt,prod默认为空must
gitUrlstring修改后Git 地址默认为空must
branchstring修改后Git 默认分支默认为空must
descriptionstring修改后 job 描述信息默认为空must
appNamestring修改后 应用名称默认为空must
buildeshellstring修改后 打包shell默认为templateoptional
folderstringjenkins 文件夹默认为空must
templateNamestring基于的jenkins模板job,随意默认为空must

正常返回

{
    "code": 0,
    "data": {
        "id": "0c2c022f-c03d-4e6d-a0e7-eac2fb1c96d6",
        "create_at": 1664456694821648,
        "update_at": 1664456694821648,
        "update_by": "",
        "data": {
            "create_by": "tqt44444",
            "jobName": "apijob0927",
            "Env": "TEST",
            "gitUrl": "https://github.com/tqtcloud/workflow-backend.git",
            "branch": "sit",
            "appName": "apijob0927",
            "description": "api调用测试job,请勿启动运行44444put",
            "buildeshell": "echo api调用测试job,请勿启动运行44444put",
            "buildenv": "",
            "folder": "test2",
            "oldjobName": "",
            "newjobName": "",
            "templateName": "apijob0927"
        }
    }
}

# Packages

No description provided by the author
No description provided by the author

# Functions

ConnectJenkins 连接jenkins服务器获取客户端.
ExEcShell 根据传入的相关主机信息,远程主机执行命令,然后关闭通道.
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
NewSshLoginConfig 创建ssh远程登陆配置(通过秘钥登录) 使用后需要关闭ssh通道 defer sshClient.Close().
No description provided by the author
No description provided by the author
ParseJenkinsEnvFromString Parse JenkinsEnv from string.
PasswordConnect 没秘钥使用密码连接的.
No description provided by the author

# Constants

No description provided by the author
No description provided by the author
jenkins 对应环境 开发 测试 预发 压测 正式.
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author

# Variables

No description provided by the author
Enum value maps for JenkinsEnv.
Enum value maps for JenkinsEnv.
Service_ServiceDesc is the grpc.ServiceDesc for Service service.

# Structs

No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
Task todo.
TaskSet todo.
UnimplementedServiceServer must be embedded to have forward compatible implementations.
No description provided by the author

# Interfaces

ServiceClient is the client API for Service service.
ServiceServer is the server API for Service service.
UnsafeServiceServer may be embedded to opt out of forward compatibility for this service.

# Type aliases

No description provided by the author