在.gitlab-ci.yml中设置一个变量,该变量从pom中读取artifactId的名称 [英] set inside .gitlab-ci.yml a variable reading the name of artifactId from pom

查看:1521
本文介绍了在.gitlab-ci.yml中设置一个变量,该变量从pom中读取artifactId的名称的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在.gitlab-ci.yml内部,我们定义了一个变量(仅是项目的artifactId名称)ARTIFACT_ID: myMicroservice-1

Inside .gitlab-ci.yml we define a variable (which is just the artifactId name for the project) ARTIFACT_ID: myMicroservice-1

此变量ARTIFACT_ID被发送到常规微服务,该微服务具有用于发布/部署docker等的所有脚本.

This variable ARTIFACT_ID is sent to a general microservice which has all the scripts to publish/deploy docker, etc.

如何直接从POM文件读取此变量?

How can I read this variable direct from POM file?

pom:

<artifactId>myMicroservice-1</artifactId>

.gitlab-ci.yml:
variables:
  SKIP_UNIT_TESTS_FLAG: "true"
  ARTIFACT_ID: myMicroserverName
  IS_OSL: "true"
  KUBERNETES_NAMESPACE: test

推荐答案

这是用于从pom中获取信息的脚本,在这种情况下,该脚本为artifactId:

This is the script to grab information from pom, in this case, artifactId:

    - export myARTIFACT_ID=$(mvn exec:exec -q -Dexec.executable=echo -Dexec.args='${project.artifactId}')
    - if [[ "$myARTIFACT_ID" == *finishWithWhatEverName]]; then export myVariable="false"; else export myVariable="true";

然后,您可以根据需要使用myVariable.

Then you can use myVariable to whatever you want.

这篇关于在.gitlab-ci.yml中设置一个变量,该变量从pom中读取artifactId的名称的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