gitlab-ci.yml保存自定义的数据,并保存log CICD

复制代码
stages:
  - build
  - test
  - deploy

build:
  stage: build
  only:
    - android_task
    - ios_task
  tags:
    - tcoe_test
  script:
    - echo $USER
    - echo "build"

test:
  stage: test
  only:
    - android_task
    - ios_task
    - McvAccount
    - HkAccount
  tags:
    - tcoe_test
#  before_script:
#    - export MAVEN_HOME=/Users/user/mydata/apache-maven-3.8.6/bin
  script:
    - echo $USER
    - echo "test"
    - pwd
    - mvn clean
   - mvn clean \>\> maven.log 2\>\&1
#    - mvn test -Dplatform=api -Denv=stage -DtestngXmlFile="src/main/resources/suite/all/api_cicd.xml"
#    - mvn test -Denv=stage -Dplatform=mobile -Dmobile=ios -DtestngXmlFile="src/main/resources/suite/channel/mobile_cicd.xml"
#    - mvn test -Denv=stage -Dplatform=mobile -Dmobile=android -DtestngXmlFile="src/main/resources/suite/channel/mobile_android_cicd.xml"
#    - mvn clean test -Denv=stage -Dplatform=api -DtestngXmlFile="src/main/resources/suite/all/create_hk_account.xml"
    - mvn test -Denv=stage -Dplatform=api -DtestngXmlFile="src/main/resources/suite/all/sta_api.xml" \>\> maven.log 2\>\&1
  artifacts:
    when: always
    paths:
      - target/
      - TestReport/
- maven.log
    expire_in: 1 week
    reports:
      junit:
        - target/surefire-reports/TEST-TestSuite.xml
        - target/surefire-reports/testng-failed.xml
        - target/surefire-reports/testng-results.xml
#  allow_failure: true

deploy:
  stage: deploy
  only:
    - McvAccount
    - HkAccount
  tags:
    - tcoe_test
  script:
    - sh readAccount.sh

保存log

上面脚本红色部分,用于保存log

打开对应的Job,点击Browser

可以看到保存的自定义文件,点击进去,可以下载该文件

保存自定义的数据

复制代码
deploy:
  stage: deploy
  only:
    - McvAccount
    - HkAccount
  tags:
    - tcoe_test
  script:
    - sh readAccount.sh

另外新建一个job,去读取保存的文件,然后逐行读取

复制代码
#!/bin/bash

# 指定文件路径
file_path="./TestReport/zephyrscale/createAccountData.txt"

# 逐行读取文件
while IFS= read -r line
do
  # 在这里处理每一行的内容,例如打印或者进行其他操作
  echo "$line"
done < "$file_path"
相关推荐
71777710 小时前
2026年CI/CD工具选哪家比较好:主流方案对比与Gitee选型解析
ci/cd·gitee
极小狐10 小时前
极狐GitLab万人并发架构实践,大规模组织的扩容路线图
架构·gitlab·极狐gitlab
smartpi_ai1 天前
机芯智能离线语音模块实战问答:SU-03T、CI-03T、SU-63T 与 JX-A7T 高频问题排查
人工智能·单片机·嵌入式硬件·ci/cd·语音识别
Lvan的前端笔记1 天前
GitLab CI 环境变量整理
ci/cd·gitlab
李迟2 天前
CICD实例:解决GitLab Runner无法执行CICD问题
gitlab
梯度下降者3 天前
二、自动化运维架构师的三大核心能力
ci/cd·架构师·自动化运维·iac·平台工程
长不大的杨瑞杰3 天前
OpenCode v2 CI 与自动化实战:无交互运行、权限收口与制品闭环
运维·人工智能·ci/cd·自动化·软件工程·1024程序员节
Madison-No74 天前
Jenkins持续集成
运维·ci/cd·jenkins
hanjq_code4 天前
gitlab本地文件 跨分支 忽略改动 不提交
gitlab
极小狐4 天前
极狐GitLab集群高可用方案,多节点架构与故障自愈实践
架构·gitlab·高可用·极狐gitlab