赞
踩
c#实现方法:
1. 登录Gitlab,创建一个具有操作权限的私人访问令牌:Personal Access Token
2. nuget安装NGitLab.Plus:Install-Package NGitLab.Plus
3. 上传更新文件的示例代码:
- var client = GitLabClient.Connect(Gitlab地址, 访问令牌);
- var repository = client.GetRepository(项目Id); //可登录到Gitlab查看
- var fclient = repository.Files;
-
- var file = new FileUpsert();
- file.Path = "文件相对路径";
- file.Branch = "分支名称";
- file.Encoding = "base64";
- byte[] content = 文件内容二进制字节数字;
- file.Content = Convert.ToBase64String(content);
- file.CommitMessage = "提交日志";
- fclient.Update(file); //执行更新
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。