测试平台集成 Gitlab-CI 时序图

1、增加 Gitlab-CI 流水线配置

# .gitlab-ci.yml
stages:
  - autotest

自动化测试:
  image: centos:7
  stage: autotest
  variables: 
    {
      BASE_URL: 'http://xxx:8000', # 测试平台后端接口ip
      QUERY: '/api/fastrunner/gitlab-ci/',
      TASK_IDS: '22,70',  # 需要运行的任务,多个任务用逗号分隔;不传或者为空,则运行所有的任务
      PROJECT: 7,  # 测试平台中的项目id
      FULL_URL: '$BASE_URL$QUERY',
      START_JOB_USER: '$GITLAB_USER_NAME',
    }
  script:
    - echo start to request test platform...
    - echo $FULL_URL
    - |
      curl -X POST $FULL_URL -H "Content-Type: application/json" -d '{"project": "'"$PROJECT"'", "task_ids": "'"$TASK_IDS"'", "ci_job_id": "'"$CI_JOB_ID"'", "ci_job_url": "'"$CI_JOB_URL"'", "ci_pipeline_id": "'"$CI_PIPELINE_ID"'", "ci_pipeline_url": "'"$CI_PIPELINE_URL"'", "ci_project_id": "'"$CI_PROJECT_ID"'", "ci_project_name": "'"$CI_PROJECT_NAME"'", "ci_project_namespace": "'"$CI_PROJECT_NAMESPACE"'", "start_job_user": "'"$START_JOB_USER"'"}' > report.xml;
    - cat report.xml
    - e=`cat report.xml|grep -Po "(?<=<errors>).*(?=</errors>)"`; echo errors count $e
    - f=`cat report.xml|grep -Po "(?<=<failures>).*(?=</failures>)"`; echo failures count $f
    - echo run test finish...
    - if [[ $e -eq 0  && $f -eq 0 ]]; then exit 0; else exit 1; fi
  after_script:
    - echo $CI_JOB_ID $CI_JOB_STATUS
    - curl -X GET "${FULL_URL}?ci_job_id=${CI_JOB_ID}" > result.txt
    - cat result.txt
  artifacts:
    when: always
    reports:
      junit: report.xml

2、修改配置运行的项目和任务 id

修改两个变量:

3、修改 Gitlab Profile 的 Full name 为中文名

中文名的作用:

5、测试平台 - 在线测试报告地址


6、飞书报告


↙↙↙阅读原文可查看相关链接,并与作者交流