我是GITLAB和GATLING的新手。我正在尝试使用上述工具实现左移性能测试作为CI / CD管道的一部分。虽然我非常精通Jenkins和Jmeter。我正在尝试将Gitlab Pipeline ID写入gatling模拟日志文件。
我已经引用了GITLAB变量,$ CI_PIPELINE_IID用于公开管道执行ID。在scala的情况下,我可以使用JAVA_OPTS获取或注入环境变量,但无法获取gitlab管道ID。
我做了一些进一步的研究,我能够在Gitlab控制台上打印管道ID
$ echo $CI_PIPELINE_ID
141683
此外,我作为scala [Gitlab]的一部分阅读,CI变量可以在构建期间用作ENV变量,因此将它们检索为System.getEnv(“$ CI_PIPELINE_IID”)
但是当我尝试相同的时候我得到空值。
val varPipelineId = System.getenv("$CI_PIPELINE_ID")
println(varPipelineId)
控制台日志:
$ echo $CI_PIPELINE_ID
141694
$ mkdir /opt/gatling/user-files/simulations/cloudnative/
$ cp gatling-reports/cloudnativems.scala /opt/gatling/user-files/simulations/cloudnative/
$ /opt/gatling/bin/gatling.sh -s cloudnative.cloudnativems
GATLING_HOME is set to /opt/gatling
null
第二部分要求:我想在gatling simulation.log文件中写入每个日志条目的管道ID值
simulation.log的实际格式
REQUEST 1 account_movement_post 1553663401413 1553663404218 KO status.find.in(200,201,202,203,204,205,206,207,208,209,303), found 500
修改了simulation.log的格式
REQUEST 1 account_movement_post 1553663401413 1553663404218 KO status.find.in(200,201,202,203,204,205,206,207,208,209,303), found 500 [pipeline_id]
我做了一个逻辑上的改变 - 从环境变量中删除了$
val varPipelineId = System.getenv("CI_PIPELINE_ID")
println(varPipelineId)
输出:
$ echo $CI_PIPELINE_ID
141714
$ mkdir /opt/gatling/user-files/simulations/cloudnative/
$ cp gatling-reports/cloudnativems.scala /opt/gatling/user-files/simulations/cloudnative/
$ /opt/gatling/bin/gatling.sh -s cloudnative.cloudnativems
GATLING_HOME is set to /opt/gatling
Some(141714)