Skip to content

Commit

Permalink
Updating job-dsl-core support to 1.34 and freshening versions of othe…
Browse files Browse the repository at this point in the history
…r libraries
  • Loading branch information
ghale committed May 17, 2015
1 parent 5bf83ec commit 11165eb
Show file tree
Hide file tree
Showing 16 changed files with 212 additions and 47 deletions.
45 changes: 24 additions & 21 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,18 @@ buildscript {
maven {
url 'http://repo.jenkins-ci.org/releases/'
}
maven {
url "https://plugins.gradle.org/m2/"
}
}

dependencies {
classpath 'org.gradle.api.plugins:gradle-nexus-plugin:0.7'
classpath 'com.jfrog.bintray.gradle:gradle-bintray-plugin:0.5'
classpath "com.gradle.publish:plugin-publish-plugin:0.9.0"
}
}

apply plugin: 'com.jfrog.bintray'
apply plugin: "com.gradle.plugin-publish"
apply plugin: 'groovy'
apply plugin: 'eclipse'
apply plugin: 'idea'
Expand Down Expand Up @@ -45,10 +48,12 @@ dependencies {
'org.apache.ivy:ivy:2.2.0'
)

compile('org.codehaus.groovy.modules.http-builder:http-builder:0.5.2') {
compile('org.codehaus.groovy.modules.http-builder:http-builder:0.6') {
exclude(module: 'groovy')
exclude(module: 'xercesImpl')
}
compile('org.jenkins-ci.plugins:job-dsl-core:1.26') {

compile('org.jenkins-ci.plugins:job-dsl-core:1.34') {
exclude(module: 'groovy-all')
}

Expand Down Expand Up @@ -87,6 +92,10 @@ task wrapper(type: Wrapper) {
gradleVersion = '1.12'
}

nexus {
sign = false
}

modifyPom {
project {
name 'gradle-jenkins-plugin'
Expand Down Expand Up @@ -118,23 +127,17 @@ modifyPom {
}
}

bintray {
user = project.hasProperty('bintrayUsername') ? project.getProperty('bintrayUsername') : ''
key = project.hasProperty('bintrayApiKey') ? project.getProperty('bintrayApiKey') : ''

configurations = ['archives']

pkg {
repo = 'gradle-plugins'
name = 'gradle-jenkins-plugin'
licenses = ['Apache-2.0']
desc = 'A Gradle plugin for programmatically managing Jenkins instances.'
websiteUrl = 'https://github.com/ghale/gradle-jenkins-plugin'
issueTrackerUrl = 'https://github.com/ghale/gradle-jenkins-plugin/issues'
vcsUrl = 'https://github.com/ghale/gradle-jenkins-plugin.git'
labels = ['jenkins', 'gradle']
publicDownloadNumbers = true
version.attributes = ['gradle-plugin': 'com.terrafolio.jenkins:com.terrafolio:gradle-jenkins-plugin']
pluginBundle {
website = 'https://github.com/ghale/gradle-jenkins-plugin'
vcsUrl = 'https://github.com/ghale/gradle-jenkins-plugin'
description = 'A Gradle plugin for programmatically managing Jenkins instances.'
tags = ['jenkins', 'gradle']

plugins {
jenkins {
id = 'com.terrafolio.jenkins'
displayName = 'Gradle Jenkins plugin'
}
}
}

Expand Down
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
version=1.2.3
version=1.3.0
group=com.terrafolio
Binary file modified gradle/wrapper/gradle-wrapper.jar
Binary file not shown.
4 changes: 2 additions & 2 deletions gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#Sun Jun 29 12:09:34 EDT 2014
#Thu Apr 02 11:30:33 EDT 2015
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=http\://services.gradle.org/distributions/gradle-1.12-all.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-1.12-bin.zip
6 changes: 3 additions & 3 deletions gradlew
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/bin/bash
#!/usr/bin/env bash

##############################################################################
##
Expand Down Expand Up @@ -61,9 +61,9 @@ while [ -h "$PRG" ] ; do
fi
done
SAVED="`pwd`"
cd "`dirname \"$PRG\"`/"
cd "`dirname \"$PRG\"`/" >&-
APP_HOME="`pwd -P`"
cd "$SAVED"
cd "$SAVED" >&-

CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar

Expand Down
Original file line number Diff line number Diff line change
@@ -1,15 +1,24 @@
package com.terrafolio.gradle.plugins.jenkins.dsl

import com.terrafolio.gradle.plugins.jenkins.jobdsl.DSLJobFactory
import com.terrafolio.gradle.plugins.jenkins.jobdsl.DefaultDSLJobFactory
import javaposse.jobdsl.dsl.*

/**
* Created by ghale on 6/2/14.
*/
class JobDSLSupport implements DSLSupport {
def JobManagement jobManagement
JobManagement jobManagement
DSLJobFactory jobFactory

JobDSLSupport(JobManagement jobManagement) {
this.jobManagement = jobManagement
this.jobFactory = new DefaultDSLJobFactory()
}

JobDSLSupport(JobManagement jobManagement, DSLJobFactory jobFactory) {
this.jobManagement = jobManagement
this.jobFactory = jobFactory
}

@Override
Expand All @@ -27,7 +36,7 @@ class JobDSLSupport implements DSLSupport {

@Override
def String evaluateDSL(String name, String type, Closure closure) {
def Job job = new Job(jobManagement, ['type': type])
def Job job = jobFactory.create(jobManagement, type)
// Load the existing xml as a template if it exists
if (jobManagement.getConfig(name) && job.templateName == null) {
job.using(name)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,27 +1,24 @@
package com.terrafolio.gradle.plugins.jenkins.dsl

import com.terrafolio.gradle.plugins.jenkins.jobdsl.DSLViewFactory
import com.terrafolio.gradle.plugins.jenkins.jobdsl.DefaultDSLViewFactory
import javaposse.jobdsl.dsl.*
import javaposse.jobdsl.dsl.views.BuildPipelineView
import javaposse.jobdsl.dsl.views.ListView
import javaposse.jobdsl.dsl.views.NestedView
import javaposse.jobdsl.dsl.views.SectionedView

/**
* Created by ghale on 6/2/14.
*/
class ViewDSLSupport implements DSLSupport {
def JobManagement jobManagement

private static final Map<ViewType, Class<? extends View>> VIEW_TYPE_MAPPING = [
(null) : ListView.class,
(ViewType.ListView) : ListView.class,
(ViewType.NestedView) : NestedView.class,
(ViewType.SectionedView) : SectionedView.class,
(ViewType.BuildPipelineView): BuildPipelineView.class,
]
JobManagement jobManagement
DSLViewFactory viewFactory

ViewDSLSupport(JobManagement jobManagement) {
this.jobManagement = jobManagement
this.viewFactory = new DefaultDSLViewFactory()
}

ViewDSLSupport(JobManagement jobManagement, DSLViewFactory viewFactory) {
this.jobManagement = jobManagement
this.viewFactory = viewFactory
}

@Override
Expand All @@ -39,8 +36,7 @@ class ViewDSLSupport implements DSLSupport {

@Override
String evaluateDSL(String name, String type, Closure closure) {
Class<? extends View> viewClass = VIEW_TYPE_MAPPING[type as ViewType]
View view = viewClass.newInstance()
View view = viewFactory.createView(jobManagement, type)
view.with(closure)
jobManagement.createOrUpdateView(name, view.xml, true)
return name
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
package com.terrafolio.gradle.plugins.jenkins.jobdsl

import javaposse.jobdsl.dsl.Job
import javaposse.jobdsl.dsl.JobManagement


interface DSLJobFactory {
Job create(JobManagement management, String type)
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
package com.terrafolio.gradle.plugins.jenkins.jobdsl

import javaposse.jobdsl.dsl.Job
import javaposse.jobdsl.dsl.jobs.*


enum DSLJobType {
Freeform(FreeStyleJob),
Maven(MavenJob),
Multijob(MultiJob),
BuildFlow(BuildFlowJob),
Workflow(WorkflowJob),
Matrix(MatrixJob)

final Class<? extends Job> jobClass

DSLJobType(Class<? extends Job> jobClass) {
this.jobClass = jobClass
}

static find(String enumName) {
values().find { it.name().toLowerCase() == enumName.toLowerCase() }
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
package com.terrafolio.gradle.plugins.jenkins.jobdsl

import javaposse.jobdsl.dsl.JobManagement
import javaposse.jobdsl.dsl.View


interface DSLViewFactory {
View createView(JobManagement management, String type)
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
package com.terrafolio.gradle.plugins.jenkins.jobdsl

import javaposse.jobdsl.dsl.View

enum DSLViewType {
ListView(javaposse.jobdsl.dsl.views.ListView),
SectionedView(javaposse.jobdsl.dsl.views.SectionedView),
NestedView(javaposse.jobdsl.dsl.views.NestedView),
DeliveryPipelineView(javaposse.jobdsl.dsl.views.DeliveryPipelineView),
BuildPipelineView(javaposse.jobdsl.dsl.views.BuildPipelineView),
BuildMonitorView(javaposse.jobdsl.dsl.views.BuildMonitorView)

final Class<? extends View> viewClass

DSLViewType(Class<? extends View> viewClass) {
this.viewClass = viewClass
}

static find(String enumName) {
values().find { it.name().toLowerCase() == enumName.toLowerCase() }
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
package com.terrafolio.gradle.plugins.jenkins.jobdsl

import javaposse.jobdsl.dsl.Job
import javaposse.jobdsl.dsl.JobManagement

class DefaultDSLJobFactory implements DSLJobFactory {
@Override
Job create(JobManagement management, String type) {
Class<? extends Job> jobClass
if (type == null) {
jobClass = DSLJobType.Freeform.jobClass
} else {
jobClass = DSLJobType.find(type).jobClass
}

return jobClass.newInstance(management)
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
package com.terrafolio.gradle.plugins.jenkins.jobdsl

import javaposse.jobdsl.dsl.JobManagement
import javaposse.jobdsl.dsl.View

class DefaultDSLViewFactory implements DSLViewFactory {
@Override
View createView(JobManagement management, String type) {
Class<? extends View> viewClass
if (type == null) {
viewClass = DSLViewType.ListView.viewClass
} else {
viewClass = DSLViewType.find(type).viewClass
}

return viewClass.newInstance(management)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,12 @@ import javaposse.jobdsl.dsl.AbstractJobManagement
import javaposse.jobdsl.dsl.ConfigFile
import javaposse.jobdsl.dsl.ConfigFileType
import javaposse.jobdsl.dsl.ConfigurationMissingException
import javaposse.jobdsl.dsl.Item
import javaposse.jobdsl.dsl.JobConfigurationNotFoundException
import javaposse.jobdsl.dsl.NameNotProvidedException
import hudson.util.VersionNumber
import javaposse.jobdsl.dsl.UserContent
import javaposse.jobdsl.dsl.helpers.ExtensibleContext

/**
* Created by ghale on 4/6/14.
Expand All @@ -17,8 +20,8 @@ class MapJobManagement extends AbstractJobManagement {
Map parameters

MapJobManagement(Map map, PrintStream out = System.out) {
super(out)
this.map = map
this.out = out
parameters = new Maps().newHashMap()
}

Expand Down Expand Up @@ -67,4 +70,57 @@ class MapJobManagement extends AbstractJobManagement {
String getConfigFileId(ConfigFileType type, String name){
return null
}

@Override
void renameJobMatching(String previousNames, String destination) throws IOException {
}

@Override
boolean createOrUpdateConfig(Item item, boolean ignoreExisting) throws NameNotProvidedException {
String jobName = item.name
String config = item.xml
return createOrUpdateConfig(jobName, config, ignoreExisting)
}

@Override
void createOrUpdateUserContent(UserContent userContent, boolean ignoreExisting) { }

@Override
void queueJob(String jobName) throws NameNotProvidedException { }

@Override
InputStream streamFileInWorkspace(String filePath) throws IOException {
return null
}

@Override
String readFileInWorkspace(String filePath) throws IOException {
return null
}

@Override
String readFileInWorkspace(String jobName, String filePath) throws IOException {
return null
}

@Override
void requirePlugin(String pluginShortName) { }

@Override
void requireMinimumCoreVersion(String version) { }

@Override
VersionNumber getJenkinsVersion() {
return null
}

@Override
Set<String> getPermissions(String authorizationMatrixPropertyClassName) {
return null
}

@Override
Node callExtension(String name, Item item, Class<? extends ExtensibleContext> contextType, Object... args) {
return null
}
}

2 comments on commit 11165eb

@kutzi
Copy link

@kutzi kutzi commented on 11165eb Jun 4, 2015

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great.
I'd like to use this, but cannot find version 1.3.0 in Jcenter where I got the previous versions from.
I couldn't find out which repository this project is deployed to. Where is it?

@kutzi
Copy link

@kutzi kutzi commented on 11165eb Jun 4, 2015

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Got it already. Sorry for the noise.
At "https://plugins.gradle.org/m2/" as you've described in the Wiki

Please sign in to comment.