JenKins使用pm2部署.net core网站
程序员文章站
2022-04-08 17:35:10
登录事先准备好的 Jenkins 1 新建任务 2 源码管理 git 输入正确地址 3 构建环境:Delete workspace before build startsAbort the build if it's stuck 打勾 4 安装事先准备好的 pm2打开shell安装参考 https: ......
登录事先准备好的 jenkins
-
1 新建任务
-
2 源码管理 git 输入正确地址
-
3 构建环境:
delete workspace before build starts
abort the build if it's stuck打勾
-
4 安装事先准备好的 pm2
打开shell安装
参考
sudo yum install nodejs
node -v
npm install pm2 -g
- 5 回到jenkins
选择 构建=>执行shell
ls cd ./vpstest.netcore/vpstest.netcore ls dotnet publish -c release cd bin/release/netcoreapp2.2/publish ls pm2 start "dotnet vpstest.netcore.dll" --name testweb
- 6 保存
- 选择立即构建
- 7 查看控制台输出
started by user www
building in workspace /var/lib/jenkins/workspace/dotcoretest
[ws-cleanup] deleting project workspace...
[ws-cleanup] deferred wipeout is used...
[ws-cleanup] done
no credentials specified
cloning the remote git repository
cloning repository https://github.com/www/vpstest.git
> git init /var/lib/jenkins/workspace/dotcoretest # timeout=10
fetching upstream changes from https://github.com/www/vpstest.git
> git --version # timeout=10
> git fetch --tags --progress https://github.com/www/vpstest.git +refs/heads/*:refs/remotes/origin/*
> git config remote.origin.url https://github.com/www/vpstest.git # timeout=10
> git config --add remote.origin.fetch +refs/heads/*:refs/remotes/origin/* # timeout=10
> git config remote.origin.url https://github.com/www/vpstest.git # timeout=10
fetching upstream changes from https://github.com/www/vpstest.git
> git fetch --tags --progress https://github.com/www/vpstest.git +refs/heads/*:refs/remotes/origin/*
> git rev-parse refs/remotes/origin/master^{commit} # timeout=10
> git rev-parse refs/remotes/origin/origin/master^{commit} # timeout=10
checking out revision 66cec8d481afee09a71ab9941e2ce25db6075485 (refs/remotes/origin/master)
> git config core.sparsecheckout # timeout=10
> git checkout -f 66cec8d481afee09a71ab9941e2ce25db6075485
commit message: "修改"
> git rev-list --no-walk 66cec8d481afee09a71ab9941e2ce25db6075485 # timeout=10
[dotcoretest] $ /bin/sh -xe /tmp/jenkins8834327214949599471.sh
+ ls
dockercompsoe
license
readme.md
vpstest.netcore
+ cd ./vpstest.netcore/vpstest.netcore
+ ls
appsettings.development.json
appsettings.json
controllers
dockerfile
models
program.cs
startup.cs
views
vpstest.netcore.csproj
wwwroot
+ dotnet publish -c release
microsoft (r) build engine version 15.9.20+g88f5fadfbe for .net core
copyright (c) microsoft corporation. all rights reserved.
restoring packages for /var/lib/jenkins/workspace/dotcoretest/vpstest.netcore/vpstest.netcore/vpstest.netcore.csproj...
generating msbuild file /var/lib/jenkins/workspace/dotcoretest/vpstest.netcore/vpstest.netcore/obj/vpstest.netcore.csproj.nuget.g.props.
generating msbuild file /var/lib/jenkins/workspace/dotcoretest/vpstest.netcore/vpstest.netcore/obj/vpstest.netcore.csproj.nuget.g.targets.
restore completed in 1.81 sec for /var/lib/jenkins/workspace/dotcoretest/vpstest.netcore/vpstest.netcore/vpstest.netcore.csproj.
vpstest.netcore -> /var/lib/jenkins/workspace/dotcoretest/vpstest.netcore/vpstest.netcore/bin/release/netcoreapp2.2/vpstest.netcore.dll
vpstest.netcore -> /var/lib/jenkins/workspace/dotcoretest/vpstest.netcore/vpstest.netcore/bin/release/netcoreapp2.2/vpstest.netcore.views.dll
vpstest.netcore -> /var/lib/jenkins/workspace/dotcoretest/vpstest.netcore/vpstest.netcore/bin/release/netcoreapp2.2/publish/
+ cd bin/release/netcoreapp2.2/publish
+ ls
appsettings.development.json
appsettings.json
vpstest.netcore.deps.json
vpstest.netcore.dll
vpstest.netcore.pdb
vpstest.netcore.runtimeconfig.json
vpstest.netcore.views.dll
vpstest.netcore.views.pdb
web.config
wwwroot
+ pm2 start 'dotnet vpstest.netcore.dll' --name testweb
[pm2] starting /bin/bash in fork_mode (1 instance)
[pm2] done.
┌──────────┬────┬─────────┬──────┬───────┬────────┬─────────┬────────┬─────┬────────────┬──────┬──────────┐
│ app name │ id │ version │ mode │ pid │ status │ restart │ uptime │ cpu │ mem │ user │ watching │
├──────────┼────┼─────────┼──────┼───────┼────────┼─────────┼────────┼─────┼────────────┼──────┼──────────┤
│ sffweb │ 0 │ n/a │ fork │ 10209 │ online │ 0 │ 33m │ 0% │ 116.3 mb │ root │ disabled │
│ testweb │ 1 │ n/a │ fork │ 13650 │ online │ 0 │ 0s │ 0% │ 3.8 mb │ root │ disabled │
└──────────┴────┴─────────┴──────┴───────┴────────┴─────────┴────────┴─────┴────────────┴──────┴──────────┘
use `pm2 show <id|name>` to get more details about an app
finished: success
-
8 开放 5000 端口
sudo firewall-cmd --add-port=5000/tcp
-
9 打开浏览器 输入 ip:5000 成功
上一篇: http请求的headers详解
下一篇: 下载文件时-修改文件名字
推荐阅读
-
ASP.NET学习笔记(五)-全球化部署,网站发布方法,AJAX使用,水晶报表使用,DropDownList,CheckBox全选
-
如何利用Jenkins + TFS为.Net Core实现持续集成/部署详解
-
如何利用Jenkins + TFS为.Net Core实现持续集成/部署详解
-
ASP.NET Core部署前期准备 使用Hyper-V安装Ubuntu Server 16.10
-
.net core3.0部署Linux服务器 使用Docker容器和Nginx反代理教程
-
ASP.NET Core 3.0 : 二十八. 在Docker中的部署以及docker-compose的使用
-
ASP.NET Core部署前期准备 使用Hyper-V安装Ubuntu Server 16.10
-
Linux下自动化部署ASP.NET CORE 3.1(Docker+Jenkins+Nginx)
-
[笔记]使用Docker部署.NET Core应用程序
-
ASP.NET学习笔记(五)-全球化部署,网站发布方法,AJAX使用,水晶报表使用,DropDownList,CheckBox全选