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.mzph.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;欧拉等国内的操作系统平台。安装…