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
などとして指定した画面へリダイレクトしたりすることができます。
この記事は
現在のアクセス:3651