Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Loading…

TeamCity integration #15

Closed
wants to merge 4 commits into from

3 participants

@damianh
Owner

This pull request contains the TeamCity integration as posted here http://groups.google.com/group/psake-dev/browse_thread/thread/d69eac6a38a5308e

(It also contains the 4.2 version bump from other pull request)

Please let me know if any problems.

Regards,

Damian Hickey
twitter.com/randompunter
gplus.to/damianh

damianh added some commits
@damianh damianh Updated the patch version to 4.0.1.0 32b79f6
@damianh damianh Upped version number to 4.2 f376c26
@damianh damianh Change nuspec version to 4.2 769a9dc
@damianh damianh When logging the task name ( "Executing XX" ) the script detects if i…
…t is being run in TeamCity via environment variable

and will open a service message block and close at the end. This will give a nice message in TeamCity as to the current running task as well as collapsible log tree view.

More on teamcity service message blocks.
http://confluence.jetbrains.net/display/TCD65/Build+Script+Interaction+with+TeamCity#BuildScriptInteractionwithTeamCity-BlocksofServiceMessages

Signed-off-by: Damian Hickey <dhickey@gmail.com>
26fe91d
@lanwin
Owner

I think in general the idea is good. But i dont like that your thoughts go only in the direction which you special case is for. There are other good uses for a Write-TaskOpened and Write-TaskClosed function. In example what would work perfectly with together with the changes @whut which write something similar in pull request https://github.com/JamesKovacs/psake/pull/9 to support colored output.

Owner

But i dont like that your thoughts go only in the direction which you special case is for.

When I wrote this, there were no other cases, so I guess it is special :)

I went with the simplest thing that works and was not aware of other efforts in the logging area.

Feel free to include this the colored output work.

@whut
Owner

There is something about integration with TeamCity in https://github.com/JamesKovacs/psake-contrib (i'm not a user of TeamCity). Maybe this work can be somehow combined with that.

@lanwin
Owner

Hmm yes there are the function which output the format teamcity needs. Whats missing in the psake core is a way to add a hook to pretask and posttask so this can be integrated by including the module.

@whut
Owner

There are TaskSetup and TaskTeardown functions, maybe they would be useful?

@lanwin
Owner

What i mean is that it should be possible to hook into them without changing psake.

@damianh
Owner

Would it also be possible to hook without changing user's build script? Not sure a user would want to use TaskSetup and TaskTeardown set up logging output for TeamCity, rather, Psake should 'detect' TeamCity via environment variable.

I agree that a more general solution is desirable :)

@lanwin
Owner

Yep. psake provides that hooks. The psake modules can subscribe to that hooks and do something. So you could drop in the Teamcity module from contrib and it will detect Teamcity and enable the output.

@whut
Owner

Closing this pull request, as a more general solution should be prepared (using TaskSetup and TaskTeardown for example) and proposed to psake-contrib

@whut whut closed this
@damianh
Owner

Ok, will look into that.

@damianh damianh deleted the damianh:TeamCityIntegration branch
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Apr 26, 2011
  1. @damianh
Commits on Jul 9, 2011
  1. @damianh

    Upped version number to 4.2

    damianh authored
  2. @damianh

    Change nuspec version to 4.2

    damianh authored
  3. @damianh

    When logging the task name ( "Executing XX" ) the script detects if i…

    damianh authored
    …t is being run in TeamCity via environment variable
    
    and will open a service message block and close at the end. This will give a nice message in TeamCity as to the current running task as well as collapsible log tree view.
    
    More on teamcity service message blocks.
    http://confluence.jetbrains.net/display/TCD65/Build+Script+Interaction+with+TeamCity#BuildScriptInteractionwithTeamCity-BlocksofServiceMessages
    
    Signed-off-by: Damian Hickey <dhickey@gmail.com>
