jenkins deploy node project
Install jenkins
docker pull jenkins/jenkins |
Start jenkins container
create /home/jenkins_home file and chage mode |
Jenkins config
Initialize
Open http://host:8080 and input initial password, then install recommended plugin.
docker exec -it jenkins bash |
When installing plugins is slow , change the Jenkins-> Manage Jenkins -> Manage plugins -> Advanced -> set Update Site URL as http://mirror.esuni.jp/jenkins/updates/update-center.json
SSH
Config ssh key, in order to let jenkis pull code from git if needed.
Create jenkins item
Create a freestyle project
General -> Select GitHub project and put the project url
Source Code Management -> Select Git and put the project url
Build -> Add build step -> Esecute shell
docker build --tag playground:$BUILD_NUMBER .
docker stop playground && docker rm playground
docker run -p 3000:3000 --name playground playground:$BUILD_NUMBER- Save and build the item
注意:不要使用默认源安装docker, 不要使用默认源安装docker, 不要使用默认源安装docker, 不然会遇到下面的error
jenkins /usr/bin/docker: 2: .: Can't open /etc/sysconfig/docker |
if this Got permission denied while trying to connect to the Docker daemon socket at unix:///var/run/docker.sock: Post
error occurs , run chmod 777 /var/run/docker.sock