Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
G
gitlab-runner
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Lars Seipel
gitlab-runner
Commits
0b1efbf0
Commit
0b1efbf0
authored
9 years ago
by
Lucas Jenss
Browse files
Options
Downloads
Patches
Plain Diff
Change unregister command to accept runner name
parent
6e269af5
No related branches found
No related tags found
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
commands/config.go
+15
-0
15 additions, 0 deletions
commands/config.go
commands/unregister.go
+16
-5
16 additions, 5 deletions
commands/unregister.go
docs/commands/README.md
+14
-4
14 additions, 4 deletions
docs/commands/README.md
with
45 additions
and
9 deletions
commands/config.go
+
15
−
0
View file @
0b1efbf0
package
commands
import
(
"fmt"
"gitlab.com/gitlab-org/gitlab-ci-multi-runner/common"
"gitlab.com/gitlab-org/gitlab-ci-multi-runner/network"
"os"
...
...
@@ -49,6 +50,20 @@ func (c *configOptions) touchConfig() error {
return
nil
}
func
(
c
*
configOptions
)
RunnerByName
(
name
string
)
(
*
common
.
RunnerConfig
,
error
)
{
if
c
.
config
==
nil
{
return
nil
,
fmt
.
Errorf
(
"Config has not been loaded"
)
}
for
_
,
runner
:=
range
c
.
config
.
Runners
{
if
runner
.
Name
==
name
{
return
runner
,
nil
}
}
return
nil
,
fmt
.
Errorf
(
"Could not find a runner with the name '%s'"
,
name
)
}
func
init
()
{
configFile
:=
os
.
Getenv
(
"CONFIG_FILE"
)
if
configFile
==
""
{
...
...
This diff is collapsed.
Click to expand it.
commands/unregister.go
+
16
−
5
View file @
0b1efbf0
...
...
@@ -12,18 +12,29 @@ type UnregisterCommand struct {
configOptions
common
.
RunnerCredentials
network
common
.
Network
Name
string
`toml:"name" json:"name" short:"n" long:"name" description:"Name of the runner you wish to unregister"`
}
func
(
c
*
UnregisterCommand
)
Execute
(
context
*
cli
.
Context
)
{
userModeWarning
(
false
)
if
!
c
.
network
.
DeleteRunner
(
c
.
RunnerCredentials
)
{
log
.
Fatalln
(
"Failed to delete runner"
)
}
err
:=
c
.
loadConfig
()
if
err
!=
nil
{
log
.
Warningln
(
err
)
log
.
Fatalln
(
err
)
return
}
if
len
(
c
.
Name
)
>
0
{
runnerConfig
,
err
:=
c
.
RunnerByName
(
c
.
Name
)
if
err
!=
nil
{
log
.
Fatalln
(
err
)
return
}
c
.
RunnerCredentials
=
runnerConfig
.
RunnerCredentials
}
if
!
c
.
network
.
DeleteRunner
(
c
.
RunnerCredentials
)
{
log
.
Fatalln
(
"Failed to delete runner"
,
c
.
Name
)
return
}
...
...
This diff is collapsed.
Click to expand it.
docs/commands/README.md
+
14
−
4
View file @
0b1efbf0
...
...
@@ -288,22 +288,32 @@ gitlab-runner verify --delete
### gitlab-runner unregister
This command allows to unregister one of the registered runners. It expects
to
enter
a full URL and the runner's token. First get the runner's details by
This command allows to unregister one of the registered runners. It expects
either
a full URL and the runner's token
, or the runner's name
. First get the runner's details by
executing
`gitlab-runner list`
:
```
bash
test-runner
Executor
=
shell
Token
=
t0k3n
URL
=
http://gitlab.example.com/ci/
```
Then use this information to unregister it, using the following command.
Then use this information to unregister it, using
one of
the following command
s
.
>**Warning:**
This operation cannot be undone, it will update the configuration file, so
make sure to have a backup of
`config.toml`
before executing it.
#### By URL and token:
```
bash
gitlab-runner unregister
--url
http://gitlab.example.com/ci/
--token
t0k3n
```
#### By name:
> **Note:** If there is more than one runner with the given name, only the first one will be removed
```
bash
gitlab-runner unregister
-
u
http://gitlab.example.com/ci/
-t
t0k3n
gitlab-runner unregister
-
-name
test-runner
```
## Service-related commands
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment