Skip to content

Commit d3ea0ec

Browse files
committed
Check that the branch name follows a simple pattern
1 parent 2b52ae2 commit d3ea0ec

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

Jenkinsfile

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,16 @@ this.helper = new JobHelper(this)
9696
helper.runWithNotification {
9797

9898
stage('Configure') {
99+
// We want to make sure that if we are building a PR that the branch name will not require any escaping of symbols in it.
100+
// Otherwise, it may lead to cryptic build errors.
101+
if (helper.scmSource.branch.name && !(helper.scmSource.branch.name ==~ /^[\w\d\/\\_\-\.]+$/)) {
102+
throw new IllegalArgumentException("""
103+
Branch name ${helper.scmSource.branch.name} contains unexpected symbols.
104+
Only characters, digits and -_.\\/ symbols are allowed in the branch name.
105+
Change the branch name and open a new Pull Request.
106+
""")
107+
}
108+
99109
this.environments = AlternativeMultiMap.create([
100110
jdk: [
101111
// This should not include every JDK; in particular let's not care too much about EOL'd JDKs like version 9

0 commit comments

Comments
 (0)