public void LaunchJenkinsPipeline(Catalog catalog, Order order) { var pipeline = _pipelineRepository.GetAllWithCatalog(catalog.CatalogId); if (pipeline.Count() > 0) { var p1 = pipeline.First(); String errorText = ""; order.JenkinsProjectName = p1.JenkinsPipelineName; if (p1.JenkinsWebAPI.Length > 0) { RESTClient rClient = new RESTClient(); //rClient.endPoint = p1.JenkinsWebAPI + p1.JenkinsPipelineName + "/build?delay=0sec"; rClient.authType = autheticationType.Basic; //rClient.httpMethod = httpVerb.POST; rClient.userName = _jenkinsSettings.UID; rClient.userPassword = _jenkinsSettings.PWD; //..Getting the Next Build Number for this Jenkins Project rClient.endPoint = p1.JenkinsWebAPI + p1.JenkinsPipelineName + "/api/xml/"; rClient.httpMethod = httpVerb.GET; int nextBuildNumber = rClient.GetNextBuildNumber(ref errorText); if (errorText.Length > 0) { order.JenkinsDetails += "Connecting to URL :" + rClient.endPoint; order.JenkinsDetails += "Error connecting to Jenkins REST API \n Getting Next Build Number Failed:\n" + errorText; _orderRepository.Update(order); return; } //..Start the Build rClient.endPoint = p1.JenkinsWebAPI + p1.JenkinsPipelineName + "/build?delay=0sec"; rClient.httpMethod = httpVerb.POST; if (!rClient.StartBuild(ref errorText)) { order.JenkinsDetails += "Error connecting to Jenkins REST API \n Starting Build Failed:" + errorText; _orderRepository.Update(order); return; } //..Getting the Next Build Number for this Jenkins Project rClient.endPoint = p1.JenkinsWebAPI + p1.JenkinsPipelineName + "/api/xml/"; rClient.httpMethod = httpVerb.GET; int nextBuildNumber2 = rClient.GetNextBuildNumber(ref errorText); if (errorText.Length > 0) { order.JenkinsDetails += "Error connecting to Jenkins REST API \n Getting Next Build Number Failed:" + errorText; _orderRepository.Update(order); return; } if (nextBuildNumber != nextBuildNumber2) { order.JenkinsBuildNumber = nextBuildNumber.ToString(); order.JenkinsDetails += "Jenkin Build Started - Build number is " + nextBuildNumber.ToString(); order.Status = eOrderStatus.InProgress; } } _orderRepository.Update(order); return; } }