美文网首页
Linux下使用Jenkins自动化构建Dotnet Core项

Linux下使用Jenkins自动化构建Dotnet Core项

作者: 凌雲木 | 来源:发表于2019-09-25 15:10 被阅读0次

环境准备

  • 系统
    linux
  • 环境
    dotnet core

jenkins:自动化部署
.NET Core 2.2 SDK:用来编译项目
.NET Core 2.2 Runtime:The runtime includes everything you need to run .NET Core applications. The runtime is also included in the SDK
项目以linux服务的方式使用Kestrel发布,再配上nginx,可以反向代理的方式访问项目
jenkins相关配置:


源码管理配置
构建触发器
execute shell

有shell命令可以看出,再次以systemd服务形式发布的ASP.NET Core项目

在/lib/systemd/system下添加 mcl.service
vim /lib/systemd/system/mcl.service

image.png
wq!保存退出
运行服务检查服务是否能运行
sudo systemctl start mcl.service
sudo systemctl status mcl.service
fcj@ubuntu:~$ sudo  systemctl status mcl.service
● mcl.service - run MclServer on ubuntu
   Loaded: loaded (/lib/systemd/system/mcl.service; disabled; vendor preset: ena
   Active: active (running) since Sat 2019-08-31 05:08:22 CST; 1h 16min ago
 Main PID: 5640 (dotnet)
    Tasks: 17 (limit: 3492)
   CGroup: /system.slice/mcl.service
           └─5640 /usr/bin/dotnet /var/lib/jenkins/workspace/MclServerCore/Integ

8月 31 05:08:22 ubuntu systemd[1]: Started run MclServer on ubuntu.
8月 31 05:08:24 ubuntu dotnet[5640]: Hosting environment: Production
8月 31 05:08:24 ubuntu dotnet[5640]: Content root path: /var/lib/jenkins/workspa
8月 31 05:08:24 ubuntu dotnet[5640]: Now listening on: http://[::]:8020
8月 31 05:08:24 ubuntu dotnet[5640]: Application started. Press Ctrl+C to shut d

服务正常后,关闭服务sudo systemctl stop mcl.service,保存jenkins的配置,构建项目:
控制提输出报错

+ sudo systemctl stop mcl.service
sudo: 没有终端存在,且未指定 askpass 程序
Build step 'Execute shell' marked build as failure
Finished: FAILURE

可见jenkins的shell脚本操作systemd服务出错了

fcj@server:~$ sudo visudo
对sudo 设置成免密形式

image.png

再次执行jenkins构建:


image.png

在浏览器访问项目发布的页面:


image.png

相关文章

网友评论

      本文标题:Linux下使用Jenkins自动化构建Dotnet Core项

      本文链接:https://www.haomeiwen.com/subject/tqpzectx.html