Jenkins-CLI get node 不起作用



我已经使用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 -s http://myjenkins/jenkins/jenkins/get -node'tests' - username userId -password testpwd

错误:没有这样的节点'tests'

从CLI创建节点或作业时,大多数情况。您已经尝试过吗?

@funkfan正如我在帖子中提到的那样,我能够通过Jenkins UI保存配置后获得节点。我什至尝试过jenkins-cli reload-configuration命令,然后再保存jenkins UI的配置而没有任何运气。

最新更新