【问题标题】:How to upload my custom Jenkins Plugin to a Jenkins Server using a Python Script如何使用 Python 脚本将我的自定义 Jenkins 插件上传到 Jenkins 服务器
【发布时间】:2017-06-16 02:12:43
【问题描述】:

我需要在一组 Jenkins 服务器上测试我的自定义 Jenkins 插件 my-plugin.hpi

我怎样才能最好地使用 Python 脚本?

【问题讨论】:

    标签: python jenkins-plugins jenkins-api


    【解决方案1】:

    以下 Python 脚本使用 requests 模块和 Jenkins HTTP API 来执行相同的操作。

    import requests
    ciUrl = 'https://jenkins-server-url/my-ci-name'
    files = {'file': open('my-plugin.hpi', 'rb')}
    headers = {'Authorization':'Basic <base-64-encodeder-username-password>'}
    ### Uploading the HPI plugin file
    r = requests.post(ciUrl + "/pluginManager/uploadPlugin", files=files, headers=headers, verify=False)
    ### Safe Restart the Jenkins to ensure plugin is installed.
    r = requests.post(ciUrl + "/safeRestart", headers=headers, verify=False)
    

    打印(r.text)

    注意 verify=False 确保关闭 SSL 验证。如果您访问的是未知的 Jenkins 服务器,请设置 verify=True。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2014-11-26
      • 1970-01-01
      • 2019-04-19
      • 2023-03-16
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多