-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[semver:minor] Merge pull request #44 from ricardo-ch/maven_verify_ve…
…rsion_pattern wip: maven_assert_expression
- Loading branch information
Showing
4 changed files
with
89 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
description: > | ||
Checks that some expression evaluated from the Maven project matches with a certain pattern. | ||
This job will succeed if the expression contains the pattern, and fail otherwise. | ||
Thus it can be used to allow/block flows depending on the value of the expression. | ||
parameters: | ||
expression: | ||
description: 'An expression to evaluate, following the Maven expression syntax but without any surrounding ${...}' | ||
type: string | ||
pattern: | ||
description: 'The regex pattern to match against the expression' | ||
type: string | ||
pom_file: | ||
description: 'The pom file to use' | ||
type: string | ||
default: 'pom.xml' | ||
|
||
steps: | ||
- run: | ||
name: Verify that expression contains pattern | ||
command: | | ||
EXPR=<< parameters.expression >> | ||
PATTERN=<< parameters.pattern >> | ||
RESULT=$(./mvnw help:evaluate -Dexpression=$EXPR -q -DforceStdout -f << parameters.pom_file >>) | ||
if [[ ! "$RESULT" =~ $PATTERN ]]; then | ||
echo "The expression $EXPR=[$RESULT] does not match with the pattern $PATTERN" | ||
exit 1 | ||
fi |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
description: > | ||
Checks that the Maven project (of the provided pom file) has a SNAPSHOT version, otherwise it fails. | ||
Typically used to force that branch builds of library modules have a -SNAPSHOT version when manually deployed. | ||
parameters: | ||
pom_file: | ||
description: 'The pom file to use' | ||
type: string | ||
default: 'pom.xml' | ||
|
||
executor: | ||
name: 'maven_docker' | ||
|
||
steps: | ||
- checkout | ||
- maven_assert_expression: | ||
expression: 'project.version' | ||
pattern: '^.*-SNAPSHOT$' | ||
pom_file: << parameters.pom_file >> |