Class: XcodeServer::Server

Inherits:
Object
  • Object
show all
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

Instance Method Summary collapse

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

#hostObject (readonly)

Returns the value of attribute host.



14
15
16
# File 'lib/xcode_server/server.rb', line 14

def host
  @host
end

#schemeObject (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

#botsObject

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

Parameters:

  • bot_name (String)

    The human name of the bot (e.g. “venmo/venmo-iphone#99 (feature/ci)”)

  • branch_name (String) (defaults to: "master")

    The name of the branch to integrate

  • performs_analyze_action (Boolean) (defaults to: true)

    Whether or not to analyze during integration

  • performs_archive_action (Boolean) (defaults to: false)

    Whether or not to archive during integration

  • performs_test_action (Boolean) (defaults to: true)

    Whether or not to test during integration

  • project_path (String)

    The path to the project or workspace within the working directory

  • repo_url (String)

    The git URL for a repo containing the project to integrate

  • scheme_name (String)

    The name of the Xcode scheme to integrate

  • testing_schedule (Integer) (defaults to: TestingSchedule::ON_COMMIT)

    See TestingSchedule

  • working_copy_path (String)

    The name of the working copy directory, usually the name of the repo (e.g. venmo/venmo-iphone)



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

Parameters:

  • id (String)

    The bot’s id as returned by 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