added jobdsl jobs

parent 4263eddf
......@@ -4,7 +4,7 @@ git:
env: dit1
promoteTo: eqa1
enabled: false
release.2020.10:
release.2020.10:
env: dit3
promoteTo: eqa3
enabled: false
......
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
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
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
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment