Jenkins 代理自動化-dotnet程序

兩種方式

容器部署

本地部署

?容器部署

可自動實現,服務器重啟,容器自動運行

主要將dockerfile 寫好

?本地部署

1.服務器重啟自動運行代理

參考下面的鏈接,只是把程序換成 java程序,提前確認好需要的jdk版本

Ubuntu20.04 設置開機自啟_ubuntu進bos系統-CSDN博客

2.這種方式重啟后,會發現,編譯 dotnet 程序報錯,錯誤如下:

/usr/share/dotnet/sdk/8.0.404/NuGet.targets(490,5): error MSB4018: The "WarnForInvalidProjectsTask" task failed unexpectedly. [/home/jenkins/agent/ /workspace/開發服1/FishServer/Server.sln] /usr/share/dotnet/sdk/8.0.404/NuGet.targets(490,5): error MSB4018: System.InvalidOperationException: Required environment variable 'HOME' is not set. Try setting 'DOTNET_CLI_HOME' or 'HOME' and running the operation [/home/jenkins/agent/ /workspace/開發服1/FishServer/Server.sln] /usr/share/dotnet/sdk/8.0.404/NuGet.targets(490,5): error MSB4018: at NuGet.Common.NuGetEnvironment.GetValueOrThrowMissingEnvVarsDotnet(Func`1 getValue, String home, String dotnetHome) [/home/jenkins/agent/ /workspace/開發服1/FishServer/Server.sln] /usr/share/dotnet/sdk/8.0.404/NuGet.targets(490,5): error MSB4018: at NuGet.Common.NuGetEnvironment.GetHome() [/home/jenkins/agent/ /workspace/開發服1/FishServer/Server.sln] /usr/share/dotnet/sdk/8.0.404/NuGet.targets(490,5): error MSB4018: at NuGet.Common.NuGetEnvironment.<>c.<.cctor>b__20_0() [/home/jenkins/agent/ /workspace/開發服1/FishServer/Server.sln] /usr/share/dotnet/sdk/8.0.404/NuGet.targets(490,5): error MSB4018: at System.Lazy`1.ViaFactory(LazyThreadSafetyMode mode) [/home/jenkins/agent/ /workspace/開發服1/FishServer/Server.sln] /usr/share/dotnet/sdk/8.0.404/NuGet.targets(490,5): error MSB4018: at System.Lazy`1.ExecutionAndPublication(LazyHelper executionAndPublication, Boolean useDefaultConstructor) [/home/jenkins/agent/ /workspace/開發服1/FishServer/Server.sln] /usr/share/dotnet/sdk/8.0.404/NuGet.targets(490,5): error MSB4018: at System.Lazy`1.CreateValue() [/home/jenkins/agent/ /workspace/開發服1/FishServer/Server.sln] /usr/share/dotnet/sdk/8.0.404/NuGet.targets(490,5): error MSB4018: at NuGet.Common.NuGetEnvironment.GetFolderPath(SpecialFolder folder) [/home/jenkins/agent/ /workspace/開發服1/FishServer/Server.sln] /usr/share/dotnet/sdk/8.0.404/NuGet.targets(490,5): error MSB4018: at NuGet.Common.NuGetEnvironment.GetFolderPath(NuGetFolderPath folder) [/home/jenkins/agent/ /workspace/開發服1/FishServer/Server.sln] /usr/share/dotnet/sdk/8.0.404/NuGet.targets(490,5): error MSB4018: at NuGet.Common.PathUtility.CheckIfFileSystemIsCaseInsensitive() [/home/jenkins/agent/ /workspace/開發服1/FishServer/Server.sln] /usr/share/dotnet/sdk/8.0.404/NuGet.targets(490,5): error MSB4018: at System.Lazy`1.ViaFactory(LazyThreadSafetyMode mode) [/home/jenkins/agent/ /workspace/開發服1/FishServer/Server.sln] /usr/share/dotnet/sdk/8.0.404/NuGet.targets(490,5): error MSB4018: at System.Lazy`1.ExecutionAndPublication(LazyHelper executionAndPublication, Boolean useDefaultConstructor) [/home/jenkins/agent/ /workspace/開發服1/FishServer/Server.sln] /usr/share/dotnet/sdk/8.0.404/NuGet.targets(490,5): error MSB4018: at System.Lazy`1.CreateValue() [/home/jenkins/agent/ /workspace/開發服1/FishServer/Server.sln] /usr/share/dotnet/sdk/8.0.404/NuGet.targets(490,5): error MSB4018: at NuGet.Common.PathUtility.get_IsFileSystemCaseInsensitive() [/home/jenkins/agent/ /workspace/開發服1/FishServer/Server.sln] /usr/share/dotnet/sdk/8.0.404/NuGet.targets(490,5): error MSB4018: at NuGet.Common.PathUtility.GetStringComparerBasedOnOS() [/home/jenkins/agent/ /workspace/開發服1/FishServer/Server.sln] /usr/share/dotnet/sdk/8.0.404/NuGet.targets(490,5): error MSB4018: at NuGet.Build.Tasks.WarnForInvalidProjectsTask.Execute() [/home/jenkins/agent/ /workspace/開發服1/FishServer/Server.sln] /usr/share/dotnet/sdk/8.0.404/NuGet.targets(490,5): error MSB4018: at Microsoft.Build.BackEnd.TaskExecutionHost.Execute() [/home/jenkins/agent/ /workspace/開發服1/FishServer/Server.sln] /usr/share/dotnet/sdk/8.0.404/NuGet.targets(490,5): error MSB4018: at Microsoft.Build.BackEnd.TaskBuilder.ExecuteInstantiatedTask(TaskExecutionHost taskExecutionHost, TaskLoggingContext taskLoggingContext, TaskHost taskHost, ItemBucket bucket, TaskExecutionMode howToExecuteTask) [/home/jenkins/agent/ /workspace/開發服1/FishServer/Server.sln] Build FAILED. /usr/share/dotnet/sdk/8.0.404/NuGet.targets(490,5): error MSB4018: The "WarnForInvalidProjectsTask" task failed unexpectedly. [/home/jenkins/agent/ /workspace/開發服1/FishServer/Server.sln] /usr/share/dotnet/sdk/8.0.404/NuGet.targets(490,5): error MSB4018: System.InvalidOperationException: Required environment variable 'HOME' is not set. Try setting 'DOTNET_CLI_HOME' or 'HOME' and running the operation [/home/jenkins/agent/ /workspace/開發服1/FishServer/Server.sln] /usr/share/dotnet/sdk/8.0.404/NuGet.targets(490,5): error MSB4018: at NuGet.Common.NuGetEnvironment.GetValueOrThrowMissingEnvVarsDotnet(Func`1 getValue, String home, String dotnetHome) [/home/jenkins/agent/ /workspace/開發服1/FishServer/Server.sln] /usr/share/dotnet/sdk/8.0.404/NuGet.targets(490,5): error MSB4018: at NuGet.Common.NuGetEnvironment.GetHome() [/home/jenkins/agent/ /workspace/開發服1/FishServer/Server.sln] /usr/share/dotnet/sdk/8.0.404/NuGet.targets(490,5): error MSB4018: at NuGet.Common.NuGetEnvironment.<>c.<.cctor>b__20_0() [/home/jenkins/agent/ /workspace/開發服1/FishServer/Server.sln] /usr/share/dotnet/sdk/8.0.404/NuGet.targets(490,5): error MSB4018: at System.Lazy`1.ViaFactory(LazyThreadSafetyMode mode) [/home/jenkins/agent/ /workspace/開發服1/FishServer/Server.sln] /usr/share/dotnet/sdk/8.0.404/NuGet.targets(490,5): error MSB4018: at System.Lazy`1.ExecutionAndPublication(LazyHelper executionAndPublication, Boolean useDefaultConstructor) [/home/jenkins/agent/ /workspace/開發服1/FishServer/Server.sln] /usr/share/dotnet/sdk/8.0.404/NuGet.targets(490,5): error MSB4018: at System.Lazy`1.CreateValue() [/home/jenkins/agent/ /workspace/開發服1/FishServer/Server.sln] /usr/share/dotnet/sdk/8.0.404/NuGet.targets(490,5): error MSB4018: at NuGet.Common.NuGetEnvironment.GetFolderPath(SpecialFolder folder) [/home/jenkins/agent/ /workspace/開發服1/FishServer/Server.sln] /usr/share/dotnet/sdk/8.0.404/NuGet.targets(490,5): error MSB4018: at NuGet.Common.NuGetEnvironment.GetFolderPath(NuGetFolderPath folder) [/home/jenkins/agent/ /workspace/開發服1/FishServer/Server.sln] /usr/share/dotnet/sdk/8.0.404/NuGet.targets(490,5): error MSB4018: at NuGet.Common.PathUtility.CheckIfFileSystemIsCaseInsensitive() [/home/jenkins/agent/ /workspace/開發服1/FishServer/Server.sln] /usr/share/dotnet/sdk/8.0.404/NuGet.targets(490,5): error MSB4018: at System.Lazy`1.ViaFactory(LazyThreadSafetyMode mode) [/home/jenkins/agent/ /workspace/開發服1/FishServer/Server.sln] /usr/share/dotnet/sdk/8.0.404/NuGet.targets(490,5): error MSB4018: at System.Lazy`1.ExecutionAndPublication(LazyHelper executionAndPublication, Boolean useDefaultConstructor) [/home/jenkins/agent/ /workspace/開發服1/FishServer/Server.sln] /usr/share/dotnet/sdk/8.0.404/NuGet.targets(490,5): error MSB4018: at System.Lazy`1.CreateValue() [/home/jenkins/agent/ /workspace/開發服1/FishServer/Server.sln] /usr/share/dotnet/sdk/8.0.404/NuGet.targets(490,5): error MSB4018: at NuGet.Common.PathUtility.get_IsFileSystemCaseInsensitive() [/home/jenkins/agent/ /workspace/開發服1/FishServer/Server.sln] /usr/share/dotnet/sdk/8.0.404/NuGet.targets(490,5): error MSB4018: at NuGet.Common.PathUtility.GetStringComparerBasedOnOS() [/home/jenkins/agent/ /workspace/開發服1/FishServer/Server.sln] /usr/share/dotnet/sdk/8.0.404/NuGet.targets(490,5): error MSB4018: at NuGet.Build.Tasks.WarnForInvalidProjectsTask.Execute() [/home/jenkins/agent/ /workspace/開發服1/FishServer/Server.sln] /usr/share/dotnet/sdk/8.0.404/NuGet.targets(490,5): error MSB4018: at Microsoft.Build.BackEnd.TaskExecutionHost.Execute() [/home/jenkins/agent/ /workspace/開發服1/FishServer/Server.sln] /usr/share/dotnet/sdk/8.0.404/NuGet.targets(490,5): error MSB4018: at Microsoft.Build.BackEnd.TaskBuilder.ExecuteInstantiatedTask(TaskExecutionHost taskExecutionHost, TaskLoggingContext taskLoggingContext, TaskHost taskHost, ItemBucket bucket, TaskExecutionMode howToExecuteTask) [/home/jenkins/agent/ /workspace/開發服1/FishServer/Server.sln] 0 Warning(s) 1 Error(s) Time Elapsed 00:00:00.75
Build step 'Execute shell' marked build as failure
Skipped archiving because build is not successful
SSH: Current build result is [FAILURE], not going to run.
Performing Post build task...
Match found for : : True
Logical operation result is TRUE

