简单的自动发布脚本

背景: 没有基础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

}

相关推荐
西部森林牧歌16 小时前
Arbess零基础学习 - 使用Arbess+GitLab实现PHP项目构建/主机部署
ci/cd·gitlab·php·tiklab devops
chevysky.cn1 天前
Jenkins自动部署CI/CD
运维·ci/cd·jenkins
中智凯灵2 天前
#智能CI/CD流水线与AIOps 论坛@AiDD深圳站
ci/cd
爱宇阳3 天前
GitLab CI/CD 集成 Harbor 全面教程
ci/cd·gitlab·harbor
测试-鹏哥3 天前
要将ITP集成到Jenkins Pipeline中,实现开发发版时自动触发自动化测试
运维·python·测试工具·ci/cd·jenkins
wangruofeng4 天前
为 CI/CD 装上“眼睛”:App 包大小监控的实践
ci/cd·架构
爱宇阳4 天前
Spring Boot 项目 GitLab CI/CD 自动构建并推送到 Harbor 教程
spring boot·ci/cd·gitlab
佐杰4 天前
持续集成与持续部署
ci/cd
一念一花一世界4 天前
Argo CD vs Tekton vs Arbess,CI/CD工具一文纵评
ci/cd·tekton·argo cd·arbess
爱宇阳4 天前
Vue3 项目 GitLab CI/CD 自动构建并推送到 Harbor 教程
ci/cd·gitlab