登錄事先準備好的 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安裝
參考 https://www.cnblogs.com/stulzq/p/9775973.html
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 成功