public GetTeamCityProjectDetailsResponse Get(GetTeamCityProjectDetails request) { GetProjectResponse teamCityResponse = null; try { teamCityResponse = TeamCityClient.GetProject(new GetProject { Locator = "id:" + request.ProjectId }); } catch (WebServiceException e) { if (e.IsAny400()) { throw HttpError.NotFound("Project not found"); } } if (teamCityResponse == null) { throw new HttpError(HttpStatusCode.InternalServerError, "Invalid response from TeamCity"); } GetBuildResponse build = null; try { build = TeamCityClient.GetBuild(new GetBuild { BuildLocator = "project:id:" + request.ProjectId }); } catch (WebException e) { if (!e.HasStatus(HttpStatusCode.BadRequest)) { throw; } } catch (WebServiceException wse) { if (!wse.IsAny400()) { throw; } } build = build ?? new GetBuildResponse(); var response = new GetTeamCityProjectDetailsResponse { ProjectName = teamCityResponse.Name, ProjectId = teamCityResponse.Id, BuildNumber = build.Number, BuildState = build.State, BuildStatus = build.StatusText }; return(response); }
public GetBuildStatusResponse Get(GetBuildStatus request) { GetBuildResponse builds; try { builds = TeamCityClient.GetBuild(new GetBuild { BuildLocator = "project:id:" + request.ProjectId }); } catch (WebException e) { if (e.HasStatus(HttpStatusCode.BadRequest)) { throw HttpError.NotFound("Project Not found"); } throw; } //Parse datetime from TeamCity string pattern = "yyyyMMddTHHmmssK"; DateTime?startDateTime = DateTime.ParseExact(builds.StartDate, pattern, CultureInfo.InvariantCulture); DateTime?finishDateTime = DateTime.ParseExact(builds.FinishDate, pattern, CultureInfo.InvariantCulture); return(new GetBuildStatusResponse { Status = builds.Status, LastUpdate = builds.State == "finished" ? finishDateTime : startDateTime }); }
private static ITeamCityClient CreateTeamCityClient() { var http = new HttpClientWrapper("teamcitytest:8080", "teamcity", "teamcity"); var client = new TeamCityClient(http); return(client); }
public void Execute(Bot bot) { if (string.IsNullOrWhiteSpace(IpAddressOrHostNameOfCCServer) || !Projects.Any()) { return; } _client = new TeamCityClient(IpAddressOrHostNameOfCCServer); _client.Connect("teamcitysharpuser", "qwerty"); var allProjects = _client.AllProjects(); var allBuildConfigs = _client.AllBuildConfigs(); foreach (var proj in allProjects) { Project currentProject = proj; var buildConfigs = allBuildConfigs.Where(buildConfig => currentProject.Id == buildConfig.Project.Id); foreach (var currentBuildConfig in buildConfigs) { var build = _client.LastBuildByBuildConfigId(currentBuildConfig.Id); var project = new ProjectModel(currentProject.Name, currentProject.Id, currentBuildConfig.Name, build.StartDate, build.Status, build.StatusText); Update(bot, project); } } }
public static async Task <Project> TeamCityProjectCreateAsync(this Context context, NewProject newProject, TeamCityClientOptions options) { using (var tcc = new TeamCityClient(options)) { return(await tcc.Projects.CreateAsync(newProject)); } }
public void it_returns_exception_when_host_does_not_exist() { var client = new TeamCityClient("test:81"); client.Connect("admin", "qwerty"); Assert.Throws<HttpRequestException>(() => client.VcsRoots.All()); }
public bool Connect(IRunOptions runOptions) { this.teamCityClient = new TeamCityClient(runOptions.HostName); this.refreshInterval = runOptions.RefreshInterval; this.buildTypeId = runOptions.BuildTypeId; this.teamCityBuildStatusProviderReporter?.ConnectingTo(runOptions.HostName); if (runOptions.Credentials != null) { this.teamCityClient.Connect(runOptions.Credentials.UserName, runOptions.Credentials.Password); } else { this.teamCityClient.ConnectAsGuest(); } this.teamCityBuildStatusProviderReporter?.Authenticating(); if (this.teamCityClient.Authenticate()) { this.lastBuildStatus = new BuildStatus(false, "None"); this.teamCityBuildStatusProviderReporter?.Authenticated(); this.refreshThread.Start(); return(true); } this.teamCityBuildStatusProviderReporter?.AuthenticationFailed(); return(false); }
private CreateVcsRootResponse CreateVcsRoot(CreateSpaBuildProject request, CreateProjectResponse createProjResponse, string gitHubToken) { var createVcs = TeamCityRequestBuilder.GetCreateVcsRootRequest( request.ProjectName, createProjResponse.Id, request.RepositoryUrl, request.PrivateRepository, request.Branch); // Use OAuth access_token as username as per https://github.com/blog/1270-easier-builds-and-deployments-using-git-over-https-and-oauth#using-oauth-with-git // Password of 'x-oauth-basic' also must be used based on how TeamCity creates the git clone command if (request.PrivateRepository) { createVcs.Properties.Properties.Add(new CreateVcsRootProperty { Name = "username", Value = gitHubToken }); createVcs.Properties.Properties.Add(new CreateVcsRootProperty { Name = "secure:password", Value = "x-oauth-basic" }); } var vcsResponse = TeamCityClient.CreateVcsRoot(createVcs); return(vcsResponse); }
static void Main(string[] args) { var client = new TeamCityClient("teamcity"); client.Connect(args[0], args[1]); //var allBuilds = client.Builds.AllSinceDate(new DateTime(2016, 04, 01)); //var buildLocator = BuildLocator.WithDimensions(status:BuildStatus.FAILURE, maxResults:1000, sinceDate: new DateTime(2016, 03, 01), untilDate: new DateTime(2016, 03, 01, 12, 59, 59)); //List<Build> builds = client.Builds.ByBuildLocator(buildLocator); var changeLocator = ChangeLocator.WithDimensions(buildType: "Development_CompilePackage", build: "10962"); var changes = client.Changes.ByChangeLocator(changeLocator); //var allUsers = client.Users.All(); //foreach (var user in allUsers) //{ // var nonSuccessfulBuilds = client.Builds.NonSuccessfulBuildsForUser(user.Username); // foreach (var nonSuccessfulBuild in nonSuccessfulBuilds) // { // var buildLocator = BuildLocator.WithId(long.Parse(nonSuccessfulBuild.Id)); // List<Build> builds = client.Builds.ByBuildLocator(buildLocator); // } //} }
private TeamCityClient GetTeamCityClient() { var client = new TeamCityClient(TeamCityServerAddress); var creds = new Credentials(); client.Connect(creds.TeamCityUsername, creds.TeamCityPassword); return(client); }
public void it_throws_exception_when_no_client_connection_made() { var client = new TeamCityClient("teamcity.codebetter.com"); var agents = client.Agents.All(); //Assert: Exception }
public void it_throws_exception_when_no_client_connection_made() { var client = new TeamCityClient("localhost:81"); var agents = client.AllAgents(); //Assert: Exception }
public void it_should_throw_exception_when_forbidden_status_code_returned() { var client = new TeamCityClient("localhost:81"); client.ConnectAsGuest(); Assert.Throws <Exception>(() => client.Users.All()); }
public void it_throws_exception_when_no_connection_formed() { var client = new TeamCityClient("teamcity.codebetter.com"); var projects = client.Projects.All(); //Assert: Exception }
public void it_throws_exception_when_no_connection_formed() { var client = new TeamCityClient(m_server, m_useSsl); Assert.Throws <ArgumentException>(() => client.BuildConfigs.All()); //Assert: Exception }
public void it_throws_exception_when_no_connection_formed() { var client = new TeamCityClient("teamcity.codebetter.com"); var projects = client.AllProjects(); //Assert: Exception }
public void it_throws_exception_when_no_connection_formed() { var client = new TeamCityClient("localhost:81"); var plugins = client.AllServerPlugins(); //Assert: Exception }
public void it_throws_exception_when_no_connection_formed() { var client = new TeamCityClient("teamcity.codebetter.com"); var plugins = client.AllServerPlugins(); //Assert: Exception }
public void it_throws_exception_when_host_url_invalid() { var client = new TeamCityClient("teamcity:81"); client.Connect("teamcitysharpuser", "qwerty"); Assert.Throws <WebException>(() => client.Agents.All()); }
public void it_throws_exception_when_no_connection_formed() { var client = new TeamCityClient(m_server, m_useSsl); const string buildConfigId = "Release Build"; Assert.Throws <ArgumentException>(() => client.Builds.SuccessfulBuildsByBuildConfigId(buildConfigId)); }
public void it_returns_exception_when_no_connection_formed() { var client = new TeamCityClient("localhost:81"); var vcsRoots = client.AllVcsRoots(); //Assert: Exception }
private TeamCityClient Open(Uri uri) { var client = new TeamCityClient(string.Concat(uri.Host, ":", uri.Port), (string.Compare(uri.Scheme, "https") == 0)); client.Connect(this.Username, this.Password); return(client); }
public void it_returns_exception_when_no_connection_made() { var client = new TeamCityClient("teamcity.codebetter.com"); var changes = client.AllChanges(); //Assert: Exception }
public void it_throws_exception_when_no_connection_formed() { var client = new TeamCityClient("teamcity.codebetter.com"); var builds = client.BuildConfigs.All(); //Assert: Exception }
public void it_throws_exception_when_no_connection_formed() { var client = new TeamCityClient("teamcity.codebetter.com"); Assert.Throws <ArgumentException>(() => client.Projects.All()); //Assert: Exception }
public void it_throws_exception_when_no_connection_formed() { var client = new TeamCityClient(m_server, m_useSsl); Assert.Throws <ArgumentException>(() => client.ServerInformation.AllPlugins()); //Assert: Exception }
public void it_throws_exception_when_host_does_not_exist() { var client = new TeamCityClient("test:81"); client.Connect("admin", "qwerty"); Assert.Throws <HttpRequestException>(() => client.ServerInformation.AllPlugins()); }
public void it_returns_exception_when_no_connection_formed() { var client = new TeamCityClient("teamcity.codebetter.com"); var vcsRoots = client.VcsRoots.All(); //Assert: Exception }
public void it_throws_exception_when_no_client_connection_made() { var client = new TeamCityClient("teamcity.codebetter.com"); var agents = client.AllAgents(); //Assert: Exception }
public void it_returns_exception_when_no_connection_made() { var client = new TeamCityClient("localhost:81"); var users = client.AllUsers(); //Assert: Exception }
public void it_should_throw_exception_when_forbidden_status_code_returned() { var client = new TeamCityClient(m_server, m_useSsl); client.ConnectAsGuest(); Assert.Throws <EasyHttp.Infrastructure.HttpException>(() => client.Users.All()); }
public void it_throws_exception_when_host_does_not_exist() { var client = new TeamCityClient("test:81"); client.Connect("teamcitysharpuser", "qwerty"); Assert.Throws <HttpRequestException>(() => client.BuildConfigs.All()); }
public void it_throws_exception_when_host_does_not_exist() { var client = new TeamCityClient("test:81"); client.Connect("admin", "qwerty"); Assert.Throws <WebException>(() => client.Projects.All()); }
public void it_throws_exception_when_no_connection_formed() { var client = new TeamCityClient("teamcity.codebetter.com"); var plugins = client.ServerInformation.AllPlugins(); //Assert: Exception }
public void it_throws_exception_when_no_connection_formed() { var client = new TeamCityClient("teamcity.codebetter.com"); var builds = client.AllBuildConfigs(); //Assert: Exception }
public void it_throws_exception_when_no_connection_formed() { var client = new TeamCityClient("localhost:81"); string buildConfigId = "Local Debug Build"; var builds = client.SuccessfulBuildsByBuildConfigId(buildConfigId); //Assert: Exception }
public void it_returns_subprojects_when_creating_project() { var client = new TeamCityClient("localhost:81"); client.Connect("admin", "qwerty"); var projectName = Guid.NewGuid().ToString("N"); var project = client.Projects.Create(projectName); Assert.That(project.Projects.Project, Is.Not.Null); }
public void it_throws_exception_when_no_connection_formed() { var client = new TeamCityClient("teamcity.codebetter.com"); string buildConfigId = "Release Build"; var builds = client.SuccessfulBuildsByBuildConfigId(buildConfigId); //Assert: Exception }
public void it_throws_exception_when_host_url_invalid() { var client = new TeamCityClient("teamcity:81"); client.Connect("teamcitysharpuser", "qwerty"); var agents = client.AllAgents(); //Assert: Exception }
public void it_throws_exception_when_host_does_not_exist() { var client = new TeamCityClient("test:81"); client.Connect("admin", "qwerty"); var allProjects = client.AllProjects(); //Assert: Exception }
public void it_throws_exception_when_host_does_not_exist() { var client = new TeamCityClient("test:81"); client.Connect("admin", "qwerty"); var plugins = client.ServerInformation.AllPlugins(); //Assert: Exception }
public void it_returns_exception_when_host_does_not_exist() { var client = new TeamCityClient("test:81"); client.Connect("admin", "qwerty"); var vcsroots = client.AllVcsRoots(); //Assert: Exception }
public void it_returns_all_build_types_with_access_token() { var client = new TeamCityClient(m_server, m_useSsl); client.ConnectWithAccessToken(m_token); var buildConfigs = client.BuildConfigs.All(); Assert.That(buildConfigs.Any(), "No build types were found in this server"); }
public void it_throws_exception_when_no_connection_formed() { var client = new TeamCityClient("teamcity.codebetter.com"); const string buildConfigId = "Release Build"; client.Builds.SuccessfulBuildsByBuildConfigId(buildConfigId); //Assert: Exception }
public void it_throws_exception_when_host_does_not_exist() { var client = new TeamCityClient("test:81"); client.Connect("teamcitysharpuser", "qwerty"); var builds = client.BuildConfigs.All(); //Assert: Exception }
private void CreateCopyAppSettingsStep(CreateSpaBuildProject request, CreateBuildConfigResponse buildConfigResponse) { TeamCityClient.CreateBuildStep( TeamCityRequestBuilder.GetCopyAppSettingsStep(buildConfigResponse.Id, request.WorkingDirectory, AppSettings.GetString("ApplicationSettingsBaseFolder"), request.OwnerName, request.Name)); }
public void it_throws_exception_when_host_does_not_exist() { var client = new TeamCityClient("test:81"); client.Connect("admin", "qwerty"); string buildConfigId = "Local Debug Build"; var builds = client.SuccessfulBuildsByBuildConfigId(buildConfigId); //Assert: Exception }
public void it_throws_exception_when_no_host() { Assert.Throws<ArgumentNullException>( () => { var client = new TeamCityClient(null); }); //Assert: Exception }
public void ig_returns_correct_build_when_calling_by_id() { const string buildId = "5726"; var client = new TeamCityClient("localhost:81"); client.Connect("admin", "qwerty"); var build = client.Builds.ById(buildId); Assert.That(build != null); Assert.That(build.Id == buildId); }
public void it_does_not_populate_the_status_text_field_of_the_build_object() { const string buildConfigId = "bt5"; var client = new TeamCityClient("localhost:81"); client.Connect("admin", "qwerty"); var build = client.Builds.ByBuildLocator(BuildLocator.WithDimensions(BuildTypeLocator.WithId(buildConfigId), maxResults: 1)); Assert.That(build.Count == 1); Assert.IsNull(build[0].StatusText); }
public void it_returns_project_details_when_creating_project_with_project_id() { var client = new TeamCityClient("localhost:81"); client.Connect("admin", "qwerty"); var projectName = Guid.NewGuid().ToString("N"); var projectId = Guid.NewGuid().ToString("N"); var project = client.Projects.Create(projectName, projectId); Assert.That(project, Is.Not.Null); Assert.That(project.Name, Is.EqualTo(projectName)); Assert.That(project.Id, Is.EqualTo(projectId)); }
public void it_throws_exception_when_host_url_invalid() { try { var client = new TeamCityClient("xyz:12345"); client.Connect("admin", "qwerty"); var agents = client.Agents.All(); } catch (AggregateException ae) { throw ae.InnerExceptions.First(); } }
public void it_throws_exception_when_no_connection_formed() { try { var client = new TeamCityClient("teamcity.codebetter.com"); var plugins = client.ServerInformation.AllPlugins(); //Assert: Exception } catch (AggregateException ae) { throw ae.InnerExceptions.First(); } }
public void it_throws_exception_when_host_does_not_exist() { try { var client = new TeamCityClient("test:81"); client.Connect("admin", "qwerty"); var plugins = client.ServerInformation.AllPlugins(); //Assert: Exception } catch (AggregateException ae) { throw ae.InnerExceptions.First(); } }
public void it_returns_exception_when_host_does_not_exist() { try { var client = new TeamCityClient("test:81"); client.Connect("admin", "qwerty"); var changes = client.Changes.All(); } catch (AggregateException ae) { throw ae.InnerExceptions.First(); } //Assert: Exception }
public void it_returns_exception_when_no_connection_made() { try { var client = new TeamCityClient("teamcity.codebetter.com"); var changes = client.Changes.All(); //Assert: Exception } catch (AggregateException ae) { throw ae.InnerExceptions.First(); } }
public void it_throws_exception_when_host_does_not_exist() { var client = new TeamCityClient("test:81"); client.Connect("teamcitysharpuser", "qwerty"); try { var builds = client.BuildConfigs.All(); } catch (AggregateException ae) { throw ae.InnerExceptions.First(); } //Assert: Exception }
public void it_will_add_a_new_user_and_new_user_will_be_able_to_log_in() { string userName = "******"; string name = "John Doe"; string email = "*****@*****.**"; string password = "******"; var createUserResult = _client.Users.Create(userName, name, email, password); ITeamCityClient _newUser; _newUser = new TeamCityClient("teamcity.codebetter.com"); _newUser.Connect(userName, password); var loginResponse = _newUser.Authenticate(); Assert.That(createUserResult && loginResponse); }