Jenkinsのlinuxスレーブが起動しなくなったのでJavaを上げた

今日はやたらyak shavingした日なのでブログに残しておこう。( TДT)

いつの間にかLinux Slaveが起動しなくなってた

Jenkinsの画面からノードを選択して手動で起動してみる

[06/29/17 19:31:05] [SSH] スレーブのプロセスを開始: cd "/home/jenkins" && java  -jar slave.jar

<===[JENKINS REMOTING CAPACITY]===>channel started

Slave JVM has not reported exit code. Is it still running?
[06/29/17 19:31:09] Launch failed - cleaning up connection
[06/29/17 19:31:09] [SSH] コネクション終了
ERROR: Connection terminated
java.io.EOFException
    at java.io.ObjectInputStream$PeekInputStream.readFully(ObjectInputStream.java:2638)
    at java.io.ObjectInputStream$BlockDataInputStream.readShort(ObjectInputStream.java:3113)
    at java.io.ObjectInputStream.readStreamHeader(ObjectInputStream.java:853)
    at java.io.ObjectInputStream.<init>(ObjectInputStream.java:349)
    at hudson.remoting.ObjectInputStreamEx.<init>(ObjectInputStreamEx.java:48)
    at hudson.remoting.AbstractSynchronousByteArrayCommandTransport.read(AbstractSynchronousByteArrayCommandTransport.java:34)
    at hudson.remoting.SynchronousCommandTransport$ReaderThread.run(SynchronousCommandTransport.java:59)
Caused: java.io.IOException: Unexpected termination of the channel
    at hudson.remoting.SynchronousCommandTransport$ReaderThread.run(SynchronousCommandTransport.java:73)

あらら? Slave JVM has not reported exit code. Is it still running? をぐぐってみるとどうやらJavaのバージョンに依存するエラーらしい。今まではJava7で動いていたのがだめになったんだろうか・・・

Java8にあげてみる

ubuntu 14.04なのでPPAで入れることにしました。

$ sudo apt-get install python-software-properties
$ sudo add-apt-repository ppa:webupd8team/ppa
 Oracle Java (JDK) Installer (automatically downloads and installs Oracle JDK7 / JDK8 / JDK9). There are no actual Java files in this PPA.

Important -> Why Oracle Java 7 And 6 Installers No Longer Work: http://www.webupd8.org/2017/06/why-oracle-java-7-and-6-installers-no.html

More info (and Ubuntu installation instructions):
- for Oracle Java 7: http://www.webupd8.org/2012/01/install-oracle-java-jdk-7-in-ubuntu-via.html
- for Oracle Java 8: http://www.webupd8.org/2012/09/install-oracle-java-8-in-ubuntu-via-ppa.html

Debian installation instructions:
- Oracle Java 7: http://www.webupd8.org/2012/06/how-to-install-oracle-java-7-in-debian.html
- Oracle Java 8: http://www.webupd8.org/2014/03/how-to-install-oracle-java-8-in-debian.html

Oracle Java 9 (for both Ubuntu and Debian): http://www.webupd8.org/2015/02/install-oracle-java-9-in-ubuntu-linux.html

For JDK9, the PPA uses standard builds from: http://jdk.java.net/9/ (and not the Jigsaw builds!).

Important!!! For now, you should continue to use Java 8 because Oracle Java 9 is available as an early access release! You should only use Oracle Java 9 if you explicitly need it, because it may contain bugs and it might not include the latest security patches! Also, some Java options were removed in JDK9, so you may encounter issues with various Java apps. More information and installation instructions (Ubuntu / Linux Mint / Debian): http://www.webupd8.org/2015/02/install-oracle-java-9-in-ubuntu-linux.html
 More info: https://launchpad.net/~webupd8team/+archive/ubuntu/java
Press [ENTER] to continue or ctrl-c to cancel adding it

gpg: keyring `/tmp/tmp7j4t0u3c/secring.gpg' created
gpg: keyring `/tmp/tmp7j4t0u3c/pubring.gpg' created
gpg: requesting key EEA14886 from hkp server keyserver.ubuntu.com
gpgkeys: key 7B2C3B0889BF5709A105D03AC2518248EEA14886 can't be retrieved
gpg: no valid OpenPGP data found.
gpg: Total number processed: 0

相変わらずプロキシ環境下で鍵をインストールするところで失敗する・・・。

gozuk16.hatenablog.com

自分の記事を参考に鍵だけインストー

$ sudo apt-key adv --keyserve
[http://gozuk16.hatenablog.com/entry/2016/03/24/144400:embed:cite]

r hkp://pgp.mit.edu:80 --keyserver-options http-proxy=http://proxy.example.com:8080/ --recv-keys EEA14886

Executing: gpg --ignore-time-conflict --no-options --no-default-keyring --homedir /tmp/tmp.JJ3XwYe2dV --no-auto-check-trustdb --trust-model always --keyring /etc/apt/trusted.gpg --primary-keyring /etc/apt/trusted.gpg --keyserver hkp://pgp.mit.edu:80 --keyserver-options http-proxy=http://proxy.example.com:8080/ --recv-keys EEA14886
gpg: requesting key EEA14886 from hkp server pgp.mit.edu
gpg: key EEA14886: public key "Launchpad VLC" imported
gpg: Total number processed: 1
gpg:               imported: 1  (RSA: 1)

更新してインストー

$ sudo aptitude update
$ sudo aptitude install oracle-java8-installer

$ sudo java -version
java version "1.8.0_131"
Java(TM) SE Runtime Environment (build 1.8.0_131-b11)
Java HotSpot(TM) 64-Bit Server VM (build 25.131-b11, mixed mode)
root@ci-slave-linux1:/etc/apt/sources.list.d# ls
webupd8team-java-trusty.list

直ったー

[06/29/17 19:49:45] [SSH] スレーブのプロセスを開始: cd "/home/jenkins" && java  -jar slave.jar
<===[JENKINS REMOTING CAPACITY]===>channel started
Slave.jar version: 3.7
This is a Unix agent
Evacuated stdout

Agent successfully connected and online