1
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 3 years have passed since last update.

作業失敗ログ)GCP VMインスタンス(debian)にJenkinsをインストール

Last updated at Posted at 2020-11-29

前提

Google Cloud Launcherを使うと、ここで作業した内容とは違い、簡単にJenkinsを設定できる。
メリットデメリットは現段階では未調査なものの今回はこの方法を取らず、VMインスタンス(debian)に自前で設定を試みた。

参考:Google Cloud Launcherを使ってGCP上に2~3分でJenkinsを構築する

GCPのインスタンス

・ブートディスク:debian-10-buster-v20201112,10GB,標準の永続ディスク
・マシンタイプ:e2-small(vCPU x 2、メモリ 2 GB)

公式ドキュメント

Installing Jenkins > Linux > Debian/Ubuntu | www.jenkins.io

関連記事

JenkinsでCI環境構築チュートリアル (Linux編・macOS編)| ics.media

作業した手順

Javaのインストール → 成功

xxx@sample-jenkins:~$ cd /etc/
xxx@sample-jenkins:/etc$ sudo apt-get install default-jre
...
xxx@sample-jenkins:/etc$ java -version

openjdk version "11.0.9" 2020-10-20
...

参考:Cara Install Jenkins di GCP (Google Cloud Platform) | medium.com/@skinnyboys

Jenkinsのインストール → 失敗

xxx@sample-jenkins:/etc$ sudo apt-get install jenkins

Reading package lists... Done
Building dependency tree       
Reading state information... Done
Package jenkins is not available, but is referred to by another package.
This may mean that the package is missing, has been obsoleted, or
is only available from another source
E: Package 'jenkins' has no installation candidate

Jenkinsのインストール1(改) → 失敗

xxx@sample-jenkins:/etc$ sudo apt-get install wget
xxx@sample-jenkins:/etc$ sudo wget -q -O — https://pkg.jenkins.io/debian/jenkins.io.key | sudo apt-key add -

gpg: no valid OpenPGP data found.

参考:Installing Jenkins on Ubuntu tells me “Package 'jenkins' has no installation candidate” | serverfault.com

Jenkinsのインストール1(改2) → 成功

xxx@sample-jenkins:/etc$ curl -O -fsSL https://download.docker.com/linux/debian/gpg
$curl: (23) Failed writing body (0 != 2896)
→ この対処は中止

xxx@sample-jenkins:/etc$ wget --no-check-certificate -qO - http://pkg.jenkins-ci.org/debian/jenkins-ci.org.key | sudo apt-key add -
OK

参考:gpg: no valid OpenPGP data found | stackoverflow.com

Jenkinsのインストール2 → 失敗 → 諦め

xxx@sample-jenkins:/etc$ sudo sh -c 'echo deb http://pkg.jenkins.io/debian-stable binary/ > /etc/apt/sources.list
.d/jenkins.list
-bash: /etc/apt/sources.list.d/jenkins.list: Permission denied

教えて偉い人....

別の手順も試す

「ソースリスト」ファイルに指定の記述を追加

xxx@sample-jenkins:/etc/apt$ ls
[1]+  Stopped                 vi sources.listes.list  sources.list.d  trusted.gpg  trusted.gpg.d  trusted.gpg~

xxx@sample-jenkins::/etc/apt$ vi sources.list
↓ viで以下を追加
deb https://pkg.jenkins.io/debian binary/

memo: viで"'readonly' option is set","Can't open file for writing"となっても:w !sudo tee %を記述すれば更新可能。
参考:Jenkins Debian Packages
参考:書き込み権限のないユーザでファイルを編集してしまったとき Can't open file for writing

Jenkinsのインストール

xxx@sample-jenkins:/etc$sudo apt-get update
xxx@sample-jenkins:/etc$sudo apt-get install jenkins

Jenkinsのスタート

xxx@sample-jenkins:/etc$sudo systemctl start jenkins
xxx@sample-jenkins:/etc$sudo systemctl status jenkins
● jenkins.service - LSB: Start Jenkins at boot time
   Loaded: loaded (/etc/init.d/jenkins; generated)
   Active: active (exited) since Sun 2020-11-29 15:35:08 UTC; 22min ago
     Docs: man:systemd-sysv-generator(8)
    Tasks: 0 (limit: 2322)
   Memory: 0B
   CGroup: /system.slice/jenkins.service
Nov 29 15:35:07 sample-jenkins systemd[1]: Starting LSB: Start Jenkins at boot time...
Nov 29 15:35:07 sample-jenkins jenkins[8638]: Correct java version found
Nov 29 15:35:07 sample-jenkins su[8678]: (to jenkins) root on none
Nov 29 15:35:07 sample-jenkins su[8678]: pam_unix(su-l:session): session opened for user jenkins by (uid=0)
Nov 29 15:35:07 sample-jenkins su[8678]: pam_unix(su-l:session): session closed for user jenkins
Nov 29 15:35:08 sample-jenkins jenkins[8638]: Starting Jenkins Automation Server: jenkins.
Nov 29 15:35:08 sample-jenkins systemd[1]: Started LSB: Start Jenkins at boot time.
1
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
1
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?