ubuntu18.04配置Jenkins+docker

風輕雲斷發表於2018-12-19

jenkins需要java支援

首先到java官網下載最新的壓縮包

tar -zxvf jdk-8u191-linux-x64.tar.gz
sudo mv jdk1.8.0_191  /usr/local/jdk1.8

設定java環境變數

  1. 方案一:修改全域性配置檔案,作用於所有使用者:vim /etc/profile
export JAVA_HOME=/usr/local/jdk1.8
export JRE_HOME=${JAVA_HOME}/jre
export CLASSPATH=.:${JAVA_HOME}/lib:${JRE_HOME}/lib
export PATH=.:${JAVA_HOME}/bin:$PATH
  1. 方案二:修改當前使用者配置檔案,只作用於當前使用者:vim ~/.bashrc 設定與上一樣
  2. 使修改的配置立刻生效
##對應方法一:
source /etc/profile 
##對應方法二:
source ~/.bashrc
  1. 檢查是否安裝成功
java -version

安裝jenkins

wget -q -O - https://pkg.jenkins.io/debian/jenkins-ci.org.key | sudo apt-key add - 
sudo sh -c 'echo deb http://pkg.jenkins.io/debian-stable binary/ > /etc/apt/sources.list.d/jenkins.list' 
sudo apt-get update 
sudo apt-get install jenkins

jenkins預設埠8080,可到/etc/init.d/jenkins中修改

sudo service jenkins start

啟動報錯

ERROR: No Java executable found in current PATH: /bin:/usr/bin:/sbin:/usr/sbin
If you actually have java installed on the system make sure the executable is in the aforementioned path and that 'type -p java' returns the java executable path

建立軟連線再次啟動

sudo ln -s /usr/local/jdk1.8/bin/java /usr/bin/java

安裝docker

#新增/etc/apt/sources.list.d/docker.list
sudo sh -c 'echo deb [arch=amd64] https://download.docker.com/linux/ubuntu bionic stable > /etc/apt/sources.list.d/docker.list'
#新增祕鑰
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -
#安裝docker-ce
sudo apt install docker-ce
#檢視是否安裝成功
docker --version

相關文章