Skip to content
Permalink
Browse files
Merge pull request #984 from daspilker/JENKINS-40719
new syntax for creating config files
  • Loading branch information
daspilker committed Jan 24, 2017
2 parents 877e860 + 02311ff commit 224523422c476ed23f8fbc2ce30b488767e71753
Showing 34 changed files with 807 additions and 355 deletions.
@@ -27,10 +27,18 @@ Browse the Jenkins issue tracker to see any [open issues](https://issues.jenkins

## Release Notes
* 1.58 (unreleased)
* Enhanced support for
[Config File Provider Plugin](https://wiki.jenkins-ci.org/display/JENKINS/Config+File+Provider+Plugin)
([JENKINS-33630](https://issues.jenkins-ci.org/browse/JENKINS-33630),
[JENKINS-39754](https://issues.jenkins-ci.org/browse/JENKINS-39754),
[JENKINS-40719](https://issues.jenkins-ci.org/browse/JENKINS-40719))
* Fixed a problem with the plugin's dependencies
([JENKINS-41001](https://issues.jenkins-ci.org/browse/JENKINS-41001))
* Improved error message for invalid enum values
([JENKINS-41270](https://issues.jenkins-ci.org/browse/JENKINS-41270))
* The syntax for creating config files is changing, see [Migration](Migration#migrating-to-158)
* Most classes and related methods for creating config files are deprecated, see
[Migration](Migration#migrating-to-158)
* 1.57 (January 15 2017)
* Updated optional
[Config File Provider Plugin](https://wiki.jenkins-ci.org/display/JENKINS/Config+File+Provider+Plugin) dependency to
@@ -124,14 +124,19 @@ When the [Config File Provider Plugin](https://wiki.jenkins-ci.org/display/JENKI
installed, the DSL can be used to create configuration files.

```groovy
customConfigFile(String name, Closure configFileClosure = null) // since 1.30
configFiles(Closure configFilesClosure = null) // since 1.58
mavenSettingsConfigFile(String name, Closure configFileClosure = null) // since 1.30
customConfigFile(String name, Closure configFileClosure = null) // deprecated
mavenSettingsConfigFile(String name, Closure configFileClosure = null) // deprecated
```

These methods behaves like the [job](#job) methods and will return a config file object.
The `configFiles` method can be used to create any kind of config file that is supported by the
[[Automatically Generated DSL]]. Use the embedded API viewer to browse available methods.

See the [API Viewer](https://jenkinsci.github.io/job-dsl-plugin/) page for details about config file options.
The other methods behaves like the [job](#job) methods and will return a config file object, but these methods are
[[deprecated|Deprecation-Policy]] and will be removed.
See the [API Viewer](https://jenkinsci.github.io/job-dsl-plugin/) page for details about these methods.

Config files will be created before jobs to ensure that the file exists before it is referenced.

@@ -1,3 +1,174 @@
## Migrating to 1.58

### Config Files

The syntax for creating config files is changing to allow new features. The methods `customConfigFile`,
`mavenSettingsConfigFile`, `globalMavenSettingsConfigFile` and `managedScriptConfigFile` are
[[deprecated|Deprecation-Policy]] and will be removed.

Finding config files by name is also [[deprecated|Deprecation-Policy]] and will be removed. Names must not be unique so
lookup by name can yield multiple results. Use the unique config ID instead.

DSL prior to 1.58
```groovy
customConfigFile('ACME Settings') {
comment('Settings for ACME tools')
content(readFileFromWorkspace('acme/settings.json'))
}
mavenSettingsConfigFile('Company Settings') {
comment('Company Maven Settings')
content(readFileFromWorkspace('maven/settings.xml'))
replaceAll()
serverCredentials('company-A', 'company-A-maven-repository-credentials')
serverCredentials('company-B', 'company-B-maven-repository-credentials')
}
globalMavenSettingsConfigFile('Company Settings') {
comment('Company Maven Settings')
content(readFileFromWorkspace('maven/settings.xml'))
replaceAll()
serverCredentials('company-A', 'company-A-maven-repository-credentials')
serverCredentials('company-B', 'company-B-maven-repository-credentials')
}
managedScriptConfigFile('Example') {
comment('My script')
content('echo Hello $1 and $2')
arguments('NAME_1', 'NAME_2')
}
mavenJob('example-1') {
providedSettings('Company Settings')
providedGlobalSettings('Company Settings')
}
job('example-2') {
wrappers {
configFiles {
file('ACME Settings') {
variable('CONFIG_FILE')
}
mavenSettings('Company Settings') {
targetLocation('settings.xml')
}
globalMavenSettings('Company Settings') {
targetLocation('global-settings.xml')
}
}
}
steps {
managedScript('Example') {
arguments('foo', 'bar')
}
maven {
providedSettings('Company Settings')
providedGlobalSettings('Company Settings')
}
}
}
```

DSL since 1.58
```groovy
configFiles {
customConfig
id('acme-settings')
name('ACME Settings') {
comment('Settings for ACME tools')
content(readFileFromWorkspace('acme/settings.json'))
}
mavenSettingsConfig
id('company-settings')
name('Company Settings')
comment('Company Maven Settings')
content(readFileFromWorkspace('maven/settings.xml'))
isReplaceAll(true)
serverCredentialMappings {
serverCredentialMapping {
serverId('company-A')
credentialsId('company-A-maven-repository-credentials')
}
}
serverCredentialMappings {
serverCredentialMapping {
serverId('company-B')
credentialsId('company-B-maven-repository-credentials')
}
}
}
globalMavenSettingsConfig {
id('global-company-settings')
name('Company Settings') {
comment('Company Maven Settings')
content(readFileFromWorkspace('maven/settings.xml'))
isReplaceAll()
serverCredentialMappings {
serverCredentialMapping {
serverId('company-A')
credentialsId('company-A-maven-repository-credentials')
}
}
serverCredentialMappings {
serverCredentialMapping {
serverId('company-B')
credentialsId('company-B-maven-repository-credentials')
}
}
}
scriptConfig {
id('example')
name('Example')
comment('My script')
content('echo Hello $1 and $2')
args {
arg {
name('NAME_1')
}
arg {
name('NAME_2')
}
}
}
}
mavenJob('example-1') {
providedSettings('company-settings')
providedGlobalSettings('global-company-settings')
}
job('example-2') {
wrappers {
configFiles {
file('acme-settings') {
variable('CONFIG_FILE')
}
mavenSettings('company-settings') {
targetLocation('settings.xml')
}
globalMavenSettings('global-company-settings') {
targetLocation('global-settings.xml')
}
}
}
steps {
managedScript('example') {
arguments('foo', 'bar')
}
maven {
providedSettings('company-settings')
providedGlobalSettings('global-company-settings')
}
}
}
```

The classes `javaposse.jobdsl.dsl.Config`, `javaposse.jobdsl.dsl.ConfigFile`,
`javaposse.jobdsl.dsl.MavenSettingsConfigFile`, `javaposse.jobdsl.dsl.ParametrizedConfigFile` and
`javaposse.jobdsl.plugin.ConfigFileProviderHelper` as well as the methods `createOrUpdateConfigFile` and
`getConfigFileId` in `javaposse.jobdsl.dsl.JobManagement` and it's implementing classes are
[[deprecated|Deprecation-Policy]] and will be removed.

## Migrating to 1.57

### Rbenv
@@ -12,6 +12,7 @@ _.extend(App.Dsl.prototype, {
context.simpleClassName = tokens[tokens.length - 1];

context.methods.forEach(function(method) {
method.signatures = _.reject(method.signatures, function(signature){ return !window.App.config.embedded && signature.embeddedOnly; });
method.signatures.forEach(function (signature) {
// maintain compatibility with older data
if (signature.plugin) {
@@ -49,6 +50,7 @@ _.extend(App.Dsl.prototype, {
})
.value();
});
context.methods = _.reject(context.methods, function(method){ return method.signatures.length == 0; });
},

getContext: function(contextClass) {

0 comments on commit 2245234

Please sign in to comment.