首页 文章

有没有简单的方法/ API来找出gocd服务器上的管道数量?

提问于
浏览
2

很抱歉这个简短的问题,但只是想知道是否有一个API来查找GoCD服务器上的管道数量 .

4 回答

  • 0

    Pipeline Groups API将在一些JSON解析后为您提供所需的内容 .

    $ curl 'https://ci.example.com/go/api/config/pipeline_groups' \
      -u 'username:password'
    

    返回:

    HTTP/1.1 200 OK
    Content-Type: application/json; charset=utf-8
    
    [
      {
        "pipelines": [
          {
            "stages": [
              {
                "name": "up42_stage"
              }
            ],
            "name": "up42",
            "materials": [
              {
                "description": "URL: https://github.com/gocd/gocd, Branch: master",
                "fingerprint": "2d05446cd52a998fe3afd840fc2c46b7c7e421051f0209c7f619c95bedc28b88",
                "type": "Git"
              }
            ],
            "label": "${COUNT}"
          }
        ],
        "name": "first"
      }
    ]
    
  • 0

    您可以获取config.xml文件并解析它 . from the config repo或通过http .

  • 0

    作为替代方案,您可以从http://yourgoserver/go/cctray.xml获取服务器上的cctray文件并解析它 .

    它包含有关所有管道(包括其阶段)的信息

  • 0

    我建议使用yagocd

    from yagocd import Yagocd
    
    go = Yagocd(server='https://build.gocd.io')
    
    # login as guest
    go._session.get('https://build.gocd.io/go/plugin/interact/gocd.guest.user.auth.plugin/index')
    
    print(len(list(go.pipelines)))
    

相关问题