Gitlab和Jenkins集成 实现CI (三)

Gitlab和Jenkins集成 实现CI (一)
Gitlab和Jenkins集成 实现CI (二)
Gitlab和Jenkins集成 实现CI (三)

自动部署

配置免密ssh

进入http服务器

生成ssh密钥
shell 复制代码
ssh-keygen -t rsa

进入jenkins(容器)

拷贝公钥
shell 复制代码
ssh-copy-id http服务器用户名@http服务器ip
#输入http服务器密码

配置jenkis构建触发器

生成拷贝脚本
shell 复制代码
vi /var/jenkins_home/scp_dev_env.sh

#!/bin/sh

scp /var/jenkins_home/workspace/jenkins项目名称/* http服务器用户名@http服务器ip:/home/docker/www/项目根目录/
ssh http服务器用户名@http服务器ip 'composer -V' # 这里是php执行composer,如果是java可以执行maven等

# 设置执行权限
chmod +x /var/jenkins_home/scp_dev_env.sh

# 运行异常脚本,保证脚本无异常,可正常执行得到想要的结果
/bin/sh /var/jenkins_home/scp_dev_env.sh

#去http服务器根目录查看拷贝是否正确
配置构建步骤(Build Steps)

进入项目
Configure Build Steps Add build step 选择Run with timeout Run with timeout Time-out strategy 按照实际选择超时机制 Build Step 选择Execute shell Command 填写脚本路径

注意,如果无需超时设置,需要保证脚本无论执行多久一定成功,在Add build step的时候直接选择Execute shell,其他配置不变

相关推荐
汪海游龙2 小时前
本地源码还是 Maven 版本?Gradle composite build 双轨依赖的正确接法
android·ci/cd·kotlin
lisanmengmeng9 小时前
搭建elk环境并接入frostmourne,实现监控报警效果(一)
运维·elk·jenkins
Ashley的成长之路10 小时前
前端性能优化实战手册·第5篇(最终篇):性能监控与 CI/CD 集成
前端·ci/cd·性能优化
小小测试开发2 天前
AI Agent 回归测试:Replay 录一次、CI 跑千遍,像 Jest 一样给非确定性系统写断言
人工智能·ci/cd
我一定会有钱2 天前
打造完美工作流:Git 配置”一次推送,三端同步”(Gitee/GitCode/GitHub)
开发语言·windows·vscode·搜索引擎·gitlab·github·visual studio code
LXY_BUAA2 天前
Git_在飞牛中部署 GitLab_20260817
git·gitlab
爱编程的Zion2 天前
Jenkins 从 0 到 1 学习笔记
笔记·学习·jenkins
JavaDog程序狗3 天前
【指南】uni-app微信小程序多环境CI-CD完全指南
ci/cd·uni-app·jenkins
Patrick_Wilson4 天前
sccache 用在 Rust 上为什么常「不省编译」:原理、限制与 Windows 接入
ci/cd·rust·编译器
北风toto4 天前
研发效能与后端核心技术全景指南:从CI/CD到共性组件实战
java·开发语言·ci/cd