简单的自动发布脚本

背景: 没有基础CI/CD 建设,又不想大动干戈,所以想着写个脚本完成这个工作,windows中使用,如果是linux只需要修改检查和发送消息部分,发送消息部分可以使用cURL

获取本地和远程的commitId

$localCommitId = git rev-parse HEAD

$string = git ls-remote origin HEAD

remoteCommitId = string.Substring(0, 40)

echo $remoteCommitId

echo $localCommitId

#检查是否有新的提交

if (remoteCommitId -ceq localCommitId) {

exit;

}

else {

停止旧服务

Stop-Process -force -name *iValon.WES.API*

cd D:\

拉取代码

git pull

发布

dotnet publish -c Release -r win-x64 --self-contained true -o

关闭build-server

dotnet build-server shutdown

启动新进程

Start-Process .\i

发送企业微信消息

msg = '{ "msgtype": "markdown", "markdown": { "content": "\' + remoteCommitId + ':\u53d1\u5e03\u6210\u529f</font>" }}';

Invoke-WebRequest https://qyapi.weixin.qq.com -Method POST -Body $msg

}

相关推荐
我叫唧唧波1 天前
【自动化部署】基于Docker构建CI/CD流水线
ci/cd·docker·node.js
熊猫钓鱼>_>2 天前
GitHub Actions CI/CD流水线实战指南
ci/cd·github
遇见火星2 天前
主流CI/CD工具对比分析!
ci/cd·gitlab·jenkins·云效
The Straggling Crow3 天前
熟练版本控制 (Git)、CI/CD 流程。
git·elasticsearch·ci/cd
sijiaoh3 天前
用Renovate处理Private Submodules
ci/cd·github
ylmzfun3 天前
CI/CD技术全景解析:从理念到高效落地的自动化流水线
运维·ci/cd·自动化
熊猫钓鱼>_>3 天前
CI/CD 配置完全指南:从零开始构建自动化流水线
servlet·ci/cd·自动化
一念一花一世界4 天前
CI/CD工具选型:GitLab CI与Arbess全面对比指南
ci/cd·gitlab·jenkins·cicd·arbess
一念一花一世界4 天前
CI/CD工具选型:Jenkins与Arbess全面对比指南
运维·ci/cd·jenkins·arbess
自己的九又四分之三站台4 天前
GitLab vs Gitea 全面对比:企业级 DevOps 还是轻量级私有仓库?
ci/cd·gitlab·devops·gitea