This page is out of date. Refresh to see the latest.
Showing with 24 additions and 7 deletions.
  1. +3 −3 en-US/psake.psm1-help.xml
  2. +1 −1  nuget/psake.nuspec
  3. +20 −3 psake.psm1
View
6 en-US/psake.psm1-help.xml
@@ -160,7 +160,7 @@ Possible values: '1.0', '1.1', '2.0', '2.0x86', '2.0x64', '3.0', '3.0x86', '3.0x
containing some variables that can be used to configure psake:
$psake.build_success = $false # indicates that the current build was successful
-$psake.version = "4.00" # contains the current version of psake
+$psake.version = "4.2" # contains the current version of psake
$psake.build_script_file = $null # contains a System.IO.FileInfo for the current build file
$psake.build_script_dir # contains the fully qualified path to the current build file
$psake.framework_version = "" # contains the framework version # for the current build
@@ -172,7 +172,7 @@ PS projects:\psake> $psake
Name Value
---- -----
-version 4.00
+version 4.2
build_script_file
build_script_dir
build_success False
@@ -204,7 +204,7 @@ PS projects:\psake> $psake
Name Value
---- -----
-version 4.00
+version 4.2
build_script_file C:\Users\Jorge\Documents\Projects\psake\examples\default.ps1
build_script_dir C:\Users\Jorge\Documents\Projects\psake\examples
build_success True
View
2  nuget/psake.nuspec
@@ -2,7 +2,7 @@
<package xmlns="http://schemas.microsoft.com/packaging/2010/07/nuspec.xsd">
<metadata>
<id>psake</id>
- <version>4.0.0.0</version>
+ <version>4.2</version>
<authors>James Kovacs</authors>
<owners>Damian Hickey, Rob Reynolds</owners>
<projectUrl>https://github.com/JamesKovacs/psake</projectUrl>
View
23 psake.psm1
@@ -81,10 +81,12 @@ function Invoke-Task
if ($currentContext.formatTaskName -is [ScriptBlock]) {
& $currentContext.formatTaskName $taskName
} else {
- $currentContext.formatTaskName -f $taskName
+ $formattedTaskName = $currentContext.formatTaskName -f $taskName
+ Write-TeamCityBlockOpened $formattedTaskName
}
- & $task.Action
+ & $task.Action
+ Write-TeamCityBlockClosed $formattedTaskName
if ($task.PostAction) {
& $task.PostAction
@@ -602,6 +604,21 @@ function Write-TaskTimeSummary {
$list | format-table -auto | out-string -stream | ? { $_ } #using "Out-String -Stream" to filter out the blank line that Format-Table prepends
}
+function Write-TeamCityBlockOpened($name = $(throw "name paramater required.")){
+ if($env:TEAMCITY_PROJECT_NAME -ne $null){ # detect if this script is being run in TeamCity. Uses same mechanism as xunit http://xunit.codeplex.com/wikipage?title=HowToUseTeamCity
+ "##teamcity[blockOpened name='$name']"
+ }
+ else{
+ $name
+ }
+}
+
+function Write-TeamCityBlockClosed($name = $(throw "name paramater required.")){
+ if($env:TEAMCITY_PROJECT_NAME -ne $null){
+ "##teamcity[blockClosed name='$name']"
+ }
+}
+
DATA msgs {
convertfrom-stringdata @'
error_invalid_task_name = Task name should not be null or empty string
@@ -634,7 +651,7 @@ import-localizeddata -bindingvariable msgs -erroraction silentlycontinue
$script:psake = @{}
$psake.build_success = $false # indicates that the current build was successful
-$psake.version = "4.00" # contains the current version of psake
+$psake.version = "4.2" # contains the current version of psake
$psake.build_script_file = $null # contains a System.IO.FileInfo for the current build file
$psake.build_script_dir = "" # contains a string with fully-qualified path to current build script
$psake.framework_version = "" # contains the framework version # for the current build
Something went wrong with that request. Please try again.