GitHub にアクセスして 「検索文字列」 repo:jenkinsci/jenkins [検索文字]といれて検索を行えばOK
XXBuilderクラスないで
action = new XXAction(build); build.addAction(action);
などとしてアクションを追加すると、そのビルド画面の左メニューにアイコンが表示されます。
このアイコンを独自のモノにするには、
@Override public String getIconFileName() { return "/plugin/project-management/images/24x24/user_suit.png"; <- project-management はプラグイン名。 }
などとしてファイル名を絶対パスで指定します。 この場所はプロジェクト上は
あたりに解釈されるので、ココにファイルを配置してビルドすればOKです。
Jenkins users - Plugin image location
index.jelly 内のリンク設定:
<a href="documents/hogehoge.tsv">hogehoge.tsv</a>
だった場合、クリックするとアクションクラスの
public void doDynamic(StaplerRequest req, StaplerResponse res) throws IOException, ServletException { }
メソッドがコールされます。引数は通常のサーブレットのReq/Resのインタフェースになっています。 なので下記のようにResponseにデータを流し込んで
String filePath = req.getRestOfPath(); filePathは documents/hogehoge.tsv File file = new File(owner.getRootDir(), filePath); ← rootDirはビルドのディレクトリ FileInputStream in = null; ServletOutputStream out = res.getOutputStream(); try { in = new FileInputStream(file); int i; while ((i = in.read()) != -1) { out.write(i); } } finally { out.close(); in.close(); }
ビルドしたディレクトリにあるファイルを引っぱってきて直接表示したり、
res.sendRedirect2(req.getContextPath() + req.getRestOfPath()); /[contextpath]/documents/hogehoge.tsv
などとして指定した画面へリダイレクトしたりすることができます。
public boolean perform(AbstractBuild build, Launcher launcher, BuildListener listener)
ないで、以下のようにアクセスすることができます。
if (build.getChangeSet() instanceof SubversionChangeLogSet) { SubversionChangeLogSet changeSet = (SubversionChangeLogSet) build .getChangeSet(); List<LogEntry> logs = changeSet.getLogs(); // 一回のコミットのログ for (LogEntry logEntry : logs) { List<Path> paths = logEntry.getPaths(); // 一回のコミットで複数のコミットファイルがある for (Path path : paths) { listener.getLogger().printf("[%s][%s][%s][%s]\n", path.getKind(), path.getValue(), path.getPath(), path.getEditType().getName()); } } }
実行結果:
A test.dat At revision 347 [unknown][/trunk/test/test.dat][/trunk/test/test.dat][add]
ビルドのトリガーとなったコミット情報*1へアクセスすることができました。
あ pom.xml に
<dependency> <groupId>org.jenkins-ci.plugins</groupId> <artifactId>subversion</artifactId> <version>1.45</version> </dependency>
の追加が必要です。。
この記事は
現在のアクセス:3651