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,其他配置不变

相关推荐
Patrick_Wilson1 天前
为什么gitlab的MR会默认有一个merge commit
前端·git·gitlab
叱咤少帅(少帅)1 天前
新版本jenkins的共享库的实现
运维·jenkins
2601_962297251 天前
Python、Pytest、Allure、Selenium和Jenkins实现自动化测试集成实例
python·selenium·jenkins·pytest·allure
大模型丫丫1 天前
工业级 RAG 为什么需要 Elasticsearch?
elasticsearch·django·jenkins
虎王物联1 天前
Docker BuildKit多阶段构建:IoT固件交叉编译流水线实战
运维·物联网·ci/cd·docker·容器·物联网嵌入式
LlmCraft|大模型工程实践1 天前
14. CI/CD 流水线中集成 Docker:GitHub Actions 自动构建部署
ci/cd·docker·github
极小狐1 天前
极狐GitLab Duo 功能更新:扩展 MCP 工具集、支持 MR 事件触发
运维·gitlab·agent·mr·极狐gitlab·mcp·极狐gitlab duo
2501_928996222 天前
GitLab CVE-2026-19478漏洞解析:Gitaly ref攻击绕过审计与中科热备下的代码资产保护重构
重构·gitlab
秦渝兴2 天前
GitLab CI/CD 流水线实战
ci/cd·gitlab
gs801402 天前
告别 CI/CD 误伤与红条:Docker 镜像智能清理与优雅防冲突实战
ci/cd·docker·容器