java - Jenkins Git API

标签 java git jenkins jenkins-plugins jgit

我们目前正在开发自定义 Jenkins 插件。我们需要对git仓库进行一些操作。我们对存储库的历史感兴趣(例如:提交消息、标记消息等)。我想问是否有一些 Java Jenkins Git Api,可以从存储库中读取这些信息。目前我们发现 JGit 能够做到这一点,但我们不确定它将如何与服务器上运行的 Jenkins 实例一起工作。感谢您的任何建议。

最佳答案

尝试scm4j-vcs-git :

public static final String WORKSPACE_DIR = System.getProperty("java.io.tmpdir") + "git-workspaces";
...
IVCSWorkspace workspace = new VCSWorkspace(WORKSPACE_DIR);
String repoUrl = "https://github.com/MyUser/MyRepo";
IVCSRepositoryWorkspace repoWorkspace = workspace.getVCSRepositoryWorkspace(repoUrl);
IVCS vcs = new GitVCS(repoWorkspace);
vcs.setCredentials("user", "password"); // if necessary
vcs.getBranchesList();
vcs.getCommitMessages(...); //see doc
//etc

该项目目前正在开发中,因此您可以请求您需要的功能。

关于java - Jenkins Git API,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43914448/

相关文章:

windows - 在 jenkins windows slave 中克隆远程仓库 'origin' 时出错

java - 包含不在日期范围内的月份的 MySQL 计数

java - 获取 GridLayout 中 JPanel 的位置/索引?

git - 如何为 github 存储库设置 CIAbot

git - 从 gitlab 推送到远程 git 服务器时为 "Connection refused - connect(2) (Errno::ECONNREFUSED)"

git - 如何在不使用 Github 的情况下使用 Git 在项目中进行协作?

jenkins - 通过 SSH 发布无效私钥

java - perfino 是否支持 REST (JAX-RS) 调用

java apache tomcat 没有检测到 jsp 文件,即使它存在

java - 为什么 Jacoco 排除 java 类?