maven-插件开发(idea)-4

xml 复制代码
package gitlab;
import org.gitlab4j.api.Constants;
import org.gitlab4j.api.GitLabApi;
import org.gitlab4j.api.GitLabApiException;
import org.gitlab4j.api.models.Branch;
import org.gitlab4j.api.models.MergeRequest;
import org.gitlab4j.api.models.MergeRequestParams;
import org.gitlab4j.api.models.Project;

import java.util.List;


public class GitMain {
    String gitLabUrl = "域名";

    static String projectId = "rcs/项目名";

    static GitLabApi gitLabApi;

    GitMain(String gitLabUrl,String projectId ){
         gitLabApi = new GitLabApi(GitLabApi.ApiVersion.V4, "https://git.com", "wfG-_kDzzxkqrts8mz5L");
    }

    public static Project getGitLabApi() throws GitLabApiException {

//        String personalAccessToken = "_C-xfqXrp3dfqUWjTy4y";

//        GitLabApi gitLabApi = new GitLabApi(gitLabUrl, personalAccessToken);
//        Project project = gitLabApi.getProjectApi().getProject(projectId);

        // 创建 GitLabApi 实例


        // 获取项目列表
        Project project = gitLabApi.getProjectApi().getProject(projectId);
        System.out.println(project.getName());

        List<Branch> branches = gitLabApi.getRepositoryApi().getBranches(projectId);
        System.out.println(branches.get(0).getName());

//        List<MergeRequest> mrs = gitLabApi.getMergeRequestApi().getMergeRequests(projectId);

        List<MergeRequest> mrs = gitLabApi.getMergeRequestApi().getMergeRequests(projectId, Constants.MergeRequestState.OPENED);

        System.out.println(mrs.size());
        return null;
    }

    public static void create() throws GitLabApiException {
        MergeRequestParams mergeRequest = new MergeRequestParams()
                .withTitle("New Merge Request")
                .withSourceBranch("source_branch")
                .withTargetBranch("target_branch")
                .withDescription("Please merge these changes.");

        // 提交 Merge Request
        MergeRequest newMergeRequest = gitLabApi.getMergeRequestApi().createMergeRequest(projectId, mergeRequest);
    }


    public static void main(String[] args) throws GitLabApiException {
        System.out.println(getGitLabApi());
    }



}
相关推荐
45288655上山打老虎1 小时前
C++完美转发
java·jvm·c++
Seven972 小时前
查找算法
java
毕设源码-朱学姐3 小时前
【开题答辩全过程】以 公务员考试在线测试系统为例,包含答辩的问题和答案
java
serendipity_hky3 小时前
【SpringCloud | 第2篇】OpenFeign远程调用
java·后端·spring·spring cloud·openfeign
RwTo3 小时前
【源码】-Java线程池ThreadPool
java·开发语言
SadSunset3 小时前
(15)抽象工厂模式(了解)
java·笔记·后端·spring·抽象工厂模式
兮动人3 小时前
EMT4J定制规则版:Java 8→17迁移兼容性检测与规则优化实战
java·开发语言·emt4j
一点★3 小时前
Java中的常量池和字符串常量池
java·开发语言
问君能有几多愁~3 小时前
C++ 日志实现
java·前端·c++
菜鸟plus+3 小时前
Java 接口的演变
java·开发语言