Docker Community Forums

Share and learn in the Docker community.

Regex in Automated build


(James Martin) #1

Hi folks,

What regex engine does Docker Cloud use? I’m trying to match JIRA ticket ID’s, which is what we use for branches.
We essentially want Docker Cloud to perform an automated build for commits to any branch that has a JIRA ID, such as:

ABC-1234
AB-12
AB-2
etc

Here’s what I’ve tried so far, which validates on https://regex101.com/r/cPiV5y/1

/(?:[a-z]+/|^)([a-z]{1,4}-\d{1,5})/i


(Grayaii) #2

I couldn’t figure this out either. I have a similar/valid regex to build everything BUT master:
/^(?!(master$)).*/
But that causes NOTHING to be built.

And have you noticed that if you add a regex new build rule, the old ones disappear?
So annoying!


(James Martin) #3

I switched to Drone.io for docker builds, you need to maintain your own instance but damn it’s quick!


(Wongwill86) #4

i’m seeing the same thing. negative lookups kill all builds.
This was supposedly fixed a long time ago in Build configuration: Match any branch
But now neither solution works.

Is this no longer supported?


(Wongwill86) #5

Just a guess here but probably docker cloud uses golang which adamantly refuses support re lookups because they are not in O(n) runtime…
https://groups.google.com/d/msg/golang-nuts/7qgSDWPIh_E/OHTAm4wRZL0J

My re knowledge is pretty ugly thus this ugly solution:

^((?:(?:m$|ma$|mas$|mast$|maste$|master.+)|(?:[^m]|m[^a]|ma[^s]|mas[^t]|mast[^e]|maste[^r]))(?:.*))$

Hope someone can suggest a more elegant solution here :slight_smile:


(Sebastian Tschan) #6

Thanks for the workaround, @wongwill86!

A slightly more elegant solution is the following:

/^(.{1,5}|.{7}|([^m]|m[^a]|ma[^s]|mas[^t]|mast[^e]|maste[^r])(.*))$/

Cheers! :slight_smile:


(Javier Cortejoso) #7

Hi all!

I have been trying different approachs to get all branches compiled but none of them seem to work. Does anybody know any regex working today?

Cheers!