Skip to content
This repository was archived by the owner on May 12, 2018. It is now read-only.

Commit 529a54f

Browse files
committed
Merge branch 'unsubscribe' into 'master'
Unlink runner from coordinator gitlab/omnibus-gitlab-runner#1 See merge request !18
2 parents 3ba62db + d5e5652 commit 529a54f

File tree

7 files changed

+58
-1
lines changed

7 files changed

+58
-1
lines changed

CHANGELOG

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
v5.2.1
2+
- Add ability to unlink runner from CI coordinator
3+
14
v5.2.0
25
- Add RUNNER_DESCRIPTION and RUNNER_TAG_LIST that can be send during runner's registration
36

README.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -117,6 +117,14 @@ bin/setup -C /my/runner/working/directory
117117

118118
You can also specify RUNNER_DESCRIPTION and RUNNER_TAG_LIST during setup.
119119

120+
To unlink the runner from the coordinator you can run following command:
121+
122+
```
123+
bin/unlink
124+
```
125+
126+
It will remove the runner's information from the coordinator and remove the given token from the current runner
127+
120128
#### Create an Upstart job (Ubuntu, Centos 6)
121129

122130
```

VERSION

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
v5.2.0
1+
v5.2.1

bin/unlink

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
#!/usr/bin/env ruby
2+
require 'bundler/setup'
3+
require_relative '../lib/unlink'
4+
5+
GitlabCi::Unlink.new
6+
exit

lib/config.rb

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,10 @@ def write(key, value)
3737
end
3838
end
3939

40+
def destroy
41+
File.delete(config_path)
42+
end
43+
4044
private
4145

4246
def config_path

lib/network.rb

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,17 @@ def register_runner(token, description, tag_list)
9494
end
9595
end
9696

97+
def unlink_runner
98+
opts = {
99+
body: default_options.to_json,
100+
headers: {"Content-Type" => "application/json"},
101+
}
102+
103+
response = self.class.delete(api_url + '/runners/delete', opts)
104+
105+
response.code == 200
106+
end
107+
97108
private
98109

99110
def broadcast message

lib/unlink.rb

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
require_relative 'config'
2+
require_relative 'network'
3+
require 'yaml'
4+
5+
module GitlabCi
6+
class Unlink
7+
def initialize
8+
unlink_runner
9+
end
10+
11+
private
12+
13+
def unlink_runner
14+
status = Network.new.unlink_runner
15+
16+
if status
17+
Config.new.destroy
18+
puts 'Runner unlinked successfully!'
19+
return
20+
else
21+
puts 'Failed to unlink this runner. Perhaps the runner is not subscribed yet or you are having network problems'
22+
end
23+
end
24+
end
25+
end

0 commit comments

Comments
 (0)