【问题标题】:How to change Jenkins Node details through python jenkinsapi如何通过 python jenkinsapi 更改 Jenkins 节点详细信息
【发布时间】:2018-02-24 09:56:22
【问题描述】:

我已经阅读了很多 Jenkins API 文档。但是我没有任何方法可以使用 Python API 更改 Jenkins 节点的详细信息。 基本上,这些是我要更改的字段:

1) # 执行者 2) 标签 3) 主机

enter image description here

【问题讨论】:

    标签: python jenkins jenkins-pipeline jenkins-cli


    【解决方案1】:
    import jenkins.model.*
    import hudson.model.*
    import hudson.slaves.*
    import hudson.plugins.sshslaves.*
    import java.util.ArrayList;
    import hudson.slaves.EnvironmentVariablesNodeProperty.Entry;
    
      Slave slave = new DumbSlave(
                        "agent-node","Agent node description",
                        "/home/jenkins",
                        "1",
                        Node.Mode.NORMAL,
                        "agent-node-label",
                        new SSHLauncher("agenNode",22,"user","password","","","","",""),
                        new RetentionStrategy.Always(),
                        new LinkedList())
      Jenkins.instance.addNode(slave)
    

    【讨论】:

    • 我对 groovy 代码非常陌生。我已经阅读了一些教程,但没有得到太多信息。请向我提供我们如何执行这个 groovy 代码和一些基本知识的信息。
    • 运行脚本,Jenkins --> 管理 --> 脚本控制台,只需复制脚本并运行它或你的 jenkinshost:8080/script
    • @Mor Lajb 问题是关于“使用 Python API”,你的脚本似乎不是 python
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2012-08-07
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多