admin管理员组文章数量:1356120
I'm using a pipeline variable sent by the web pipeline creation as a condition to start a job. In my case, the variable contains the tags for the cucumber test cases that I would like to execute. If the tags don't match the job shouldn't be created in the pipeline.
What I was able to do is make it work when the tags are empty or the tags contains only one tag. At the moment I sent more than one tag the job doesn't start.
Reading the documentation I found that the '@' character should be replaced by /x40 for the regular expression. But, even having this in mind, I'm not able to do it. I know it should be a small detail and I cannot see it.
The example:
I send the next TAGS variable tag1 and tag2
The jobs are for example:
test-job1:
rules:
if: ($TAGS == null || $TAGS =~ /(\x40tag1|\x40tag3)(?!_)/)
script:
- echo "Multiple tags"
test-job2:
rules:
if: ($TAGS == null || $TAGS =~ /\x40tag2/)
script:
- echo "Single tags"
test-job3:
rules:
if: ($TAGS == null || $TAGS =~ /\x40tag1_Blabla/)
script:
- echo "Single tags"
What I expected is having the test-job1 running. But it is not. On the other hand, if I send the TAGS variable with tag1 the job starts.
I think the problem is (?!_) but I cannot see it.
What am I missing?
I'm using a pipeline variable sent by the web pipeline creation as a condition to start a job. In my case, the variable contains the tags for the cucumber test cases that I would like to execute. If the tags don't match the job shouldn't be created in the pipeline.
What I was able to do is make it work when the tags are empty or the tags contains only one tag. At the moment I sent more than one tag the job doesn't start.
Reading the documentation I found that the '@' character should be replaced by /x40 for the regular expression. But, even having this in mind, I'm not able to do it. I know it should be a small detail and I cannot see it.
The example:
I send the next TAGS variable tag1 and tag2
The jobs are for example:
test-job1:
rules:
if: ($TAGS == null || $TAGS =~ /(\x40tag1|\x40tag3)(?!_)/)
script:
- echo "Multiple tags"
test-job2:
rules:
if: ($TAGS == null || $TAGS =~ /\x40tag2/)
script:
- echo "Single tags"
test-job3:
rules:
if: ($TAGS == null || $TAGS =~ /\x40tag1_Blabla/)
script:
- echo "Single tags"
What I expected is having the test-job1 running. But it is not. On the other hand, if I send the TAGS variable with tag1 the job starts.
I think the problem is (?!_) but I cannot see it.
What am I missing?
Share Improve this question edited Mar 29 at 10:03 j.barrio asked Mar 28 at 7:24 j.barrioj.barrio 1,0581 gold badge15 silver badges38 bronze badges1 Answer
Reset to default 1The problem was that I was using a normal regex, and the rules for the if's in GitLab are using the Re2 Syntax, that can be validated in regex101 selecting Golang as Flavor.
At the end my regular expression fix was:
if: ($TAGS == null || $TAGS =~ /(\x40tag1|\x40tag3)\b/)
But it still didn't work until I used double back slash:
if: ($TAGS == null || $TAGS =~ /(\x40tag1|\x40tag3)\\b/)
After this everything worked perfect.
Hope it will be useful to someone.
本文标签: How to usefor cucumber tag variables comparation properly in GitLab rulesStack Overflow
版权声明:本文标题:How to use @ for cucumber tag variables comparation properly in GitLab rules? - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1744050783a2582383.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论