本人,進入這個代理工作目錄,編譯是可以的,但是不知道為什么,代理無法編譯

3.ps查看代理的啟動用戶:

root         835  1.1  1.4 12800956 469660 ?     Sl   13:00   1:03 java -jar agent.jar -url ...

確實為root,應該不是權限的問題,查找報錯日志,也未發現 Permission 或?Deny 相關內容

4.1現在只能先看最上面一條錯誤,看看有沒有什么線索

MSB4018:

MSB4018 - MSBuild | Microsoft Learn

再加上?

Required environment variable 'HOME' is not set. Try setting 'DOTNET_CLI_HOME' or 'HOME' and running the operation

?可以確定第一條錯誤應該是找不到這個條件變量

4.2HOME其實就是用戶的家目錄

原來我手動啟動 jenkins代理,使用的是 ubuntu, 所以,HOME=/home/ubuntu

5.3是否可以在 配置 開啟啟動時,配置 環境變量,編輯?/etc/systemd/system/rc-local.service

[Unit]
Description=/etc/rc.local Compatibility
Documentation=man:systemd-rc-local-generator(8)
ConditionFileIsExecutable=/etc/rc.local
After=network.target[Service]
Type=forking
ExecStart=/etc/rc.local start
TimeoutSec=0
RemainAfterExit=yes
GuessMainPID=no# 在這里添加環境變量,可添加多個
Environment=HOME=/home/ubuntu[Install]
WantedBy=multi-user.target  
Alias=rc-local.service

