0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 1 year has passed since last update.

Jenkins + Maven の操作

Posted at

はじめに

Jenkins + Maven の操作について学んだことを記載する。
リポジトリは以下を利用した。
https://github.com/jenkins-docs/simple-java-maven-app/blob/master/jenkins/Jenkinsfile

Git からクローン

Jenkins に Git と Maven の Plugin がインストールされていること
image.png
image.png
適当な新しい Job を作成
image.png
設定で Git を指定
image.png
Build するとコンテナに clone される
image.png
確認

$ docker exec -it condescending_boyd bash
$ cd /var/jenkins_home/workspace/{Your Job}/
$ ls -al

jar ファイル作成

Global Tool Configuration で Maven の設定
mvn -B -DskipTests clean packageこちらを指定(テストスキップして、jar を作成してくれる)
image.png
Job の configuration で Invoke top-level Maven targets を指定
image.png
Build すると Jar が作成される(最初は、maven のインストールも含まれるため、時間がかかる)
image.png
確認

$ cd /var/jenkins_home/workspace/{Your Job}/target
$ ls -al
// jar ファイルが作成されている
// my-app-1.0-SNAPSHOT.jar

テスト実施

Job の configuration で Invoke top-level Maven targets を指定
image.png

Jenkins の Global properties に以下を追加

_JAVA_OPTION
-Djdk.net.URLClassPath.disableClassPathURLCheck=true

image.png
テスト実行されていることを確認
image.png

Deploy

Build step に以下を追加
image.png
SUCCESS
image.png
確認

$ java -jar /var/jenkins_home/workspace/maven-job/target/my-app-1.0-SNAPSHOT.jar
Hello World!

テストレポート

Post-build Actions に Publish JUnit test result report を追加
image.png
結果
image.png

Build が成功した最新の jar をアーカイブする

Post-build Actions に Archive the artifacts を追加
image.png

結果
image.png

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?