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



}
相关推荐
ChillJavaGuy10 小时前
常见限流算法详解与对比
java·算法·限流算法
寻星探路10 小时前
数据库造神计划第六天---增删改查(CRUD)(2)
java·大数据·数据库
毕设源码-朱学姐10 小时前
【开题答辩全过程】以 4S店汽车维修保养管理系统为例,包含答辩的问题和答案
java·spring boot·汽车
盖世英雄酱5813611 小时前
Read timed out问题 排查
java·数据库·后端
狼爷11 小时前
破解 JetBrains 的学生,后来都成了它的 “推销员”:一场用习惯换市场的长期战
java·jetbrains
.豆鲨包11 小时前
【Android】Viewpager2实现无限轮播图
android·java
BXCQ_xuan11 小时前
软件工程实践二:Spring Boot 知识回顾
java·spring boot·后端
老赵的博客11 小时前
c++ unqiue指针
java·jvm·c++
wuxuanok12 小时前
SpringBoot -原理篇
java·spring boot·spring
柿蒂12 小时前
从if-else和switch,聊聊“八股“的作用
android·java·kotlin