Comments (4)
I'm hitting the same issue. Using the jenkins { dsl { job { flow,
jenkins {
dsl {
...
// Ensure folder is for subsequent job building.
folder("${folderName}") {
description('foobar.')
}
job("${folderName}/${jobName}") {
The folder will be created but I can't reference the folder in a job name. This fails for both the updateJenkinsItems and dumpJenkinsItems. This flow does work in job-dsl proper. I'm using the 1.3.2 gradle jenkins plugin ( which uses job-dsl-core 1.42).
Philbeier, if your dsl {} config is inside a jobs {} configuration, the folder construct won't work but if you move the dsl to the top-level, i.e., jenkins { dsl { folder() }} that approach should work but unfortunately, you can't reference the folder in a job definition. :-(
- see https://github.com/ghale/gradle-jenkins-plugin/wiki#configuration for the config hiearchy...
from gradle-jenkins-plugin.
JUST figured out some sauce to workaround the job-dsl folder issue using serviceOverrides. serviceoverrides is undoc'ed but search in "issues" for details.
jenkins {
...
// NOTE: This will only work 1 folder deep. TODO: Follow pattern for 2+ deep version.
def defaultServiceOverrides = { folder, jobName ->
return {
create = ["uri": "/jenkins/job/${folder}/createItem", params: [ name: "${jobName}" ] ]
update = ["uri": "/jenkins/job/${folder}/job/${jobName}/config.xml"]
get = ["uri": "/jenkins/job/${folder}/job/${jobName}/config.xml"]
delete = ["uri": "/jenkins/job/${folder}/job/${jobName}/doDelete"]
}
}
...
dsl {
// Ensure folder is present for subsequent job building.
// NOTE: job-dsl folder command does not work in
// jobs { jobName { dsl { folder <- doesn't work }}} construct
// so need to leave it separate top-level dsl config here.
//
folder("${folderName}") {
description('EDIF sample data extraction effort.')
}
}
...
jobs {
"${jobName}" {
dsl fileTree('.').include("${jobName}.groovy")
// place job in appropriate folder. gradle jenkins plugin doesn't support
// job-dsl job command with folder in the name like foo/bar.
// Use serviceOverrides as a workaround.
serviceOverrides defaultServiceOverrides(folderName, jobName)
}
}
...
I have variables folderName and jobName defined elsewhere but hopefully you get the gist. The dsl file creates a job at the root level of Jenkins. You can see this when you run dumpJenkinsItem. But, the serviceOverrides effectively moves the job into the folder $folderName.
So, folders aren't first class citizens in the gradle jenkins plugin :-( but there are workarounds. NOTE: This approach works for the XML config flow as well. Place the serviceOverrides clause after the definition configuration.
You can always just use gradle and job-dsl directly ( see https://github.com/sheehan/job-dsl-gradle-example ) BUT not having to deal with seed jobs plus the tasks added in this plugin still make it worth it for me. :-) . Nice job, Gary!
from gradle-jenkins-plugin.
Last remark and I hope this issue is resolved well since it basically means that job names must be unique across all jenkins jobs since you can't use folders to provide a namespace to isolate job names. :-(
from gradle-jenkins-plugin.
Well in fact you can create jobs with the same name in different folders with the following approach:
jobs {
"${folderName}-${jobName}" {
...
serviceOverrides defaultServiceOverrides(folderName, jobName)
}
}
if you run dumpJenkinsItems, you will get folderName-jobName.xml, so unique names for each config file.
But when you run updateJenkinsItems the override kicks in and it correctly create/update folderName/jobName, assuming multiple jobs with jobName will be created in different folders.
from gradle-jenkins-plugin.
Related Issues (20)
- Plugin should not push one-line xml so it plays nice with Jenkins Job Config History
- deleteJenkinsItem fails if Job web page is open on Jenkins server
- Crash when using JobDSL's archiveArtifacts() HOT 2
- Advanced XML manipulation
- Releases 1.3.x not available at central repo HOT 3
- Getting error on linux
- update to job-dsl-plugin 1.44+ (or provide hacking instructions?) HOT 2
- Jenkins 2.0 and Gradle 2.13 "No valid crumb was included in the request" HOT 9
- workflows and good practices HOT 1
- Plugin pushes configuration files marked as "incompatible" with most recent Jenkins version
- Update job-dsl-core HOT 2
- Should support creating a Pipeline Job HOT 1
- 1.3.3 Upgrade Exception: No signature of method: ..getPluginVersion()
- Is this plugin still maintained? HOT 7
- 1.3.4 is not available on the Gradle repo HOT 3
- Logging Output Hard to Read
- Support of jenkins plugins
- Is there a way to shutdown Jenkins server cleanly?
- Please use Action<...> instead of Closure for Kotlin DSL interoperability
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from gradle-jenkins-plugin.