去发现生活中的美好,记录生活中的点点滴滴

docker-jenkins部署项目N种方式

php admin 947℃

1、通过共享docker命令行发布:

在jenkins
echo 'Start deploying the project...'
docker exec -it -d testproject  /bin/bash   -c "cd /html && git pull"
testproject为容器名或容器id,此命令通过进入docker执行docker内部命令
echo 'Deployment complete.'

2、通过Publish over SSH发布:

Dashboard->Manage Jenkins->Manage Plugins ->Available,搜Publish Over SSH进行安装插件;

在服务器生成ssh key:

ssh-keygen -f /root/.ssh/jenkins 
#Passphrase 设置密码,这个密码要记住,后续要用到;
Dashboard->Manage Jenkins->Configure System->Public over ssh,分别填写Passphrase,key(ssh生成的密钥,vim /root/.ssh/jenkins可见),如果jenkins不是docker安装,可以直接填写私钥路径到Path to key
继续填写SSH Servers配置:
Name为模板名称,Hostname为主机IP,Username为账户名,Remote Directory可以填写 /
保存后,在发布配置找到Build Environment-> Send files or execute commands over SSH before the build starts 或者 Send files or execute commands over SSH after the build runs
选择刚刚创建的模板,填写Source file为
cd  /home/jenkins/workspace/testproject
Remote directory为:/home/jenkins/workspace/testproject
Exec command为:sh  /home/jenkins/workspace/testproject/deploy.sh

(6)保存后进行构建即可

3、Pipeline安装方式:
有时间再整理…

转载请注明:永盟博客 » docker-jenkins部署项目N种方式

喜欢 (1)

Warning: count(): Parameter must be an array or an object that implements Countable in E:\www\blog\wp-includes\class-wp-comment-query.php on line 405