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());
    }



}
相关推荐
disgare10 小时前
SpringBoot 请求调用时关于高可用机制选型和落地
java·spring boot·后端
CodeMartain10 小时前
@SpringBootApplication 到底是什么呢?
java·spring boot·intellij-idea
星秀日10 小时前
大学生开发社区项目-CLXHXH-登录功能
java
兩尛10 小时前
struct,union,Class,bitfield各自的作用和区别
java·开发语言
算.子10 小时前
【Spring AI 实战】八、完整 RAG 问答实战:检索 + 重排序 + 生成全链路
java·人工智能·spring
wuminyu10 小时前
专家视角看 Java 字节码与Class 文件格式
java·linux·c语言·jvm·c++
Gauss松鼠会10 小时前
【openGauss】openGauss 磁盘引擎之 ustore
java·服务器·开发语言·前端·数据库·经验分享·gaussdb
lee_curry10 小时前
线程中断,等待,唤醒与ThreadLocal
java·线程·juc·threadlocal·中断
indexsunny11 小时前
互联网大厂Java面试实战:Spring Boot微服务与Kafka消息队列深度解析
java·spring boot·微服务·面试·kafka·消息队列·电商
杨凯凡11 小时前
【019】IO/NIO 概念:Web 开发要掌握到什么程度
java·开发语言·nio