// 下階層用テンプレート
#topicpath
----
//ここにコンテンツを記述します。
#contents

** ビルダーが追加したアクションのアイコンを指定する。 [#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
などとして指定した画面へリダイレクトしたりすることができます。

----
この記事は
#vote(おもしろかった,そうでもない)


#comment
#topicpath


SIZE(10){現在のアクセス:&counter;}

トップ   新規 一覧 単語検索 最終更新   ヘルプ   最終更新のRSS