Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
T
test_Shared_library_for_projects
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Khawaja Ibrahim Mohiuddin
test_Shared_library_for_projects
Commits
cfdd1f6b
Commit
cfdd1f6b
authored
Jan 22, 2021
by
Khawaja Ibrahim Mohiuddin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
remove unwanted file from src
parent
83a71eaf
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
0 additions
and
71 deletions
+0
-71
ReleaseCheck.groovy
src/com/example/ReleaseCheck.groovy
+0
-71
No files found.
src/com/example/ReleaseCheck.groovy
deleted
100644 → 0
View file @
83a71eaf
package
com.example
class
ReleaseCheck
{
void
checkExistence
(
String
branch_name
,
String
yaml_path
)
{
appendIfNotExist
(
branch_name
,
yaml_path
)
}
def
appendIfNotExist
(
String
buildName
,
String
fileName
){
// Opening the File
yamlFile
=
new
File
(
fileName
)
// Yaml Reader
def
ys
=
new
YamlSlurper
()
// Parsing the YAML and checking if Branch name exists
yamlFile
.
withReader
{
reader
->
def
yaml
=
ys
.
parse
(
reader
)
def
git_base_branch_to_deploy
=
yaml
.
git
.
branchBaseDeployment
if
(
git_base_branch_to_deploy
[
"$buildName"
])
{
println
"Branch Name to deploy Already Exists"
}
else
{
println
"The branch name $buildName does not exist, appending in the YAML file"
// Append in the File as It doesn't exist
appendNew
(
buildName
)
}
}
}
// A function to append new banch build name according to the conditions
def
appendNew
(
String
newBuildName
)
{
// Data to be appended, will be defined by conditions
def
config
// YamlBuild to convert Groovy Objects to Yaml
def
yaml
=
new
YamlBuilder
()
// End Result String to be Appended in the File
def
end_result
// Conditions to design the YAML object
if
(
newBuildName
.
substring
(
0
,
7
)
==
"release"
){
config
=
[
"$newBuildName"
:
[
env:
"dit1"
,
promoteTo:
"eqa1"
,
enabled:
true
]]
yaml
(
config
)
end_result
=
yaml
.
toString
()
}
else
if
(
newBuildName
.
substring
(
0
,
7
)
==
"develop"
){
config
=
[
"$newBuildName"
:
[
env:
"dit2"
,
promoteTo:
"eq2"
,
enabled:
true
]]
yaml
(
config
)
end_result
=
yaml
.
toString
()
}
else
if
(
newBuildName
.
substring
(
0
,
7
)
==
"feature"
){
config
=
[
"$newBuildName"
:
[
env:
"dev1"
,
promoteTo:
"dev2"
,
enabled:
true
]]
yaml
(
config
)
end_result
=
yaml
.
toString
()
}
else
{
// Handle any other release, other than: release, develop and feature
config
=
[
"$newBuildName"
:
[
env:
"dev1"
,
promoteTo:
"dev2"
,
enabled:
true
]]
yaml
(
config
)
end_result
=
yaml
.
toString
()
}
// As it generates a new Yaml Document, remove the firstline
end_result
=
end_result
.
replace
(
'---'
,
''
)
// Replace 2 spaces with 6 spaces for the children inside <branch_name>
end_result
=
end_result
.
replace
(
" "
,
" "
)
// Append 4 space characters in the first line
// Some Shadowing
end_result
.
eachMatch
(
"$newBuildName"
)
{
ch
->
end_result
=
end_result
.
replace
(
ch
,
" "
+
ch
)}
// Append the End Result string to the YAML file
yamlFile
.
append
(
end_result
)
}
// Function Usage appendIfNotExists('Branch Name (Can only be: release, develop, feature)', 'FileName to read data from and append data to')
}
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