【问题标题】:tagging releases in ansible and repo name以 ansible 和 repo 名称标记发布
【发布时间】:2020-06-16 11:32:26
【问题描述】:

我之前使用语义标签来标记我的版本,但现在我有一个要求,即每个版本都将附加一个名称和编号,例如 rel-1.0.1、rel-1.0.2 ... 所以如果我做对了,我就不能再使用这个库了,因为我需要专门控制标签。 所以我使用 ansible,我发现了这个很酷的页面: https://docs.ansible.com/ansible/latest/modules/github_release_module.html

- name: Create a new release
  github_release:
    token: tokenabc1234567890
    user: testuser
    repo: testrepo
    action: create_release
    tag: test
    target: master
    name: My Release
    body: Some description

现在我很困惑。如果我的仓库是这样的,则在仓库名称中:git@github.mycompany.com:test/test-backend.git

如果我只是将 test-backend.git 放在 repo 名称部分,那将如何解决和工作?我不应该放完整路径吗?

【问题讨论】:

    标签: git ansible ansible-2.x


    【解决方案1】:

    the docs of github3.py 看来,必须使用专用方法github.enterprise_login(url="https://github.mycompany.com", ...) 其中regrettably v2.9.5 does not support

    据我所知,您唯一的办法是将github_release.py 复制到您的剧本的library 文件夹as described by the fine manual 并修补模块以接受server_url 属性,例如

    --- a/github_release.py 2020-01-20 13:12:06.000000000 -0800
    +++ b/github_release.py 2020-01-20 13:12:06.000000000 -0800
    @@ -145,6 +145,7 @@
     def main():
         module = AnsibleModule(
             argument_spec=dict(
    +            server_url=dict(type='str', required=False),
                 repo=dict(required=True),
                 user=dict(required=True),
                 password=dict(no_log=True),
    @@ -168,6 +169,7 @@
             module.fail_json(msg=missing_required_lib('github3.py >= 1.0.0a3'),
                              exception=GITHUB_IMP_ERR)
    
    +    server_url = module.params['server_url']
         repo = module.params['repo']
         user = module.params['user']
         password = module.params['password']
    @@ -182,12 +184,17 @@
    
         # login to github
         try:
    +        login_mth = github3.login
    +        login_kwargs = {}
    +        if server_url:
    +            login_mth = github3.enterprise_login
    +            login_kwargs['url'] = server_url
             if password:
    -            gh_obj = github3.login(user, password=password)
    +            login_kwargs['username'] = user
    +            login_kwargs['password'] = password
             elif login_token:
    -            gh_obj = github3.login(token=login_token)
    -        else:
    -            gh_obj = github3.GitHub()
    +            login_kwargs['token'] = login_token
    +        gh_obj = login_mth(**login_kwargs)
    
             # test if we're actually logged in
             if password or login_token:
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2017-04-01
      • 1970-01-01
      • 2012-06-06
      • 1970-01-01
      • 2021-07-19
      • 2019-10-19
      • 1970-01-01
      • 2015-02-14
      相关资源
      最近更新 更多