DockerでJenkinsを構築する
dockerイメージの取得
docker pull jenkins/jenkins:lts
コンテナ起動
docker run -p 8080:8080 -p 50000:50000 --restart=on-failure jenkins/jenkins:lts-jdk17
Jenkinsの初期設定
localhost:8080
にアクセス
To ensure Jenkins is securely set up by the administrator, a password has been written to the log (not sure where to find it?) and this file on the server:
/var/jenkins_home/secrets/initialAdminPassword
Please copy the password from either location and paste it below.
ログに出力されたパスワードを入力
Install suggested plugins
プラグインの設定
ユーザー作成 adminユーザーで作業を継続する場合はSkip and continue as admin
設定完了
admin
ユーザーでのログインは、先ほどのパスワードを使用してと書いてある
Job作成
- 新規ジョブ作成
- プロジェクトに名前を付ける
- フリースタイル・プロジェクトのビルドを選択
- ビルド手順の追加(試しにシェルの実行
ls -lah
) - ビルドの保存と実行
ビルドの履歴からコンソール出力を選択して実行結果を確認
Started by user admin
Running as SYSTEM
Building in workspace /var/jenkins_home/workspace/test_job
[test_job] $ /bin/sh -xe /tmp/jenkins10752324995961363420.sh
+ ls -lah
total 8.0K
drwxr-xr-x 2 jenkins jenkins 4.0K Feb 5 21:50 .
drwxr-xr-x 3 jenkins jenkins 4.0K Feb 5 21:50 ..
Finished: SUCCESS