Skip to content

Conversation

ANGkeith
Copy link
Collaborator

@ANGkeith ANGkeith commented Sep 13, 2024

fixes #1335

Might have made the regex now even more confusing 😅

but hopefully this will make the rules evaluation behavior closer to gitlab.com's one...

let value = `${expandWith.variable(name)}`;
if (value.startsWith("\"/") && value.endsWith("/\"")) {
value = value.substring(1).slice(0, -1);
}
Copy link
Collaborator Author

@ANGkeith ANGkeith Sep 13, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Removed this chunk in order to support the following scenario:

job:
  image: alpine
  variables:
    teststring: "/test/url"
    pattern: /test//
  script:
    - echo works
  rules:
    - if: '$teststring =~ $pattern' # gcl works
    - if: $teststring =~ /test//      # gcl does not work but it's expected to work

{if: "$VAR1 && (($VAR2 =~ /ci-skip-job-/ && $VAR2 =~ $VAR3) || ($VAR2 =~ /ci-skip-stage-/ && $VAR2 =~ $VAR3))", when: "manual"},
];
variables = {VAR1: "val", VAR2: "ci-skip-job-", VAR3: "ci-skip-job-"};
variables = {VAR1: "val", VAR2: "ci-skip-job-", VAR3: "/ci-skip-job-/"};
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

rhs here should be a regex
image

@ANGkeith ANGkeith force-pushed the fix/#1335 branch 3 times, most recently from f98ab80 to b3e19c2 Compare September 13, 2024 13:20
@ANGkeith ANGkeith changed the title fix: edge cases in regex used for evaluate rules regex fix: handle more edge cases in evaluateRuleIf Sep 13, 2024
Copy link

sonarqubecloud bot commented Sep 16, 2024

Copy link
Owner

@firecow firecow left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Lets go

@firecow
Copy link
Owner

firecow commented Sep 16, 2024

@ANGkeith You want a new version now?

@ANGkeith
Copy link
Collaborator Author

@ANGkeith You want a new version now?

sure thing. thanks

@firecow firecow merged commit ee0b8c2 into master Sep 16, 2024
10 checks passed
@firecow firecow deleted the fix/#1335 branch September 16, 2024 07:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

backslash then double slash within double quotes throws syntax error

2 participants