Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
I
Imldeployment
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container registry
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
IML Open Source
Imldeployment
Commits
fc406554
Commit
fc406554
authored
2 years ago
by
hahn
Browse files
Options
Downloads
Patches
Plain Diff
add build plugins
parent
b0ec80dd
No related branches found
No related tags found
1 merge request
!19
5534 add docker
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
public_html/deployment/classes/build.interface.php
+41
-0
41 additions, 0 deletions
public_html/deployment/classes/build.interface.php
public_html/deployment/classes/build_base.class.php
+208
-0
208 additions, 0 deletions
public_html/deployment/classes/build_base.class.php
with
249 additions
and
0 deletions
public_html/deployment/classes/build.interface.php
0 → 100644
+
41
−
0
View file @
fc406554
<?php
/**
* INTERFACE for rollout plugins
*
* @author hahn
*/
interface
iBuildplugin
{
// ----------------------------------------------------------------------
// VERIFY
// ----------------------------------------------------------------------
/**
* check requirements if the plugin could work
public function checkRequirements();
*/
/**
* get an array with shell commands to execute
* @return array
*/
public
function
getBuildCommands
();
/**
* get name of plugin as string ... language specific
public function getName();
*/
/**
* get description of plugin as string ... language specific
public function getDescription();
*/
/**
* get array of data in info.js
public function getPluginInfos();
*/
}
This diff is collapsed.
Click to expand it.
public_html/deployment/classes/build_base.class.php
0 → 100644
+
208
−
0
View file @
fc406554
<?php
require_once
'build.interface.php'
;
/**
* build_base class that will be extended in a rollout plugin
* see deployment/plugins/build/*
*
* @author axel
*/
class
build_base
implements
iBuildplugin
{
protected
$_sBuildDir
=
false
;
protected
$_sOutfile
=
false
;
protected
$_sLang
=
"en"
;
protected
$_aLang
=
[];
// ---------------------------------------------------------------
// CONSTRUCTOR
// ---------------------------------------------------------------
/**
* initialize build plugin
* @param array $aParams hash with those possible keys
* lang string language, i.e. 'de'
* phase string name of phase in a project
* globalcfg array given global config $aConfig
* projectcfg array project config to generate config
* for project and all phases
* @return boolean
*/
public
function
__construct
(
$aParams
)
{
// set current plugin id - taken from plugin directory name above
$oReflection
=
new
ReflectionClass
(
$this
);
$this
->
_sPluginId
=
basename
(
dirname
(
$oReflection
->
getFileName
()));
// ----- init language
if
(
isset
(
$aParams
[
'lang'
])){
$this
->
setLang
(
$aParams
[
'lang'
]);
}
else
{
$this
->
setLang
();
}
if
(
isset
(
$aParams
[
'workdir'
])){
$this
->
setWorkdir
(
$aParams
[
'workdir'
]);
}
if
(
isset
(
$aParams
[
'outfile'
])){
$this
->
setOutfile
(
$aParams
[
'outfile'
]);
}
return
true
;
}
// ---------------------------------------------------------------
// LANGUAGE TEXTS
// ---------------------------------------------------------------
/**
* get a translated text from lang_XX.json in plugin dir;
* If the key is missed it returns "[KEY :: LANG]"
*
* @see setLang()
* @param string $sKey key to find in lang file
* @return string
*/
protected
function
_t
(
$sKey
){
return
(
isset
(
$this
->
_aLang
[
$sKey
])
&&
$this
->
_aLang
[
$sKey
])
?
$this
->
_aLang
[
$sKey
]
:
"[
$sKey
::
$this->_sLang
]"
;
}
/**
* set language for output of formdata and other texts.
* This method loads the language file into a hash. The output of
* translated texts can be done with $this->_t("your_key")
*
* @see _t()
* @param string $sLang language code, i.e. "de"
* @return boolean
*/
public
function
setLang
(
$sLang
=
false
){
$this
->
_sLang
=
$sLang
?
$sLang
:
$this
->
_sLang
;
$oReflection
=
new
ReflectionClass
(
$this
);
$sFile
=
dirname
(
$oReflection
->
getFileName
())
.
'/lang_'
.
$this
->
_sLang
.
'.json'
;
$this
->
_aLang
=
(
file_exists
(
$sFile
))
?
json_decode
(
file_get_contents
(
$sFile
),
1
)
:
$this
->
_aLang
;
return
true
;
}
// ---------------------------------------------------------------
// SETTER
// ---------------------------------------------------------------
/**
* set build dir with sources
* @param string $sBuildDir full path of the build directory
* @return array
*/
public
function
setWorkdir
(
$sBuildDir
){
return
$this
->
_sBuildDir
=
$sBuildDir
?
$sBuildDir
:
$this
->
_sBuildDir
;
}
/**
* set outfile name
* @param string $sOutFilename filename for output (without extension)
* @return array
*/
public
function
setOutfile
(
$sOutFilename
){
return
$this
->
_sOutfile
=
$sOutFilename
?
$sOutFilename
.
$this
->
getExtension
()
:
$this
->
_sOutfile
;
}
// ---------------------------------------------------------------
// GETTER
// ---------------------------------------------------------------
/**
* get an array with shell commands to execute
* @param string $sBuildDir full path of the build directory
* @param string $sOutFilename filename for output
* @return array
*/
public
function
getBuildCommands
(){
return
[
'echo "ERROR: The method getBuildCommamds() was not implemented in the build plugin ['
.
$this
->
getId
()
.
']"'
,
'exit 1'
];
}
/**
* get string with current ID
* @return string
*/
public
function
getId
(){
return
$this
->
_sPluginId
;
}
/**
* get string with plugin name (taken from plugin language file)
* @return string
*/
public
function
getName
(){
return
$this
->
_t
(
'plugin_name'
);
}
/**
* get string with plugin description (taken from plugin language file)
* @return string
*/
public
function
getDescription
(){
return
$this
->
_t
(
'description'
);
}
/**
* get array read from info.json
* @return type
*/
public
function
getPluginInfos
(){
if
(
$this
->
_aPlugininfos
){
return
$this
->
_aPlugininfos
;
}
$oReflection
=
new
ReflectionClass
(
$this
);
$sFile
=
dirname
(
$oReflection
->
getFileName
())
.
'/info.json'
;
$this
->
_aPlugininfos
=
(
file_exists
(
$sFile
))
?
json_decode
(
file_get_contents
(
$sFile
),
1
)
:
array
(
'error'
=>
'unable to read info file ['
.
$sFile
.
'].'
)
;
return
$this
->
_aPlugininfos
;
}
/**
* get the file extension of created output file (from plugin info.json)
*/
public
function
getExtension
(){
$aInfos
=
$this
->
getPluginInfos
();
return
isset
(
$aInfos
[
'extenmsion'
])
?
'.'
.
$aInfos
[
'extenmsion'
]
:
''
;
}
/**
* set outfile name
* @param string $sOutFilename filename for output (without extension)
* @return array
*/
public
function
getOutfile
(){
return
$this
->
_sOutfile
;
}
/**
* set outfile name
* @param string $sOutFilename filename for output (without extension)
* @return array
*/
public
function
getBuildDir
(){
return
$this
->
_sBuildDir
;
}
// ----------------------------------------------------------------------
// INTERFACE :: RENDERER
// ----------------------------------------------------------------------
public
function
renderPluginBox
(){
$sReturn
=
''
;
$aInfos
=
$this
->
getPluginInfos
();
return
'<strong>'
.
$this
->
getName
()
.
'</strong> ('
.
$this
->
getId
()
.
')<br>
'
.
$this
->
getDescription
();
}
}
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