JenKins使用pm2部署.net core網站

来源:https://www.cnblogs.com/WNpursue/archive/2019/04/03/10646725.html
-Advertisement-
Play Games

登錄事先準備好的 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 成功


您的分享是我們最大的動力!

-Advertisement-
Play Games
更多相關文章
  • Random類專門用於生成一個偽隨機數,它有兩個構造器:一個構造器使用預設的種子(以當前時間作為種子),另一個構造器需要程式員顯示傳入一個long型整數的種子。 Random類比Math類的random()方法提供了更多的方式來生成各種偽隨機數,可以生成浮點類型的偽隨機數,也可以生成整數類型的偽隨機 ...
  • Java工具類——通過配置XML驗證Map 背景 在JavaWeb項目中,接收前端過來的參數時通常是使用我們的實體類進行接收的。但是呢,我們不能去決定已經搭建好的框架是怎麼樣的,在我接觸的框架中有一種就是通過Map來接收前端過來的所有參數,框架中沒有實體類的說法,從接收參數,驗證參數到參數至持久層整 ...
  • 小胖將代碼進行了升級,改成用mongodb來存儲用戶數據。 關註公眾號「**Python專欄**」,後臺回覆:zsxq08,獲取本文全套代碼。 ...
  • Java中的常用類: ▪ Object類 ▪ Math類 ▪ String類和StringBuffer類(字元串) ▪ 8種基本類型所對應的包裝類 ▪ java.util包中的類——Date類 Object類: Object類是Java語言程式中所有類的父類,即承自Object類。Object類中包 ...
  • 所屬網站分類: 資源下載 > python電子書 作者:熊貓燒香 鏈接:http://www.pythonheidong.com/blog/article/29/ 來源:python黑洞網 作者:熊貓燒香 鏈接:http://www.pythonheidong.com/blog/article/29 ...
  • 求最大公約數也可以用遞歸實現 ...
  • 1、JAVA中,char占2位元組,16位。可在存放漢字 2、char賦值 char a='a'; //任意單個字元,加單引號。 char a='中';//任意單個中文字,加單引號。 char a=111;//整數。0~65535。十進位、八進位、十六進位均可。輸出字元編碼表中對應的字元。 註:只能放 ...
  • 一,java介面 二,介面與類的區別 三,介面特性 不能使用new運算符實例化一個介面 //錯誤的 x = new Comparable(.....); //Comparable是一個介面 介面內能聲明變數 可以使用instanceof檢查一個對象是否屬於某個特定類 介面可擴展 介面不能包含實例域或 ...
一周排行
    -Advertisement-
    Play Games
  • 移動開發(一):使用.NET MAUI開發第一個安卓APP 對於工作多年的C#程式員來說,近來想嘗試開發一款安卓APP,考慮了很久最終選擇使用.NET MAUI這個微軟官方的框架來嘗試體驗開發安卓APP,畢竟是使用Visual Studio開發工具,使用起來也比較的順手,結合微軟官方的教程進行了安卓 ...
  • 前言 QuestPDF 是一個開源 .NET 庫,用於生成 PDF 文檔。使用了C# Fluent API方式可簡化開發、減少錯誤並提高工作效率。利用它可以輕鬆生成 PDF 報告、發票、導出文件等。 項目介紹 QuestPDF 是一個革命性的開源 .NET 庫,它徹底改變了我們生成 PDF 文檔的方 ...
  • 項目地址 項目後端地址: https://github.com/ZyPLJ/ZYTteeHole 項目前端頁面地址: ZyPLJ/TreeHoleVue (github.com) https://github.com/ZyPLJ/TreeHoleVue 目前項目測試訪問地址: http://tree ...
  • 話不多說,直接開乾 一.下載 1.官方鏈接下載: https://www.microsoft.com/zh-cn/sql-server/sql-server-downloads 2.在下載目錄中找到下麵這個小的安裝包 SQL2022-SSEI-Dev.exe,運行開始下載SQL server; 二. ...
  • 前言 隨著物聯網(IoT)技術的迅猛發展,MQTT(消息隊列遙測傳輸)協議憑藉其輕量級和高效性,已成為眾多物聯網應用的首選通信標準。 MQTTnet 作為一個高性能的 .NET 開源庫,為 .NET 平臺上的 MQTT 客戶端與伺服器開發提供了強大的支持。 本文將全面介紹 MQTTnet 的核心功能 ...
  • Serilog支持多種接收器用於日誌存儲,增強器用於添加屬性,LogContext管理動態屬性,支持多種輸出格式包括純文本、JSON及ExpressionTemplate。還提供了自定義格式化選項,適用於不同需求。 ...
  • 目錄簡介獲取 HTML 文檔解析 HTML 文檔測試參考文章 簡介 動態內容網站使用 JavaScript 腳本動態檢索和渲染數據,爬取信息時需要模擬瀏覽器行為,否則獲取到的源碼基本是空的。 本文使用的爬取步驟如下: 使用 Selenium 獲取渲染後的 HTML 文檔 使用 HtmlAgility ...
  • 1.前言 什麼是熱更新 游戲或者軟體更新時,無需重新下載客戶端進行安裝,而是在應用程式啟動的情況下,在內部進行資源或者代碼更新 Unity目前常用熱更新解決方案 HybridCLR,Xlua,ILRuntime等 Unity目前常用資源管理解決方案 AssetBundles,Addressable, ...
  • 本文章主要是在C# ASP.NET Core Web API框架實現向手機發送驗證碼簡訊功能。這裡我選擇是一個互億無線簡訊驗證碼平臺,其實像阿裡雲,騰訊雲上面也可以。 首先我們先去 互億無線 https://www.ihuyi.com/api/sms.html 去註冊一個賬號 註冊完成賬號後,它會送 ...
  • 通過以下方式可以高效,並保證數據同步的可靠性 1.API設計 使用RESTful設計,確保API端點明確,並使用適當的HTTP方法(如POST用於創建,PUT用於更新)。 設計清晰的請求和響應模型,以確保客戶端能夠理解預期格式。 2.數據驗證 在伺服器端進行嚴格的數據驗證,確保接收到的數據符合預期格 ...