// 下階層用テンプレート #topicpath ---- //ここにコンテンツを記述します。 #contents **Jenkinsのソース検索 [#g070d50c] [[GitHub>https://github.com/jenkinsci/jenkins/search]] にアクセスして 「検索文字列」 repo:jenkinsci/jenkins [検索文字]といれて検索を行えばOK ** ビルダーが追加したアクションのアイコンを指定する。 [#r4d697cc] XXBuilderクラスないで action = new XXAction(build); build.addAction(action); などとしてアクションを追加すると、そのビルド画面の左メニューにアイコンが表示されます。 #ref(menu.png) このアイコンを独自のモノにするには、 @Override public String getIconFileName() { return "/plugin/project-management/images/24x24/user_suit.png"; <- project-management はプラグイン名。 } などとしてファイル名を絶対パスで指定します。 この場所はプロジェクト上は #ref(icon.png) あたりに解釈されるので、ココにファイルを配置してビルドすればOKです。 [[Jenkins users - Plugin image location>http://jenkins-ci.361315.n4.nabble.com/Plugin-image-location-td362688.html]] **アクションの画面でのリンク [#g3e2a4b9] 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 などとして指定した画面へリダイレクトしたりすることができます。 **ビルドのトリガーとなったコミット情報にアクセスする。 [#l96c8684] 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] ビルドのトリガーとなったコミット情報((というか、そのビルドでUpdateされたコミット情報))へアクセスすることができました。 あ pom.xml に <dependency> <groupId>org.jenkins-ci.plugins</groupId> <artifactId>subversion</artifactId> <version>1.45</version> </dependency> の追加が必要です。。 ---- この記事は #vote(おもしろかった,そうでもない) #comment #topicpath SIZE(10){現在のアクセス:&counter;}