Module: Albacore::Ext::TeamCity

Defined in:
lib/albacore/ext/teamcity.rb

Overview

The teamcity module writes appropriate build-script "interaction messages" (see http://confluence.jetbrains.com/display/TCD7/Build+Script+Interaction+with+TeamCity#BuildScriptInteractionwithTeamCity-artPublishing) to STDOUT.

Class Method Summary collapse

Class Method Details

.configure ⇒ Object



28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
# File 'lib/albacore/ext/teamcity.rb', line 28

def self.configure
  Albacore.subscribe :artifact do |artifact|
    ::Albacore.puts "##teamcity[publishArtifacts '#{artifact.location}']"
  end
  Albacore.subscribe :build_version do |version|
    # tell teamcity our decision
    ::Albacore.puts "##teamcity[buildNumber '#{version.build_number}']" # available as 'build.number' in TC
    ::Albacore.puts "##teamcity[setParameter name='build.version' value='#{version.build_version}']"
    ::Albacore.puts "##teamcity[setParameter name='build.version.formal' value='#{version.formal_version}']"
  end
  Albacore.subscribe :progress do |p|
    # tell teamcity of our progress
    ::Albacore.puts "##teamcity[progressMessage '#{escape p.message}']"
  end
  Albacore.subscribe :start_progress do |p|
    # tell teamcity of our progress
    start_progress p.message
  end
  Albacore.subscribe :finish_progress do |p|
    # tell teamcity of our progress
    finish_progress p.message
  end
end

.escape(message) ⇒ Object

Escaped the progress message (see http://confluence.jetbrains.com/display/TCD7/Build+Script+Interaction+with+TeamCity#BuildScriptInteractionwithTeamCity-ServiceMessages) The Unicode symbol escape is not implemented Character Should be escaped as ' (apostrophe) |' \n (line feed) |n \r (carriage return) |r \uNNNN (unicode symbol with code 0xNNNN) |0xNNNN | (vertical bar) || [ (opening bracket) |[ ] (closing bracket) |]



24
25
26
# File 'lib/albacore/ext/teamcity.rb', line 24

def self.escape message
  message.gsub(/([\[|\]|\|'])/, '|\1').gsub(/\n/, '|n').gsub(/\r/, '|r')
end