Skip to content

Commit

Permalink
Only throw FlowInterruptedException when commit message matches patte…
Browse files Browse the repository at this point in the history
…rn (#46)

* Fix default skip message regex pattern

* Add documentation for contributing

* Only throw FlowInterruptedException when commit message matches regex pattern
  • Loading branch information
c42-arthur authored Aug 14, 2023
1 parent fe40b09 commit c89455f
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 3 deletions.
12 changes: 11 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,4 +33,14 @@ pipelinekt is a kotlin library that improves the Jenkinsfile development experie

# getting started
Please see the [quickstart guide](docs/quickstart.md)


# Contributing
1. Fork on GitHub
2. Update minor or major as needed in [version.txt] per [Semantic Versioning 2.0.0](https://semver.org)
3. Ensure all gradle tasks are successful

./gradlew build detek examples:build
4. Apply spotless before each commit

./gradlew spotlessApply
5. Create PR
Original file line number Diff line number Diff line change
Expand Up @@ -13,15 +13,15 @@ import com.code42.jenkins.pipelinekt.core.writer.GroovyWriter

@Suppress("MaxLineLength")
data class CommitMessageBasedSkip(
val regex: String = "\\[ci skip\\]",
val regex: String = "\\\\[ci skip\\\\]",
val result: String = "SUCCESS"
) : ScriptedStep, SingletonStep {
override fun scriptedGroovy(writer: GroovyWriter) {
writer.writeln(
"""
script {
try {
sh "git log --oneline -1 | grep -qE '$regex' && false"
sh "if git log --oneline -1 | grep -qE '$regex'; then exit 1; fi"
} catch(exc) {
throw new FlowInterruptedException(Result.$result)
}
Expand Down

0 comments on commit c89455f

Please sign in to comment.