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
865f80b7
Commit
865f80b7
authored
8 years ago
by
Jan Christophersen
Committed by
Tomasz Maczukin
8 years ago
Browse files
Options
Downloads
Patches
Plain Diff
Add handling for GIT_CHECKOUT variable to skip checkout
parent
e86452b8
Branches
Branches containing commit
Tags
Tags containing commit
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
common/build.go
+17
-0
17 additions, 0 deletions
common/build.go
executors/shell/executor_shell_test.go
+48
-0
48 additions, 0 deletions
executors/shell/executor_shell_test.go
shells/abstract.go
+6
-5
6 additions, 5 deletions
shells/abstract.go
with
71 additions
and
5 deletions
common/build.go
+
17
−
0
View file @
865f80b7
...
...
@@ -463,6 +463,23 @@ func (b *Build) GetGitStrategy() GitStrategy {
}
}
func
(
b
*
Build
)
GetGitCheckout
()
bool
{
if
b
.
GetGitStrategy
()
==
GitNone
{
return
false
}
strCheckout
:=
b
.
GetAllVariables
()
.
Get
(
"GIT_CHECKOUT"
)
if
len
(
strCheckout
)
==
0
{
return
true
}
checkout
,
err
:=
strconv
.
ParseBool
(
strCheckout
)
if
err
!=
nil
{
return
true
}
return
checkout
}
func
(
b
*
Build
)
GetSubmoduleStrategy
()
SubmoduleStrategy
{
if
b
.
GetGitStrategy
()
==
GitNone
{
return
SubmoduleNone
...
...
This diff is collapsed.
Click to expand it.
executors/shell/executor_shell_test.go
+
48
−
0
View file @
865f80b7
...
...
@@ -212,11 +212,36 @@ func TestBuildWithGitStrategyFetch(t *testing.T) {
out
,
err
:=
runBuildReturningOutput
(
t
,
build
)
assert
.
NoError
(
t
,
err
)
assert
.
Contains
(
t
,
out
,
"Cloning repository"
)
assert
.
Regexp
(
t
,
"Checking out [a-f0-9]+ as"
,
out
)
out
,
err
=
runBuildReturningOutput
(
t
,
build
)
assert
.
NoError
(
t
,
err
)
assert
.
Contains
(
t
,
out
,
"Fetching changes"
)
assert
.
Regexp
(
t
,
"Checking out [a-f0-9]+ as"
,
out
)
assert
.
Contains
(
t
,
out
,
"pre-clone-script"
)
})
}
func
TestBuildWithGitStrategyFetchNoCheckout
(
t
*
testing
.
T
)
{
onEachShell
(
t
,
func
(
t
*
testing
.
T
,
shell
string
)
{
successfulBuild
,
err
:=
common
.
GetSuccessfulBuild
()
assert
.
NoError
(
t
,
err
)
build
,
cleanup
:=
newBuild
(
t
,
successfulBuild
,
shell
)
defer
cleanup
()
build
.
Runner
.
PreCloneScript
=
"echo pre-clone-script"
build
.
Variables
=
append
(
build
.
Variables
,
common
.
JobVariable
{
Key
:
"GIT_STRATEGY"
,
Value
:
"fetch"
})
build
.
Variables
=
append
(
build
.
Variables
,
common
.
JobVariable
{
Key
:
"GIT_CHECKOUT"
,
Value
:
"false"
})
out
,
err
:=
runBuildReturningOutput
(
t
,
build
)
assert
.
NoError
(
t
,
err
)
assert
.
Contains
(
t
,
out
,
"Cloning repository"
)
assert
.
Contains
(
t
,
out
,
"Skippping Git checkout"
)
out
,
err
=
runBuildReturningOutput
(
t
,
build
)
assert
.
NoError
(
t
,
err
)
assert
.
Contains
(
t
,
out
,
"Fetching changes"
)
assert
.
Contains
(
t
,
out
,
"Skippping Git checkout"
)
assert
.
Contains
(
t
,
out
,
"pre-clone-script"
)
})
}
...
...
@@ -238,7 +263,30 @@ func TestBuildWithGitStrategyClone(t *testing.T) {
out
,
err
=
runBuildReturningOutput
(
t
,
build
)
assert
.
NoError
(
t
,
err
)
assert
.
Contains
(
t
,
out
,
"Cloning repository"
)
assert
.
Regexp
(
t
,
"Checking out [a-f0-9]+ as"
,
out
)
assert
.
Contains
(
t
,
out
,
"pre-clone-script"
)
})
}
func
TestBuildWithGitStrategyCloneNoCheckout
(
t
*
testing
.
T
)
{
onEachShell
(
t
,
func
(
t
*
testing
.
T
,
shell
string
)
{
successfulBuild
,
err
:=
common
.
GetSuccessfulBuild
()
assert
.
NoError
(
t
,
err
)
build
,
cleanup
:=
newBuild
(
t
,
successfulBuild
,
shell
)
defer
cleanup
()
build
.
Runner
.
PreCloneScript
=
"echo pre-clone-script"
build
.
Variables
=
append
(
build
.
Variables
,
common
.
JobVariable
{
Key
:
"GIT_STRATEGY"
,
Value
:
"clone"
})
build
.
Variables
=
append
(
build
.
Variables
,
common
.
JobVariable
{
Key
:
"GIT_CHECKOUT"
,
Value
:
"false"
})
out
,
err
:=
runBuildReturningOutput
(
t
,
build
)
assert
.
NoError
(
t
,
err
)
assert
.
Contains
(
t
,
out
,
"Cloning repository"
)
out
,
err
=
runBuildReturningOutput
(
t
,
build
)
assert
.
NoError
(
t
,
err
)
assert
.
Contains
(
t
,
out
,
"Cloning repository"
)
assert
.
Contains
(
t
,
out
,
"Skippping Git checkout"
)
assert
.
Contains
(
t
,
out
,
"pre-clone-script"
)
})
}
...
...
This diff is collapsed.
Click to expand it.
shells/abstract.go
+
6
−
5
View file @
865f80b7
...
...
@@ -248,20 +248,21 @@ func (b *AbstractShell) writeCloneFetchCmds(w ShellWriter, info common.ShellScri
switch
info
.
Build
.
GetGitStrategy
()
{
case
common
.
GitFetch
:
b
.
writeFetchCmd
(
w
,
build
,
projectDir
,
gitDir
)
b
.
writeCheckoutCmd
(
w
,
build
)
case
common
.
GitClone
:
b
.
writeCloneCmd
(
w
,
build
,
projectDir
)
b
.
writeCheckoutCmd
(
w
,
build
)
case
common
.
GitNone
:
w
.
Notice
(
"Skipping Git repository setup"
)
w
.
MkDir
(
projectDir
)
default
:
return
errors
.
New
(
"unknown GIT_STRATEGY"
)
}
if
info
.
Build
.
GetGitCheckout
()
{
b
.
writeCheckoutCmd
(
w
,
build
)
}
else
{
w
.
Notice
(
"Skippping Git checkout"
)
}
return
nil
}
...
...
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