從其服務器后,編譯正常

本文來自互聯網用戶投稿,該文觀點僅代表作者本人,不代表本站立場。本站僅提供信息存儲空間服務,不擁有所有權,不承擔相關法律責任。
如若轉載,請注明出處:http://www.pswp.cn/diannao/79715.shtml
繁體地址,請注明出處:http://hk.pswp.cn/diannao/79715.shtml
英文地址,請注明出處:http://en.pswp.cn/diannao/79715.shtml

如若內容造成侵權/違法違規/事實不符,請聯系多彩編程網進行投訴反饋email:809451989@qq.com,一經查實,立即刪除!

相關文章

從Archery到NineData:積加科技驅動數據庫研發效能與數據安全雙升級

積加科技作為國內領先的企業級數字化解決方案服務商&#xff0c;依托自研的 A4X 數字化平臺&#xff08;https://a4x.io/&#xff09;&#xff0c;專注于為全球范圍內的視覺物聯網&#xff08;IoT&#xff09;設備提供 PaaS/SaaS 服務。致力于運用 AI 技術賦能物聯網世界的各類…

SpringBoot整合Logback日志框架深度實踐

一、依賴與默認集成機制 SpringBoot從2.x版本開始默認集成Logback日志框架,無需手動添加額外依賴。當項目引入spring-boot-starter-web時,該組件已包含spring-boot-starter-logging,其底層實現基于Logback+SLF4J組合。這種設計使得開發者只需關注業務日志的輸出規則,無需處…

自由學習記錄(56)

從貼圖空間&#xff08;texture space&#xff09;將值還原到切線空間&#xff08;tangent space&#xff09;向量 tangentNormal.xy (packedNormal.xy * 2 - 1) * _BumpScale; 背后的知識點&#xff1a;法線貼圖中的 RGB 是在 0~1 范圍內編碼的向量 所以貼圖法線是怎么“壓…

【mysql】mysql疑難問題:實際場景解釋什么是排它鎖 當前讀 快照讀

注&#xff1a; 理解本文 前置需要掌握的基礎知識&#xff1a;事務隔離、鎖的概念、并發知識&#xff1b; 事務隔離 尤其是事務延伸問題 是個重難點&#xff0c;絕非八股文那幾句話就能說完的&#xff0c;在實際場景中&#xff0c;分析起來有一定難度 author: csdn博主 孟秋與你…

Python:使用web框架Flask搭建網站

Date: 2025.04.19 20:30:43 author: lijianzhan Flask 是一個輕量級的 Python Web 開發框架&#xff0c;以簡潔靈活著稱&#xff0c;適合快速構建中小型 Web 應用或 API 服務。以下是 Flask 的核心概念、使用方法和實踐指南 Flask 的核心特點&#xff1a; 輕量級 核心代碼僅約…

層次式架構核心:中間層的功能、優勢與技術選型全解析

層次式架構中的中間層是整個架構的核心樞紐&#xff0c;承擔著多種重要職責&#xff0c;在功能實現、優勢體現以及技術選型等方面都有豐富的內容&#xff0c;以下為你詳細介紹&#xff1a; 一、功能 1.業務邏輯處理 復雜規則運算&#xff1a;在許多企業級應用中&#xff0c;…

網絡--應用層自定義協議與序列化

目錄 4-1 應用層 4-2 重新理解 read、write、recv、send 和 tcp 為什么支持全雙工 4-3 開始實現 4-1 應用層 我們程序員寫的一個個解決我們實際問題 , 滿足我們日常需求的網絡程序 , 都是在應用 層 . 再談 " 協議 " 協議是一種 " 約定 ". socke…

fastlio用mid360錄制的bag包離線建圖,提示消息類型錯誤

我用mid360錄制的bag包&#xff0c;激光雷達的數據類型是sensor_msgs::PointCloud2&#xff0c;但是運行fast_lio中的mid360 launch文件&#xff0c;會報錯&#xff08;沒截圖&#xff09;&#xff0c;顯示無法從livox_ros_driver2::CustomMsg轉換到sensor_msgs::PointCloud2。…

C# WinForm窗口TextBox控件只能輸入數字(包括小數)并且恢復Ctrl+C復制和Ctrl+V粘貼功能

1. 前言 最近在寫定GPS定位時&#xff0c;經緯度是用的double類型&#xff0c;并且經緯度的要求是小數點后最少6位&#xff0c;多了能達到17位&#xff0c;又遇到了常用的TextBox控件只能輸入數字、小數的功能&#xff0c;因為有一年多沒有寫程序&#xff0c;現在再來寫這些感…

【MySQL數據庫】數據類型

目錄 1&#xff0c;數據類型分類 2&#xff0c;bit類型 3&#xff0c;小數類型 3-1&#xff0c;float/double類型 3-2&#xff0c;decimal類型 4&#xff0c;字符串類型 4-1&#xff0c;char 4-2&#xff0c;varchar 5&#xff0c;日期和時間類型 6&#xff0c;enum和…

Spark-SQL核心編程2

路徑問題 相對路徑與絕對路徑&#xff1a;建議使用絕對路徑&#xff0c;避免復制粘貼導致的錯誤&#xff0c;必要時將斜杠改為雙反斜杠。 數據處理與展示 SQL 風格語法&#xff1a;創建臨時視圖并使用 SQL 風格語法查詢數據。 DSL 風格語法&#xff1a;使用 DSL 風格語法查詢…

pandas庫詳解

CONTENT 基本數據結構SeriesDataFrame 數據讀取與寫入讀取 CSV 文件寫入 CSV 文件 數據清洗處理缺失值數據類型轉換 數據操作索引與切片數據合并數據分組與聚合 數據可視化 基本數據結構 Series Series 屬于一維標記數組&#xff0c;由一組數據和對應的索引構成。 import pa…

黑馬商城(五)微服務保護和分布式事務

一、雪崩問題 二、雪崩-解決方案&#xff08;服務保護方案&#xff09; 請求限流&#xff1a; 線程隔離&#xff1a; 服務熔斷&#xff1a; 服務保護組件&#xff1a; 三、Sentinel 引入依賴&#xff1a; <!--sentinel--> <dependency><groupId>com.aliba…

洛谷P1312 [NOIP 2011 提高組] Mayan 游戲

題目 #算法/進階搜索 思路: 根據題意,我們可以知道,這題只能枚舉,剪枝,因此,我們考慮如何枚舉,剪枝. 首先,我們要定義下降函數down(),使得小木塊右移時,能夠下降到最低處,其次,我們還需要寫出判斷函數,判斷矩陣內是否有小木塊沒被消除.另外,我們還需要消除函數,將矩陣內三個相連…

基于Redis的3種分布式ID生成策略

在分布式系統設計中&#xff0c;全局唯一ID是一個基礎而關鍵的組件。隨著業務規模擴大和系統架構向微服務演進&#xff0c;傳統的單機自增ID已無法滿足需求。高并發、高可用的分布式ID生成方案成為構建可靠分布式系統的必要條件。 Redis具備高性能、原子操作及簡單易用的特性&…

Spotlight on Mysql詳細介紹

1. 版本............................................................................................................................................1 2. 使用介紹...............................................................................................…

背包 DP 詳解

文章目錄 背包DP01 背包完全背包多重背包二進制優化單調隊列優化 小結 背包DP 背包 DP&#xff0c;說白了就是往一個背包里扔東西&#xff0c;求最后的最大價值是多少&#xff0c;一般分為了三種&#xff1a;01 背包、完全背包和多重背包。而 01 背包則是一切的基礎。 01 背包…

二級評論列表-Java實現

二級評論列表是很常見的功能&#xff0c;文章記錄了新手用Java實現的具體邏輯。 整體實現邏輯是先用2個sql&#xff0c;分別查出兩層數據。然后用java在service中實現數據組裝&#xff0c;返給前端。這種實現思路好處是SQL簡潔&#xff0c;邏輯分明&#xff0c;便于維護。 一…

快速入手-基于python和opencv的人臉檢測

1、安裝庫 pip install opencv-python 如果下載比較卡的話&#xff0c;指向國內下載地址&#xff1a; pip3 install opencv-python -i https://pypi.tuna.tsinghua.edu.cn/simple 2、下載源碼 https://opencv.org/ windows11對應的版本下載&#xff1a; https://pan.baidu…

GitLab本地安裝指南

當前GitLab的最新版是v17.10&#xff0c;安裝地址&#xff1a;https://about.gitlab.com/install/。當然國內也可以安裝極狐GitLab版本&#xff0c;極狐GitLab 是 GitLab 中國發行版&#xff08;JH&#xff09;。極狐GitLab支持龍蜥&#xff0c;歐拉等國內的操作系統平臺。安裝…