jenkins下后台运行链接Jenkins服务脚本方法

为了编写一个用于在后台运行 Jenkins agent 的批处理脚本,你可以使用 start 命令来启动 Java 进程并将其设置为在后台运行。以下是一个示例批处理脚本 run_agent.bat:

bat

@echo off
setlocal

REM Set the path to the Jenkins agent JAR file
set AGENT_JAR_PATH=C:\path\to\agent.jar

REM Set the JNLP URL for the Jenkins agent
set JNLP_URL=http://127.0.0.1:8000/com/A40%5FU8/jenkins-agent.jnlp

REM Set the secret for the Jenkins agent
set SECRET=XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

REM Set the working directory for the Jenkins agent
set WORK_DIR=D:\jenkins_home

REM Start the Jenkins agent in the background
start /b java -Xrs -jar "%AGENT_JAR_PATH%" -jnlpUrl "%JNLP_URL%" -secret "%SECRET%" -workDir "%WORK_DIR%"

REM Optional: Uncomment the following line if you want to wait for the process to finish
REM wait %1

echo Jenkins agent started in the background.
endlocal

设置变量:
AGENT_JAR_PATH:Jenkins agent JAR 文件的路径。
JNLP_URL࿱

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值