Skip to content
GitLab
Next
Projects
Groups
Snippets
Help
Loading...
Help
What's new
4
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
gitlab-runner
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Locked Files
Issues
1,985
Issues
1,985
List
Boards
Labels
Service Desk
Milestones
Iterations
Merge Requests
213
Merge Requests
213
Requirements
Requirements
List
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Test Cases
Security & Compliance
Security & Compliance
Dependency List
License Compliance
Operations
Operations
Incidents
Environments
Packages & Registries
Packages & Registries
Container Registry
Analytics
Analytics
CI / CD
Code Review
Insights
Issue
Repository
Value Stream
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
GitLab.org
gitlab-runner
Commits
fe798d37
Commit
fe798d37
authored
Jun 06, 2015
by
Kamil Trzciński
💬
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Added support for custom variables received from CI
parent
401b7b0f
Pipeline
#39214
failed with stage
Changes
6
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
64 additions
and
69 deletions
+64
-69
CHANGELOG.md
CHANGELOG.md
+1
-0
common/network.go
common/network.go
+15
-9
shells/abstract.go
shells/abstract.go
+42
-0
shells/bash.go
shells/bash.go
+2
-20
shells/cmd.go
shells/cmd.go
+2
-20
shells/powershell.go
shells/powershell.go
+2
-20
No files found.
CHANGELOG.md
View file @
fe798d37
v 0.4.0
-
Added CI=true and GITLAB_CI=true to environment variables
-
Added output_limit (in kilobytes) to runner config which allows to enlarge default build log size
-
Added support for custom variables received from CI
-
Make the debug log human readable
-
Make default build log limit set to 4096 (4MB)
-
Updated kardianos service to fix OSX service installation
...
...
common/network.go
View file @
fe798d37
...
...
@@ -35,16 +35,22 @@ type GetBuildRequest struct {
Token
string
`json:"token,omitempty"`
}
type
BuildVariable
struct
{
Key
string
`json:"key"`
Value
string
`json:"value"`
}
type
GetBuildResponse
struct
{
ID
int
`json:"id,omitempty"`
ProjectID
int
`json:"project_id,omitempty"`
Commands
string
`json:"commands,omitempty"`
RepoURL
string
`json:"repo_url,omitempty"`
Sha
string
`json:"sha,omitempty"`
RefName
string
`json:"ref,omitempty"`
BeforeSha
string
`json:"before_sha,omitempty"`
AllowGitFetch
bool
`json:"allow_git_fetch,omitempty"`
Timeout
int
`json:"timeout,omitempty"`
ID
int
`json:"id,omitempty"`
ProjectID
int
`json:"project_id,omitempty"`
Commands
string
`json:"commands,omitempty"`
RepoURL
string
`json:"repo_url,omitempty"`
Sha
string
`json:"sha,omitempty"`
RefName
string
`json:"ref,omitempty"`
BeforeSha
string
`json:"before_sha,omitempty"`
AllowGitFetch
bool
`json:"allow_git_fetch,omitempty"`
Timeout
int
`json:"timeout,omitempty"`
Variables
[]
BuildVariable
`json:"variables"`
}
type
RegisterRunnerRequest
struct
{
...
...
shells/abstract.go
0 → 100644
View file @
fe798d37
package
shells
import
(
"fmt"
.
"gitlab.com/gitlab-org/gitlab-ci-multi-runner/common"
)
type
AbstractShell
struct
{
}
func
(
s
*
AbstractShell
)
GetDefaultVariables
(
build
*
Build
,
projectDir
string
)
[]
string
{
return
[]
string
{
fmt
.
Sprintf
(
"CI_BUILD_REF=%s"
,
build
.
Sha
),
fmt
.
Sprintf
(
"CI_BUILD_BEFORE_SHA=%s"
,
build
.
BeforeSha
),
fmt
.
Sprintf
(
"CI_BUILD_REF_NAME=%s"
,
build
.
RefName
),
fmt
.
Sprintf
(
"CI_BUILD_ID=%d"
,
build
.
ID
),
fmt
.
Sprintf
(
"CI_BUILD_REPO=%s"
,
build
.
RepoURL
),
fmt
.
Sprintf
(
"CI_PROJECT_ID=%d"
,
build
.
ProjectID
),
fmt
.
Sprintf
(
"CI_PROJECT_DIR=%s"
,
projectDir
),
"CI=true"
,
"CI_SERVER=yes"
,
"CI_SERVER_NAME=GitLab CI"
,
"CI_SERVER_VERSION="
,
"CI_SERVER_REVISION="
,
"GITLAB_CI=true"
,
}
}
func
(
s
*
AbstractShell
)
GetBuildVariables
(
build
*
Build
)
[]
string
{
var
variables
[]
string
for
_
,
variable
:=
range
build
.
Variables
{
variables
=
append
(
variables
,
fmt
.
Sprintf
(
"%s=%s"
,
variable
.
Key
,
variable
.
Value
))
}
return
variables
}
func
(
s
*
AbstractShell
)
GetVariables
(
build
*
Build
,
projectDir
string
)
[]
string
{
variables
:=
s
.
GetDefaultVariables
(
build
,
projectDir
)
variables
=
append
(
variables
,
s
.
GetBuildVariables
(
build
)
...
)
return
variables
}
shells/bash.go
View file @
fe798d37
...
...
@@ -12,6 +12,7 @@ import (
)
type
BashShell
struct
{
AbstractShell
}
func
(
b
*
BashShell
)
GetName
()
string
{
...
...
@@ -81,27 +82,8 @@ func (b *BashShell) GenerateScript(build *common.Build, shellType common.ShellTy
w
.
Flush
()
env
:=
[]
string
{
fmt
.
Sprintf
(
"CI_BUILD_REF=%s"
,
build
.
Sha
),
fmt
.
Sprintf
(
"CI_BUILD_BEFORE_SHA=%s"
,
build
.
BeforeSha
),
fmt
.
Sprintf
(
"CI_BUILD_REF_NAME=%s"
,
build
.
RefName
),
fmt
.
Sprintf
(
"CI_BUILD_ID=%d"
,
build
.
ID
),
fmt
.
Sprintf
(
"CI_BUILD_REPO=%s"
,
build
.
RepoURL
),
fmt
.
Sprintf
(
"CI_PROJECT_ID=%d"
,
build
.
ProjectID
),
fmt
.
Sprintf
(
"CI_PROJECT_DIR=%s"
,
projectDir
),
"CI=true"
,
"CI_SERVER=yes"
,
"CI_SERVER_NAME=GitLab CI"
,
"CI_SERVER_VERSION="
,
"CI_SERVER_REVISION="
,
"GITLAB_CI=true"
,
}
script
:=
common
.
ShellScript
{
Environment
:
env
,
Environment
:
b
.
GetVariables
(
build
,
projectDir
)
,
Script
:
buffer
.
String
(),
Command
:
"bash"
,
}
...
...
shells/cmd.go
View file @
fe798d37
...
...
@@ -12,6 +12,7 @@ import (
)
type
CmdShell
struct
{
AbstractShell
}
func
(
b
*
CmdShell
)
GetName
()
string
{
...
...
@@ -93,27 +94,8 @@ func (b *CmdShell) GenerateScript(build *common.Build, shellType common.ShellTyp
w
.
Flush
()
env
:=
[]
string
{
fmt
.
Sprintf
(
"CI_BUILD_REF=%s"
,
build
.
Sha
),
fmt
.
Sprintf
(
"CI_BUILD_BEFORE_SHA=%s"
,
build
.
BeforeSha
),
fmt
.
Sprintf
(
"CI_BUILD_REF_NAME=%s"
,
build
.
RefName
),
fmt
.
Sprintf
(
"CI_BUILD_ID=%d"
,
build
.
ID
),
fmt
.
Sprintf
(
"CI_BUILD_REPO=%s"
,
build
.
RepoURL
),
fmt
.
Sprintf
(
"CI_PROJECT_ID=%d"
,
build
.
ProjectID
),
fmt
.
Sprintf
(
"CI_PROJECT_DIR=%s"
,
projectDir
),
"CI=true"
,
"CI_SERVER=yes"
,
"CI_SERVER_NAME=GitLab CI"
,
"CI_SERVER_VERSION="
,
"CI_SERVER_REVISION="
,
"GITLAB_CI=true"
,
}
script
:=
common
.
ShellScript
{
Environment
:
env
,
Environment
:
b
.
GetVariables
(
build
,
projectDir
)
,
Script
:
buffer
.
String
(),
Command
:
"cmd"
,
Arguments
:
[]
string
{
"/Q"
,
"/C"
},
...
...
shells/powershell.go
View file @
fe798d37
...
...
@@ -11,6 +11,7 @@ import (
)
type
PowerShell
struct
{
AbstractShell
}
func
(
b
*
PowerShell
)
GetName
()
string
{
...
...
@@ -91,27 +92,8 @@ func (b *PowerShell) GenerateScript(build *common.Build, shellType common.ShellT
w
.
Flush
()
env
:=
[]
string
{
fmt
.
Sprintf
(
"CI_BUILD_REF=%s"
,
build
.
Sha
),
fmt
.
Sprintf
(
"CI_BUILD_BEFORE_SHA=%s"
,
build
.
BeforeSha
),
fmt
.
Sprintf
(
"CI_BUILD_REF_NAME=%s"
,
build
.
RefName
),
fmt
.
Sprintf
(
"CI_BUILD_ID=%d"
,
build
.
ID
),
fmt
.
Sprintf
(
"CI_BUILD_REPO=%s"
,
build
.
RepoURL
),
fmt
.
Sprintf
(
"CI_PROJECT_ID=%d"
,
build
.
ProjectID
),
fmt
.
Sprintf
(
"CI_PROJECT_DIR=%s"
,
projectDir
),
"CI=true"
,
"CI_SERVER=yes"
,
"CI_SERVER_NAME=GitLab CI"
,
"CI_SERVER_VERSION="
,
"CI_SERVER_REVISION="
,
"GITLAB_CI=true"
,
}
script
:=
common
.
ShellScript
{
Environment
:
env
,
Environment
:
b
.
GetVariables
(
build
,
projectDir
)
,
Script
:
buffer
.
String
(),
Command
:
"powershell"
,
Arguments
:
[]
string
{
"-noprofile"
,
"-noninteractive"
,
"-executionpolicy"
,
"Bypass"
,
"-command"
},
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment