Skip to content
This repository has been archived by the owner on Feb 5, 2020. It is now read-only.

Commit

Permalink
Merge pull request #3169 from cpanato/fix_cluster_name
Browse files Browse the repository at this point in the history
Fix cluster name when testing in Branches
  • Loading branch information
squat authored Apr 10, 2018
2 parents 21418bd + 269bb69 commit 40542ee
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions tests/rspec/lib/name_generator.rb
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,10 @@ def self.generate(prefix)

def self.jenkins_env_name(prefix)
build_id = ENV['BUILD_ID']
branch_name = ENV['BRANCH_NAME']
name = "#{prefix}-#{branch_name}-#{build_id}"
# Resource names containing dots are prohibited on most cloud providers
branch_name = ENV['BRANCH_NAME'].to_s.delete('.')
short_prefix = prefix.split('-').map { |x| x[0...3] }.join.gsub(/^(.{10,}?).*$/m, '\1')
name = "#{short_prefix}-#{branch_name}-#{build_id}"
name = name[0..(MAX_NAME_LENGTH - RANDOM_HASH_LENGTH - 1)]
name += SecureRandom.hex[0...RANDOM_HASH_LENGTH]
name
Expand Down

0 comments on commit 40542ee

Please sign in to comment.