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); }
private void CreateCopyAppSettingsStep(CreateSpaBuildProject request, CreateBuildConfigResponse buildConfigResponse) { TeamCityClient.CreateBuildStep( TeamCityRequestBuilder.GetCopyAppSettingsStep(buildConfigResponse.Id, request.WorkingDirectory, AppSettings.GetString("ApplicationSettingsBaseFolder"), request.OwnerName, request.Name)); }
private void CreateWebDeployPushStep(CreateSpaBuildProject request, CreateBuildConfigResponse buildConfigResponse) { TeamCityClient.CreateBuildStep( TeamCityRequestBuilder.GetWebDeployPush(buildConfigResponse.Id, request.WorkingDirectory)); }
private void CreateNuGetRestoreStep(CreateSpaBuildProject request, CreateBuildConfigResponse buildConfigResponse) { TeamCityClient.CreateBuildStep( TeamCityRequestBuilder.GetNuGetRestoreBuildStep(buildConfigResponse.Id, request.SolutionPath)); }
private void CreateBowerInstallStep(CreateSpaBuildProject request, CreateBuildConfigResponse buildConfigResponse) { TeamCityClient.CreateBuildStep( TeamCityRequestBuilder.GetBowerInstallBuildStep(buildConfigResponse.Id, request.WorkingDirectory)); }
private void CreateVcsTrigger(CreateBuildConfigResponse buildConfigResponse) { TeamCityClient.CreateTrigger(TeamCityRequestBuilder.GetCreateVcsTrigger(buildConfigResponse.Id)); }
private void AttachVcsToProject(CreateBuildConfigResponse buildConfigResponse, CreateVcsRootResponse vcsResponse) { TeamCityClient.AttachVcsEntries( TeamCityRequestBuilder.GetAttachVcsEntriesRequest(buildConfigResponse.Id, vcsResponse.Id)); }
public CreateSpaBuildProjectResponse Post(CreateSpaBuildProject request) { Log.Info(request.ToJson()); var session = SessionAs <AuthUserSession>(); var gitHubToken = session.GetGitHubAccessToken(); var createProjResponse = CreateTeamCityProject(request); var vcsResponse = CreateVcsRoot(request, createProjResponse, gitHubToken); try { if (!request.LocalOnlyApp) { IisHelper.AddSite(request.Name, request.HostName); } else { IisHelper.AddLocalOnlySite(request.Name, request.Port); } } catch (Exception e) { Log.Error(e.Message, e); } var createBuildConfig = new CreateBuildConfig { Locator = "id:" + createProjResponse.Id, Name = "Build and Deploy" }; var buildConfigResponse = TeamCityClient.CreateBuildConfig(createBuildConfig); TeamCityClient.UpdateBuildConfigParameters(new UpdateBuildConfigParameters { Locator = "id:" + buildConfigResponse.Id, Properties = new List <CreateTeamCityBuildParameter> { TeamCityRequestBuilder .CreateTeamCityBuildParameter(buildConfigResponse.Id, "ss.msdeploy.serverAddress", "localhost", "text validationMode='any' display='normal'"), TeamCityRequestBuilder .CreateTeamCityBuildParameter(buildConfigResponse.Id, "ss.msdeploy.iisApp", request.Name, "text validationMode='any' display='normal'") } }); TeamCityClient.UpdateBuildConfigSettings(new UpdateBuildConfigSetting { Locator = "id:" + buildConfigResponse.Id, SettingId = "artifactRules", Value = request.WorkingDirectory + "/wwwroot => " + request.WorkingDirectory + "/wwwroot" }); AttachVcsToProject(buildConfigResponse, vcsResponse); CreateVcsTrigger(buildConfigResponse); CreateNpmInstallStep(request, buildConfigResponse); CreateBowerInstallStep(request, buildConfigResponse); CreateNuGetRestoreStep(request, buildConfigResponse); CreateGruntStep(request, buildConfigResponse); CreateCopyAppSettingsStep(request, buildConfigResponse); CreateWebDeployPackStep(request, buildConfigResponse); CreateWebDeployPushStep(request, buildConfigResponse); TeamCityClient.TriggerBuild(new TriggerBuild { TriggerBuildType = new TriggerBuildType { Id = buildConfigResponse.Id } }); return(new CreateSpaBuildProjectResponse { ProjectId = createProjResponse.Id }); }