我使用jenkins-cli create node命令创建了一个jenkins节点。节点创建成功,我可以在web界面中看到它。
NODE_NAME=$1
LABEL=$2
cat <<EOF | java -jar jenkins-cli.jar -s http://myjenkins/jenkins/ create-node --username userId --password testPwd $1
<?xml version='1.0' encoding='UTF-8'?>
<slave>
<name>${NODE_NAME}</name>
<description></description>
<remoteFS>/Users/jenkins1/Desktop/workspace</remoteFS>
<numExecutors>1</numExecutors>
<mode>EXCLUSIVE</mode>
<retentionStrategy class="hudson.slaves.RetentionStrategy$Always"/>
<launcher class="hudson.plugins.sshslaves.SSHLauncher" plugin="ssh-slaves@1.22">
<host>test</host>
<port>22</port>
<credentialsId>test</credentialsId>
<maxNumRetries>0</maxNumRetries>
<retryWaitTime>0</retryWaitTime>
<sshHostKeyVerificationStrategy class="hudson.plugins.sshslaves.verifiers.KnownHostsFileKeyVerificationStrategy"/>
</launcher>
<label>${LABEL}</label>
<nodeProperties>
<hudson.slaves.EnvironmentVariablesNodeProperty>
<envVars serialization="custom">
<unserializable-parents/>
<tree-map>
<default>
<comparator class="hudson.util.CaseInsensitiveComparator"/>
</default>
<int>1</int>
<string>MVN_REPOS</string>
<string>/Users/jenkins1/Desktop/workspace</string>
</tree-map>
</envVars>
</hudson.slaves.EnvironmentVariablesNodeProperty>
</nodeProperties>
</slave>
EOF但是,在使用jenkins-cli创建节点之后,当我尝试获取节点时,我没有得到这样的节点错误。但是,在通过Jenkins UI保存配置后,我能够获得节点。你能帮我修复这个错误吗?
java -jar jenkins-cli.jar -s测试获取节点‘http://myjenkins/jenkins/’--用户名userId --密码testPwd
错误:没有这样的节点‘test’
发布于 2018-02-20 19:06:46
从cli创建节点或作业时,大多数时候必须返回到Jenkins UI并运行"Manage Jenkins >> Reload Configuration from Disk",否则cli更改有时仍然无效。你已经尝试过这样做了吗?
发布于 2018-02-20 19:59:37
@funkfan正如我在我的帖子中提到的,我可以在通过Jenkins UI保存配置后获得节点。在从Jenkins UI保存配置之前,我甚至尝试过jenkins-cli reload-configuration命令。
https://stackoverflow.com/questions/48881111
复制相似问题