Class: XcodeServer::Server
- Inherits:
-
Object
- Object
- XcodeServer::Server
- Includes:
- Networking
- Defined in:
- lib/xcode_server/server.rb,
lib/xcode_server/server/networking.rb
Defined Under Namespace
Modules: Networking, TestingSchedule
Instance Attribute Summary collapse
-
#host ⇒ Object
readonly
Returns the value of attribute host.
-
#scheme ⇒ Object
readonly
Returns the value of attribute scheme.
Instance Method Summary collapse
-
#bots ⇒ Object
Retrieve a list of all bots on the server.
-
#create_bot(bot_name:, branch_name: "master", performs_analyze_action: true, performs_archive_action: false, performs_test_action: true, project_path:, repo_url:, scheme_name:, testing_schedule: TestingSchedule::ON_COMMIT, working_copy_path:) ⇒ Object
Create a new bot on the server.
-
#destroy_bot(id, rev = nil) ⇒ Object
Delete an existing bot based on the bot id.
-
#initialize(host, scheme = 'https') ⇒ Server
constructor
A new instance of Server.
Methods included from Networking
#delete, #get, #get_json, #post
Constructor Details
#initialize(host, scheme = 'https') ⇒ Server
Returns a new instance of Server.
16 17 18 19 |
# File 'lib/xcode_server/server.rb', line 16 def initialize(host, scheme = 'https') @host = host @scheme = scheme end |
Instance Attribute Details
#host ⇒ Object (readonly)
Returns the value of attribute host.
14 15 16 |
# File 'lib/xcode_server/server.rb', line 14 def host @host end |
#scheme ⇒ Object (readonly)
Returns the value of attribute scheme.
13 14 15 |
# File 'lib/xcode_server/server.rb', line 13 def scheme @scheme end |
Instance Method Details
#bots ⇒ Object
Retrieve a list of all bots on the server
23 24 25 |
# File 'lib/xcode_server/server.rb', line 23 def bots get_json('bots')['results'].map { |result| Bot.new(self, result) } end |
#create_bot(bot_name:, branch_name: "master", performs_analyze_action: true, performs_archive_action: false, performs_test_action: true, project_path:, repo_url:, scheme_name:, testing_schedule: TestingSchedule::ON_COMMIT, working_copy_path:) ⇒ Object
Create a new bot on the server
48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 |
# File 'lib/xcode_server/server.rb', line 48 def create_bot(bot_name:, branch_name: "master", performs_analyze_action: true, performs_archive_action: false, performs_test_action: true, project_path:, repo_url:, scheme_name:, testing_schedule: TestingSchedule::ON_COMMIT, working_copy_path:) repo_identifier = SecureRandom.uuid res = post('bots', group: { name: SecureRandom.uuid }, configuration: { builtFromClean: 1, # Always periodicScheduleInterval: 0, # Run manually performs_test_action: performs_test_action, performs_analyze_action: performs_analyze_action, scheme_name: scheme_name, sourceControlBlueprint: { DVTSourceControlWorkspaceBlueprintLocationsKey: { repo_identifier => { DVTSourceControlBranchIdentifierKey: branch_name, DVTSourceControlBranchOptionsKey: 156, # Mystery meat DVTSourceControlWorkspaceBlueprintLocationTypeKey: "DVTSourceControlBranch" # "Pull a git branch" } }, DVTSourceControlWorkspaceBlueprintPrimaryRemoteRepositoryKey: repo_identifier, DVTSourceControlWorkspaceBlueprintRemoteRepositoryAuthenticationStrategiesKey: { repo_identifier => { DVTSourceControlWorkspaceBlueprintRemoteRepositoryAuthenticationTypeKey: "DVTSourceControlAuthenticationStrategy" } }, DVTSourceControlWorkspaceBlueprintWorkingCopyStatesKey: { repo_identifier => 0 }, DVTSourceControlWorkspaceBlueprintIdentifierKey: repo_identifier, DVTSourceControlWorkspaceBlueprintWorkingCopyPathsKey: { repo_identifier => working_copy_path }, DVTSourceControlWorkspaceBlueprintNameKey: project_path, DVTSourceControlWorkspaceBlueprintVersion: 203, # Mystery meat DVTSourceControlWorkspaceBlueprintRelativePathToProjectKey: project_path, DVTSourceControlWorkspaceBlueprintRemoteRepositoriesKey: [{ DVTSourceControlWorkspaceBlueprintRemoteRepositoryURLKey: project_url, DVTSourceControlWorkspaceBlueprintRemoteRepositorySystemKey: "com.apple.dt.Xcode.sourcecontrol.Git", DVTSourceControlWorkspaceBlueprintRemoteRepositoryIdentifierKey: repo_identifier }] }, hourOfIntegration: 0, scheduleType: testing_schedule, performs_archive_action: performs_archive_action, testingDestinationType: 0 # "iOS All Devices and All Simulators" }, requiresUpgrade: false, # Mystery meat name: bot_name, type: 1 # Mystery meat ) Bot.new(self, JSON.load(res.body)) end |
#destroy_bot(id, rev = nil) ⇒ Object
Delete an existing bot based on the bot id
30 31 32 33 |
# File 'lib/xcode_server/server.rb', line 30 def destroy_bot(id, rev = nil) rev ||= get_json("bots/#{id}")['_rev'] delete("bots/#{id}/#{rev}").code.to_i == 204 end |