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
2605659a
Commit
2605659a
authored
Jan 22, 2021
by
Khawaja Ibrahim Mohiuddin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
added jobdsl jobs
parent
4263eddf
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
57 additions
and
64 deletions
+57
-64
commonConfig.yaml
resources/commonConfig.yaml
+1
-1
CreateJobs.groovy
src/com/example/CreateJobs.groovy
+0
-47
jobs.groovy
vars/jobs.groovy
+51
-5
main.groovy
vars/main.groovy
+5
-11
No files found.
resources/commonConfig.yaml
View file @
2605659a
...
...
@@ -4,7 +4,7 @@ git:
env
:
dit1
promoteTo
:
eqa1
enabled
:
false
release.2020.10
:
release.2020.10
:
env
:
dit3
promoteTo
:
eqa3
enabled
:
false
...
...
src/com/example/CreateJobs.groovy
deleted
100644 → 0
View file @
4263eddf
package
com.example
class
CreateJobs
{
public
Boolean
createPipelineJob
(
String
jobName
,
String
repoUrl
,
String
credentialsID
,
String
srcBranch
,
String
jenkinsfilePath
){
pipelineJob
(
jobName
)
{
definition
{
cpsScm
{
scm
{
git
{
remote
{
name
(
jobName
)
url
(
repoUrl
)
credentials
(
credentialsID
)
}
branch
(
srcBranch
)
}
scriptPath
(
jenkinsfilePath
)
}
}
}
}
}
public
Boolean
createMultibranchPipelineJob
(){
multibranchPipelineJob
(
String
jobName
,
String
repoUrl
,
String
credentialsID
,
String
srcBranch
,
String
jenkinsfilePath
,
List
srcBranches
)
{
branchSources
{
git
{
remote
{
name
(
jobName
)
url
(
repoUrl
)
credentials
(
credentialsID
)
}
includes
(
srcBranches
)
}
scriptPath
(
jenkinsfilePath
)
}
}
}
public
Boolean
createFolder
(
String
foldername
){
folder
(
foldername
)
{
displayName
(
foldername
)
description
(
foldername
+
" folder"
)
}
}
}
\ No newline at end of file
vars/jobs.groovy
View file @
2605659a
import
com.example.ReleaseCheck
import
com.example.CreateJobs
def
createPipelineJob
(
String
jobName
,
String
repoUrl
,
String
credentialsID
,
String
srcBranch
,
String
jenkinsfilePath
){
pipelineJob
(
jobName
)
{
definition
{
cpsScm
{
scm
{
git
{
remote
{
name
(
jobName
)
url
(
repoUrl
)
credentials
(
credentialsID
)
}
branch
(
srcBranch
)
}
scriptPath
(
jenkinsfilePath
)
}
}
}
}
}
//ReleaseCheck rc = new ReleaseCheck().checkExistence(release,"../resources/commonConfig.yaml")
CreateJobs
job
=
new
CreateJobs
()
job
.
createFolder
(
"hello"
)
\ No newline at end of file
def
createMultibranchPipelineJob
(
String
jobName
,
String
repoUrl
,
String
credentialsID
,
String
srcBranch
,
String
jenkinsfilePath
,
List
srcBranches
){
multibranchPipelineJob
(
jobName
)
{
branchSources
{
git
{
remote
{
name
(
jobName
)
url
(
repoUrl
)
credentials
(
credentialsID
)
}
includes
(
srcBranches
)
}
scriptPath
(
jenkinsfilePath
)
}
}
}
def
createFolder
(
String
foldername
){
folder
(
foldername
)
{
displayName
(
foldername
)
description
(
foldername
+
" folder"
)
}
}
def
buildPipelineJobs
()
{
def
repoUrl
=
"https://gitlab.mynisum.com/kmohiuddin/test_shared_library_for_projects.git"
createFolder
(
"test"
)
createPipelineJob
(
"test/testjob"
,
repoUrl
,
"github-ci-creds"
,
"master"
,
"Jenkinsfile"
)
}
buildPipelineJobs
()
\ No newline at end of file
vars/main.groovy
View file @
2605659a
def
call
(
body
)
{
def
call
(
String
filepath
)
{
node
{
// step([
// $class: 'ExecuteDslScripts',
// targets: ['var/jobs.groovy'].join('\n'),
// ])
stage
(
'hello'
)
{
sh
'echo helloworld'
}
stage
(
'build dsl jobs'
)
{
jobDsl
targets:
[
'jobs.groovy'
].
join
(
'\n'
)
}
jobDsl
targets:
[
'jobs.groovy'
].
join
(
'\n'
),
removedJobAction:
'DELETE'
,
removedViewAction:
'DELETE'
,
lookupStrategy:
'SEED_JOB'
,
}
}
\ No newline at end of file
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