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】GitHub連携①

Last updated at Posted at 2023-10-12

はじめに

今回やること
 ・Jenkinsのインストール
 ・JenkinsからSSHでサーバにアクセス

Jenkinsのインストール(今回はCentOS)

  • Javaをインストール
     ※既にインストール済みであればスキップしてください。
    $sudo yum install -y java-11-openjdk-devel.x86_64

  • Jenkins公式yumリポジトリの追加
     ※既にインストール済みであればスキップしてください。
    $curl -o /etc/yum.repos.d/jenkins.repo https://pkg.jenkins.io/redhat-stable/jenkins.repo
    $rpm --import https://pkg.jenkins.io/redhat-stable/jenkins.io.key

  • Jenkinsのインストール
    $yum -y install jenkins
    サーバ起動時の自動起動の設定
    $systemctl enable jenkins
    Jenkinsの起動
    $systemctl start jenkins

  • Jenkinsの起動
    デフォルトの設定だと、http://IPアドレス:8080/でログイン画面が開きます。
    $vim /var/lib/jenkins/secrets/initialAdminPasswordでパスワードファイルを開いて、
    パスワードをコピーします。
    Jenkinsの画面に戻ってパスワードを入力してログインします。

JenkinsからSSHでサーバにアクセス

  • SSHのプラグインをインストール
    Jenkinsの管理⇒Pluginsの画面に移動します。
    Available pluginsを選択して、検索フォームに「SSH」と入力してインストールします。
    image.png

  • 認証情報の登録
    Jenkinsの管理⇒Credentialsの画面に移動します。
    image.png
    Domeinsのリンクをクリックしてグローバルドメインの画面に遷移します。
    「+ Add Credentials」でユーザー名とパスワードを登録します。(サーバのログインIDとパスワード)
    image.png

  • ジョブ作成
    「+ 新規ジョブ作成」を選択してジョブ名を入力し、「フリースタイル・プロジェクトのビルド」を選択する。
    項目がたくさんありますが、ひとまず、SSH接続を確認したいだけなので、ビルド環境の設定のみ行います。
    「リモートホストでシェルを実行」をチェックしてIPアドレスと適当なスクリプトを書きます。

image.png
shellはなんでも良いです。↓

echo "test"

最後に適用⇒保存をします。
ダッシュボードに戻ると今作成したQiitaというジョブが作成されています。
右にある実行ボタンを押してみましょう。実行の履歴が見れると思うので確認してください。

image.png

【Jenkins】GitHub連携②:https://qiita.com/mojapico/items/ce475d827551b739ab3f

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?