Jenkins 2019 in Docker(4)Cluster using Docker
Check the docker version on 2 machines
> docker --version
Docker version 18.09.2, build 6247962
Master and Slave, set the public key to ssh each other, major is just the Master need to SSH to Slave
Manage Jenkins —> Manage Nodes —> We can see there is one master nodes with 60.27GB disk space
New Node —> Node Name: slave1 —> Permanent Agent
In the next page, I put some informations as follow:
Name: slave1
#of executors: 2
Remote root directory: /opt/jenkins/jensins_home_slave
Labels: slave1
Usage: Use this node as much as possible
Launch method: Launch agent agents via SSH
Host: IP address of the slave machine
Credentials: I use root and use private key to ssh to the slave
Host Key Verification Strategy: Non verifying Verification Strategy
Availability: Keep this agent online as much as possible.
Here is my Jenkins file in pipeline script:
pipeline {
options {
buildDiscarder(logRotator(numToKeepStr: '50'))
}
agent {
dockerfile {
filename 'deployment/jenkins/Dockerfile.build'
args '-u root:root -v $HOME/.m2:/root/.m2 -v /var/run/docker.sock:/var/run/docker.sock'
}
}
stages {
stage('Clone Code') {
steps {
git(url: 'https://github.com/sillycatInc/NetsuiteConnector', branch: 'master', changelog: true, poll: true, credentialsId: 'github')
}
}
stage('Compile and Unit Test') {
steps {
sh 'mvn clean'
sh 'mvn compile'
sh 'mvn -Dtest=WsClientServiceTest test'
}
}
stage('Release to Artifactory') {
steps {
sh 'mvn package -DskipTests=true'
withCredentials([string(credentialsId: 'artifactory', variable: 'TOKEN')]) {
sh '''
set +x
jfrog rt config --url https://artifactory.sillycat.com/artifactory --user kikokang --apikey $TOKEN --interactive=false
jfrog rt u target/netsuiteconnector-*-bundle.tar.gz sillycat-java/com/sillycat/netsuiteconnector/1.0/
rm -fr target
'''
}
}
}
}
}
I think it is not good to use root and I do not think directly run on slave is a good idea. I will check other solution later.
References:
https://www.cnblogs.com/stulzq/p/9297260.html
https://www.jianshu.com/p/ab5c0bbe02de
https://chanjarster.github.io/post/jenkins-cluster/
https://my.oschina.net/mrpei123/blog/1975952
https://stackoverflow.com/questions/48223200/jenkins-pipeline-using-docker-on-existing-slaves
分享到:
相关推荐
jenkins教程+docker容器实际项目实战教程.pdf jenkins教程+docker容器实际项目实战教程.pdf
使用 Docker 安装 Jenkins,可以使用以下命令:docker run --name jenkins -u root --rm -d -p 8080:8080 -p 50000:50000 -v /var/jenkins_home:/var/jenkins_home -v /var/run/docker.sock:/var/run/docker.sock ...
4. 镜像推送:Jenkins 服务器将 Docker 镜像推送到 Harbor 服务器上。 5. 部署应用程序:Harbor 服务器提供了一个安全的环境来部署应用程序。 六、 Dockerfile 解析 在自动化部署流程中,Dockerfile 负责定义 ...
基于Jenkins+Gitlab+Docker实现SpringBoot项目自动部署 本文主要介绍了基于Jenkins、Gitlab和Docker实现SpringBoot项目自动部署的方法。下面将从Jenkins的安装、配置到自动化构建和部署的整个过程进行详细说明。 ...
项目基本结构是SpringBoot,集成了docker-maven插件实现build完的镜像上传到私服,然后用 Jenkins构建实现docker集群一键自动化部署
1)根据官方链接操作即可: ... -v /var/run/docker.sock:/var/run/docker.sock \ jenkinsci/blueocean 2)容器部署完成之后,登录页面http://虚拟机的IP:18080 进入容器查看密码: 输入密码开始按照提
触发jenkins自动pull代码,通过maven编译、打包,然后通过执行shell脚本使docker构建镜像并push到私服(或者阿里云)仓库,此操作完成后jenkins服务器上再执行SSH命令登录到部署服务器,docker从仓库(私服)拉取...
jenkins-pipeline-docker, 带有Jenkins管道插件和 Docker的容器构建环境 采用Jenkins管道插件和 Docker的容器环境。这里代码与这里博客帖子相关:...
带有Docker-in-Docker的Jenkins带有Docker-in-Docker的Jenkins容器映像是同时包含Jenkins和Docker-in-Docker的标准化连续集成环境。 这意味着它具有易于运输的Docker容器的所有优点,此外还具有从内部构建Docker容器...
jenkins部署包 docker image
Jenkins mavn git docker-compose swarm 构建持续集成及一键式部署
Docker中的Jenkins附加了本地Docker注册表目的如果您在PC上使用Jenkins,您很可能会注意到启动后运行第一次Jenkins作业所花费的时间。 在此期间,Jenkins中的Docker提取在Jenkins文件中指定的映像。 每次Docker Dind...
Jenkins Docker and DevOps The Innovation Catalysts,Jenkins Docker and DevOps The Innovation Catalysts
基于GitLab+Jenkins与Docker的自动化考试系统后端源码.zip 特性 [x] 使用通用的Git协议 [x] 自动化测试,实时展示成绩 [x] 完全隐藏GitLab和Jenkins [x] Docker中运行测试,隔离网络 [x] CPU、内存资源限制 [ ] LDAP...
Docker 安装 Jenkins 部署并自动化打包部署 Java 服务 一、 Docker 安装 Jenkins 部署 Docker 是一个开源的容器化平台,可以轻松地将应用程序打包、部署和管理。Jenkins 是一个流行的自动化构建工具,可以自动化...
详细讲解Jenkins 结合Docker的 持续集成方案,包含大量的实践案例,适合项目发布人员和配管人员学习。
##背景:jenkins部署在容器中,无法利用docker执行操作,通过ssh将jar包和当前路径下的dockerfile推送到指定服务器目录上,使用脚本进行构
docker pull jenkins/jenkins 2.查看镜像文件 docker images 3.创建Jenkins挂载目录并授权权限 创建:mkdir -p /usr/local/jenkins/data 授权:chmod -R 777 /usr/local/jenkins/data 4.启动jenkins容器 ...
gitlab+jenkins+docker自动化部署脚本,采用shell与python开发,其中python部分均为封装成型的逻辑,只接受shell传参就能完成项目构建