Created
October 30, 2017 05:48
-
-
Save dacaiguoguogmail/916b0f3a737058828e2dd3cb4cf8c094 to your computer and use it in GitHub Desktop.
config Xcode Server Bot
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
NSURLSessionConfiguration *configr = [NSURLSessionConfiguration defaultSessionConfiguration]; | |
self.sessionManager = [NSURLSession sessionWithConfiguration:configr]; | |
NSString *urlString = [NSString stringWithFormat:@"https://%@:20343/api/bots/%@",hostIp, fixId]; | |
NSMutableURLRequest *mutR = [NSMutableURLRequest requestWithURL:[NSURL URLWithString:urlString]]; | |
[mutR setHTTPMethod:@"GET"]; | |
NSURLSessionDataTask *task1 = [self.sessionManager dataTaskWithRequest:mutR completionHandler:^(NSData * _Nullable data1, NSURLResponse * _Nullable response1, NSError * _Nullable error1) { | |
NSLog(@"%@",error1); | |
NSMutableDictionary *responseObject = [NSJSONSerialization JSONObjectWithData:data1 options:(NSJSONReadingMutableContainers) error:nil]; | |
NSLog(@"%@",responseObject); | |
NSMutableDictionary *botConfig = responseObject.mutableCopy; | |
[botConfig setObject:@"configuration5" forKey:@"name"]; | |
NSMutableDictionary *configuration=botConfig[@"configuration"]; | |
NSMutableDictionary *sourceControlBlueprint=configuration[@"sourceControlBlueprint"]; | |
NSMutableDictionary *DVTSourceControlWorkspaceBlueprintLocationsKey = sourceControlBlueprint[@"DVTSourceControlWorkspaceBlueprintLocationsKey"]; | |
NSArray *allkeys = [DVTSourceControlWorkspaceBlueprintLocationsKey allKeys]; | |
NSString *firstKey = allkeys.firstObject; | |
NSMutableDictionary *firstObj = DVTSourceControlWorkspaceBlueprintLocationsKey[firstKey]; | |
firstObj[@"DVTSourceControlBranchIdentifierKey"] = branchVersion;//fix version | |
botConfig[@"configuration"][@"scheduleType"] = @3;//Maunaly | |
NSData *data = [NSJSONSerialization dataWithJSONObject:botConfig options:0 error:nil]; | |
NSString *urlString = [NSString stringWithFormat:@"https://%@:20343/api/bots/%@?overwriteBlueprint=true", hostIp, responseObject[@"_id"]]; | |
NSMutableURLRequest *mutR = [NSMutableURLRequest requestWithURL:[NSURL URLWithString:urlString]]; | |
mutR.HTTPBodyStream = [[NSInputStream alloc] initWithData:data]; | |
[mutR setHTTPMethod:@"PATCH"]; | |
[mutR setValue:@"6" forHTTPHeaderField:@"x-xcsclientversion"]; | |
[mutR setValue:@"*/*" forHTTPHeaderField:@"Accept"]; | |
[mutR setValue:@"application/json" forHTTPHeaderField:@"Content-Type"]; | |
[mutR setValue:@"no-cache" forHTTPHeaderField:@"Pragma"]; | |
[mutR setValue:@"no-cache" forHTTPHeaderField:@"Cache-Control"]; | |
NSURLSessionDataTask *task3 = [self.sessionManager dataTaskWithRequest:mutR completionHandler:^(NSData * _Nullable data3, NSURLResponse * _Nullable response3, NSError * _Nullable error3) { | |
NSLog(@"%@",error3); | |
NSLog(@"%@",[NSJSONSerialization JSONObjectWithData:data3 options:(NSJSONReadingMutableContainers) error:nil]); | |
}]; | |
[task3 resume]; | |
}]; | |
[task1 resume]; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment