Example #1
0
    def get_version_by_title(cls, issue, project_id):
        version_title = issue.fields.fixVersions[
            0].name if issue.fields.fixVersions else None
        if version_title is None:
            # raise CannotFindObjectException(f'issue {issue} does not have fixVersion ! please check the issue !')
            current_app.logger.warning(
                f'issue {issue} does not have fixVersion ! please check the issue !'
            )
            return None
        version = Version.query.filter(
            Version.title == version_title,
            Version.project_id == project_id).first()
        if version:
            version_id = version.id
        else:

            fix_version = jira.version(issue.fields.fixVersions[0].id)
            start_time = fix_version.startDate if fix_version and hasattr(
                fix_version, "startDate") else None
            end_time = fix_version.releaseDate if fix_version and hasattr(
                fix_version, "releaseDate") else None
            VersionBusiness.version_create(
                title=version_title,
                project_id=project_id,
                start_time=start_time,
                end_time=end_time,
                description="jira create",
                creator=1,
            )  # 默认的 版本创建人 1
            version_id = cls.get_version_by_title(issue, project_id)
        return version_id
Example #2
0
 def get_version_by_title(cls, issue, project_id):
     version_title = issue.fields.fixVersions[0].name if issue.fields.fixVersions else None
     if version_title is None:
         raise CannotFindObjectException(f'issue {issue} does not have fixVersion ! please check the issue !')
     version = Version.query.filter(Version.title == version_title,
                                    Version.project_id == project_id).first()
     if version:
         version_id = version.id
     else:
         VersionBusiness.version_create(title=version_title,
                                        project_id=project_id,
                                        start_time=None,
                                        end_time=None,
                                        description="jira create",
                                        creator=1,)  # 默认的 版本创建人 1
         version_id = cls.get_version_by_title(issue, project_id)
     return version_id
Example #3
0
def version_add_handler():
    """
    @api {post} /v1/version/ 新增版本
    @apiName CreateVersion
    @apiGroup 项目
    @apiDescription 新增版本
    @apiParam {string} title 标题
    @apiParam {int} project_id 项目ID
    @apiParam {string} start_time 版本开始时间
    @apiParam {string} end_time 版本结束时间
    @apiParam {int} creator 创建人
    @apiParam {int} publish_status 发布状态0:未发布1:已发布
    @apiParam {string} description 描述
    @apiParam {string} comment 备注
    @apiParamExample {json} Request-Example:
    {
        "title": "str",
        "project_id": 1,
        "start_time": "2018-11-11",
        "end_time": "2018-11-11",
        "creator": 1,
        "publish_status": 1,
        "description": "str",
        "comment": "str"
    }
    @apiSuccessExample {json} Success-Response:
     HTTP/1.1 200 OK
    {
    "code":0,
    "data":[],
    "message":"ok"
    }
    """
    title, project_id, start_time, end_time, description = parse_json_form('versioncreate')
    ret = VersionBusiness.version_create(title, project_id, start_time, end_time, description)

    return json_detail_render(ret)