コード例 #1
0
		/// <summary>
		/// Trigger a deploy in AppVeyor
		/// </summary>
		/// <param name="project"></param>
		/// <param name="env"></param>
		/// <param name="buildVersion"></param>
		/// <returns></returns>
		public async Task<StartDeploymentResponse> DeployEnvironment(AppVeyorProject project, AppVeyorEnvironment env, string buildVersion)
		{
			NewDeploy deploy = new Models.NewDeploy()
			{
				AccountName = project.AccountName,
				BuildVersion = buildVersion,
				EnvironmentName = env.Name,
				ProjectSlug = project.Slug
			};

			var jsonSerializerSettings = new JsonSerializerSettings { ContractResolver = new CamelCasePropertyNamesContractResolver() };

			string envJson = JsonConvert.SerializeObject(deploy, jsonSerializerSettings);

			using (var response = await httpClient.PostAsync("https://ci.appveyor.com/api/deployments", new StringContent(envJson, Encoding.UTF8, "application/json")))
			{
				response.EnsureSuccessStatusCode();

				var resultJson = await response.Content.ReadAsStringAsync();

				var result = JsonConvert.DeserializeObject<StartDeploymentResponse>(resultJson);

				return result;
			}
		}
コード例 #2
0
        /// <summary>
        /// Trigger a deploy in AppVeyor
        /// </summary>
        /// <param name="project"></param>
        /// <param name="env"></param>
        /// <param name="buildVersion"></param>
        /// <returns></returns>
        public async Task <bool> DeployEnvironment(AppVeyorProject project, AppVeyorEnvironment env, string buildVersion)
        {
            NewDeploy deploy = new Models.NewDeploy()
            {
                AccountName     = project.AccountName,
                BuildVersion    = buildVersion,
                EnvironmentName = env.Name,
                ProjectSlug     = project.Slug
            };

            var jsonSerializerSettings = new JsonSerializerSettings {
                ContractResolver = new CamelCasePropertyNamesContractResolver()
            };

            string envJson = JsonConvert.SerializeObject(deploy, jsonSerializerSettings);

            using (var response = await httpClient.PostAsync("https://ci.appveyor.com/api/deployments", new StringContent(envJson, Encoding.UTF8, "application/json")))
            {
                return(response.IsSuccessStatusCode);
            }
        }