stack72 / TeamCitySharp

No Longer Maintained - please use https://github.com/mavezeau/TeamCitySharp
Other
200 stars 165 forks source link

Added ability to download build configurations #53

Closed mdevilliers closed 11 years ago

mdevilliers commented 11 years ago

Hey,

I've added a method to download build configurations locally. Also filled out BuildConfig object with a settings object.

Thanks for a great project,

Mark

stack72 commented 11 years ago

Hi @mdevilliers when you download the build config, what does this actually do with it? Is it saved locally? I need to see a sample usage of this to see how you are actually using it so that I can add it to the docs.

I love the idea, infact it gives me an idea of the ability to export a build config from 1 teamcity server to another, something which I think has been missing for a long time in TC.

Hope to hear from you soon!

mdevilliers commented 11 years ago

If it's ok to put my sample usage here (I can add it to a test if you want)

 static void Main(string[] args)
        {
            var client = new TeamCityClient("192.168.1.84:8111");

            client.Connect("user", "user");

            var config = client.BuildConfigs.ByConfigurationId("SignalRRabbitMQ_Build");
            client.BuildConfigs.DownloadConfiguration(BuildTypeLocator.WithId(config.Id), Download);

        }

        static void Download(string temporaryfilename)
        {
            File.Copy(temporaryfilename, "buildconfig.json");
        }

Essentially the local temporary file name is passed into an action that you can then do with as you will - in this case I just copy it to another file. I originally submitted the pull request to download artifacts and I just copied the same pattern.

I became interested when I saw the work JetBrains have done to allow for exporting the build configurations via the REST api.

What I would really like to do in future is add a teamcity build configuration to one of my projects so that I (or any one else) could then fork the project, make changes to the code but still be able to build, test, nuget pack the code etc in the same way that I do.

Setting it all up would be as simple as importing the build configuration, maybe tinker with the git url/branch and clicking Run.

I couldn't see a way of importing the build config via the api which is the last bit of the puzzle....

stack72 commented 11 years ago

Thanks mark - this is very useful!

I will get this merged soon :) On 16 Oct 2013 21:07, "Mark deVilliers" notifications@github.com wrote:

If it's ok to put my sample usage here (I can add it to a test if you want)

static void Main(string[] args) { var client = new TeamCityClient("192.168.1.84:8111");

        client.Connect("user", "user");

        var config = client.BuildConfigs.ByConfigurationId("SignalRRabbitMQ_Build");
        client.BuildConfigs.DownloadConfiguration(BuildTypeLocator.WithId(config.Id), Download);

    }

    static void Download(string temporaryfilename)
    {
        File.Copy(temporaryfilename, "buildconfig.json");
    }

Essentially the local temporary file name is passed into an action that you can then do with as you will - in this case I just copy it to another file. I originally submitted the pull request to download artifactshttps://github.com/stack72/TeamCitySharp/pull/23and I just copied the same pattern.

I became interested when I saw the work JetBrains have done to allow for exporting the build configurations via the REST api.

What I would really like to do in future is add a teamcity build configuration to one of my projectshttps://github.com/mdevilliers/SignalR.RabbitMqso that I (or any one else) could then fork the project, make changes to the code but still be able to build, test, nuget pack the code etc in the same way that I do.

Setting it all up would be as simple as importing the build configuration, maybe tinker with the git url/branch and clicking Run.

I couldn't see a way of importing the build config via the api which is the last bit of the puzzle....

— Reply to this email directly or view it on GitHubhttps://github.com/stack72/TeamCitySharp/pull/53#issuecomment-26452796 .

stack72 commented 11 years ago

@mdevilliers so Ive jsut been looking at this. It looks good. I am going to merge this. With regards on importing the build config via the API, wouldnt it just be taking the config, creating the correct object and then use the API to create a buildConfig, template or project?