user8810618
user8810618

Reputation: 115

Unable to find/locate generated job by DSL script in Jenkins

I am running Jenkins dsl script to generate new jobs. In the log file, everything look fine and the Job is well created.

Created_xdbd6ajc2_le5_SEED_JOB_UNIX_xdbd6ajc2_le5

Existing items:
    GeneratedJob{name='Created_xdbd6ajc2_le5_SEED_JOB_UNIX_xdbd6ajc2_le5'}
Added views:
    GeneratedView{name='TEMPLATE_BD6'}
Started calculate disk usage of build
Finished Calculation of disk usage of build in 0 seconds
Started calculate disk usage of workspace
Finished Calculation of disk usage of workspace in 0 seconds
Finished: SUCCESS

The problem is that I can not find Created_xdbd6ajc2_le5_SEED_JOB_UNIX_xdbd6ajc2_le5 Job !! I looked in the TEMPLATE_BD6, but there is no thing.

Also, I searched in all jenkins folder, but no way ! Look, at the structure of my DSL script :

def jobParams= [
  'gitUrl': "${GIT_SSH_URL}", 
  'projectName': "${PROJECT}", 
  'composantType': "${COMPOSANT_TYPE}",
  'elements': "${ELEMENTS}"
]

def repoGitName = (jobParams.gitUrl =~ "(.*)/(.*)/(.*).git")[0][3]
def repoShortName = repoGitName
//def composantPath = "${jobParams.projectName}/${jobParams.composantType}/${repoShortName}"
def composantPath = "${repoShortName}"


def gitConfig =  ['gitUrl': jobParams.gitUrl]
def Created_Job_name = "Created_${composantPath}_SEED_JOB_${jobParams.composantType}_${repoShortName}"

listView('TEMPLATE_BD6') {

  job(Created_Job_name) {

    logRotator {
      daysToKeep(30)
    }

    scm {
      git {
        remote {
          url(gitConfig.gitUrl)
        }
        extensions {
          pruneBranches()
        }
      }
    }

    triggers{ scm('') }

    steps {
      dsl{
        text(readFileFromWorkspace("src/groovy/CPF_${jobParams.composantType}_JOBDSL.groovy"))
        ignoreExisting()
        removeAction('DISABLE')
        removeViewAction('IGNORE')
      }
    }
  }
}

EDIT I tried the solution proposed by @agabrys, but no generated items shown in the Jenkins dashboard even the console confirm the generation of these items !

Look at the picture and the result to console :

Picture

enter image description here

Console

  Existing items:
    GeneratedJob{name='Created_xdbd6ajc2_le5_SEED_JOB_UNIX_xdbd6ajc2_le5'}
Added views:
    GeneratedView{name='TEMPLATE_BD6'}
Started calculate disk usage of build
Finished Calculation of disk usage of build in 0 seconds
Started calculate disk usage of workspace
Finished Calculation of disk usage of workspace in 0 seconds
Finished: SUCCESS

Is there any configuration in Jenkins that I miss ?

Upvotes: 0

Views: 353

Answers (1)

user8810618
user8810618

Reputation: 115

Well I finally find the solution for my problem. I missed two steps :

First, I should specify the type of the created job as freestyle object !!

In other word, instead of :

job(Created_Job_name) {
  logRotator {
    daysToKeep(30)
  }

I should write :

freeStyleJob(Created_Job_name) {
  logRotator {
    daysToKeep(30)
  }

The second thing,, the name of the new job should contains the root path : In other word, If the new Job named "test" will be created in "template_bd6" which is in the folder "bd6" as an exemple. Then, the name of new job should be :

Created_Job_name = "bd6/template_bd6/test"

Upvotes: 0

Related Questions