Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Andrew Lyons
pipeline
Commits
be34b4d3
Commit
be34b4d3
authored
Dec 17, 2017
by
Andrew Nicols
Browse files
Major refactor
parent
74e90d7a
Changes
8
Hide whitespace changes
Inline
Side-by-side
jobs/phpunit/master/Jenkinsfile
deleted
100644 → 0
View file @
74e90d7a
@Library
(
'ci'
)
def
branch
=
new
org
.
moodle
.
ci
.
branches
.
Master
()
def
Util
=
new
org
.
moodle
.
ci
.
Util
()
def
Repo
=
new
org
.
moodle
.
ci
.
repositories
.
integration
()
Util
.
runJob
(
"phpunit"
,
Repo
.
getUrl
(),
Repo
.
getBranch
(),
Util
.
getDefaultRunCombinations
(
branch
),
false
,
false
);
src/org/moodle/ci/Target.groovy
deleted
100644 → 0
View file @
74e90d7a
package
org.moodle.ci
;
class
Target
{
protected
String
url
protected
String
credentialsId
protected
String
branch
}
src/org/moodle/ci/Task.groovy
0 → 100644
View file @
be34b4d3
package
org.moodle.ci
;
import
org.moodle.ci.repositories.Repository
import
org.moodle.ci.versions.Version
class
Task
{
protected
Repository
repository
protected
Version
moodleVersion
protected
String
url
protected
String
credentialsId
protected
String
branch
protected
String
database
=
'pgsql'
protected
String
phpVersion
protected
String
task
=
'phpunit'
protected
Boolean
notify
=
false
protected
String
pathToRunner
def
getUrl
()
{
if
(
url
)
{
return
url
}
else
if
(
repository
)
{
return
repository
.
url
}
throw
new
Exception
(
'No repository specified.'
)
}
def
getCredentialsId
()
{
if
(
credentialsId
)
{
return
credentialsId
}
else
if
(
repository
&&
repository
.
credentialsId
)
{
return
repository
.
credentialsId
}
return
null
}
def
getBranch
()
{
if
(
branch
)
{
return
branch
}
else
if
(
moodleVersion
)
{
return
moodleVersion
.
defaultBranch
}
throw
new
Exception
(
'No Pull URL set'
)
}
def
getPhpVersion
()
{
if
(
phpVersion
)
{
return
phpVersion
}
else
if
(
moodleVersion
)
{
return
moodleVersion
.
getHighestSupportedVersion
()
}
throw
new
Exception
(
"I don't know what PHP Version to test against"
)
}
def
getPathToRunner
()
{
if
(
pathToRunner
)
{
if
(!
fileExists
(
pathToRunner
))
{
throw
new
Exception
(
"Unable to find job runner at ${pathToRunner}"
)
}
return
pathToRunner
}
else
if
(
moodleVersion
)
{
runner
=
"${env.PATHTORUNNER}/${moodleVersion.name}/run.sh"
if
(!
fileExists
(
runner
))
{
runner
=
"${env.PATHTORUNNER}/master/run.sh"
}
return
runner
}
throw
new
Exception
(
"Unable to determine path to script runner. Either a moodleVersion or a pathToRunner must be provided"
)
}
}
src/org/moodle/ci/Util.groovy
deleted
100644 → 0
View file @
74e90d7a
package
org.moodle.ci
;
def
getDefaultRunCombinations
(
branch
)
{
def
php
=
branch
.
getPhpVersions
()
def
db
=
branch
.
getDatabases
()
def
combinations
=
[:]
for
(
int
i
=
0
;
i
<
db
.
size
();
i
++)
{
combinations
[
i
]
=
[
"db"
:
db
[
i
],
"php"
:
php
[
php
.
size
()
-
1
]
]
}
return
combinations
;
}
def
getHighestSupportedVersion
(
branch
)
{
return
branch
[
branch
.
size
()
-
1
]
}
def
getLowestSupportedVersion
(
branch
)
{
return
branch
[
0
]
}
def
runTask
(
String
task
,
String
repo
,
String
branch
,
String
phpversion
,
String
database
,
Boolean
notify
,
Boolean
publish
)
{
node
(
'docker'
)
{
stage
(
"Git Checkout"
)
{
echo
"Starting ${task} on ${phpversion}/${database} from {$repo} ${branch}"
checkout
(
[
$class
:
'GitSCM'
,
branches:
[
[
name:
"${branch}"
]
],
doGenerateSubmoduleConfigurations:
false
,
extensions:
[
[
$class
:
'CloneOption'
,
depth:
0
,
noTags:
false
,
reference:
"${env.HOME}/caches/integration.git"
,
shallow:
false
],
[
$class
:
'RelativeTargetDirectory'
,
relativeTargetDir:
'moodle'
]
],
submoduleCfg:
[],
userRemoteConfigs:
[
[
url:
"${repo}"
]
]
]
)
}
stage
(
"Run ${task}"
)
{
withEnv
([
"PHP_VERSION=${phpversion}"
,
"DBTYPE=${database}"
,
"TASK=${task}"
])
{
sh
'$HOME/scripts/runner/master/run.sh'
}
}
stage
(
"Post"
)
{
junit
allowEmptyResults:
true
,
testResults:
'$BUILD_ID/*.junit/*.xml,$BUILD_ID/*.junit'
archiveArtifacts
allowEmptyArchive:
true
,
artifacts:
'$BUILD_ID/**'
cleanWs
deleteDirs:
true
,
notFailBuild:
true
}
}
}
return
this
;
src/org/moodle/ci/
branche
s/Master.groovy
→
src/org/moodle/ci/
version
s/Master.groovy
View file @
be34b4d3
package
org.moodle.ci.
branche
s
;
package
org.moodle.ci.
version
s
;
class
Master
extends
Branch
{
class
Master
extends
Version
{
Master
()
{
this
.
name
=
"master"
this
.
defaultBranch
=
"master"
this
.
supportedPHPVersions
=
[
"7.0"
,
...
...
src/org/moodle/ci/
branches/Branch
.groovy
→
src/org/moodle/ci/
versions/Version
.groovy
View file @
be34b4d3
package
org.moodle.ci.branches
;
package
org.moodle.ci.versions
;
class
Version
{
protected
String
name
class
Branch
{
protected
String
defaultBranch
protected
String
[]
supportedPHPVersions
...
...
vars/baseCheckout.groovy
deleted
100644 → 0
View file @
74e90d7a
def
call
()
{
pipeline
{
agent
{
label
'docker'
}
stages
{
stage
(
"Git Checkout"
)
{
steps
{
checkout
(
[
$class
:
'GitSCM'
,
branches:
[
[
name:
"master"
]
],
doGenerateSubmoduleConfigurations:
false
,
extensions:
[
[
$class
:
'CloneOption'
,
depth:
0
,
noTags:
false
,
shallow:
true
]
],
submoduleCfg:
[],
userRemoteConfigs:
[
[
url:
"https://github.com/moodle/moodle.git"
]
]
]
)
}
}
}
}
}
return
this
vars/runTask.groovy
View file @
be34b4d3
def
call
(
String
task
,
org
.
moodle
.
ci
.
Ta
rget
Target
,
String
phpversion
,
String
database
,
Boolean
notify
)
{
def
call
(
org
.
moodle
.
ci
.
Ta
sk
task
)
{
pipeline
{
agent
{
label
'docker'
}
environment
{
PHP_VERSION
=
"${php
v
ersion}"
DBTYPE
=
"${database}"
TESTTORUN
=
"${task}"
PHP_VERSION
=
"${
task.
php
V
ersion}"
DBTYPE
=
"${
task.
database}"
TESTTORUN
=
"${task
.task
}"
PATHTORUNNER
=
"${HOME}/scripts/runner"
}
...
...
@@ -19,7 +19,7 @@ def call(String task, org.moodle.ci.Target Target, String phpversion, String dat
$class
:
'GitSCM'
,
branches:
[
[
name:
"${
Target
.branch}"
name:
"${
task
.branch}"
]
],
doGenerateSubmoduleConfigurations:
false
,
...
...
@@ -39,8 +39,8 @@ def call(String task, org.moodle.ci.Target Target, String phpversion, String dat
submoduleCfg:
[],
userRemoteConfigs:
[
[
url:
"${
Target
.url}"
,
credentialsId:
"${
Target
.credentialsId}"
url:
"${
task
.url}"
,
credentialsId:
"${
task
.credentialsId}"
]
]
]
...
...
@@ -48,24 +48,9 @@ def call(String task, org.moodle.ci.Target Target, String phpversion, String dat
}
}
stage
(
"Detect Moodle Version"
)
{
steps
{
script
{
moodleversion
=
sh
(
script:
'grep "\\$branch" moodle/version.php | sed "s/^[^\']*\'\\([^\']*\\).*\$/\\1/"'
,
returnStdout:
true
).
trim
()
runner
=
"${env.PATHTORUNNER}/${moodleversion}"
if
(!
fileExists
(
runner
))
{
runner
=
"${env.PATHTORUNNER}/master"
}
}
}
}
stage
(
"Run Task"
)
{
steps
{
sh
"${runner}/run.sh"
sh
task
.
pathToRunner
}
}
...
...
Write
Preview
Supports
Markdown
0%
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!
Cancel
Please
register
or
sign in
to comment