Search code examples
jenkinsjenkins-pluginsjenkins-job-dsl

Jenkins job DSL list view does not create a job


The below job DSL creates a new job, list view, and should add the new job to the view, but it's not adding the job to the view- the job runs without any errors though:

multibranchPipelineJob("myjob") {
  branchSources {
    branchSource {
      source {
        bitbucket {
          credentialsId('bitbucket-login-user-pass')
          repoOwner('myteam')
          repository('myrepo')
          autoRegisterHook(true)
        }
      }
    }
  }
}
//listview is created, but job not added to it
listView('mylistview') {
  jobs {
    name('myjob')
  }
}

I suspect I'm doing something dumb. Everything is created but when I click on the tab for the "mylistview", "myjob" is not there.


Solution

  • I feel dumb now, but this behavior is a little odd. Looks like you need to add columns to the view or you won't see anything!

    How to put jobs inside a folder in jenkins?

    listView('MyJobsList') {
      jobs {
         map.each{
           name((it.key).trim())
         }
      }
       columns{
            status()
            weather()
            name()
            lastSuccess()
            lastFailure()
            lastDuration()
            buildButton()
        }
    }