Skip to content

Modernize this plugin #31

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 22 commits into from
Dec 11, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
b49dd9e
Get this to compile, build, and pass the tests.
tomaswolf Jun 29, 2015
7ad9ae3
Switch to Java 6.
tomaswolf Jun 29, 2015
83a1bb8
JENKINS-22666: Fix regexp
tomaswolf Jun 25, 2015
652c6d2
JENKINS-24993: restrict looking for jobs to the jobs directory.
tomaswolf Jun 25, 2015
dec7428
JENKINS-18401: Don't fail on files outside $JENKINS_HOME
tomaswolf Jun 27, 2015
283a3d5
Cleanup: avoid warnings about missing serialization ID.
tomaswolf Jun 29, 2015
8660de3
JENKINS-22540: include built-in jenkins-plugins.
tomaswolf Jun 29, 2015
25db7ec
Fix dynamic load problem: avoid need to restart Jenkins.
tomaswolf Jun 29, 2015
28d4aee
JENKINS-15218, JENKINS 16378, JENKINS-24881: job renaming
tomaswolf Jun 29, 2015
36756ca
Cleanup: grammar, and make commit messages wrap at 72 characters.
tomaswolf Jun 29, 2015
d7fcc81
Cleanup: get a warning-free build & workspace.
tomaswolf Jun 30, 2015
e2ad192
JENKINS-16348: trim & validate repository URL obtained from user.
tomaswolf Jun 30, 2015
25f8c79
Cleanup: add a few comments.
tomaswolf Jul 1, 2015
a54d147
Test: job name starting with dash
tomaswolf Jul 4, 2015
91897e8
JENKINS-16441: make it work for job names starting with '-'
tomaswolf Jul 1, 2015
f32a1ed
Test: job name with blanks
tomaswolf Jul 4, 2015
cb2f319
JENKINS-24686: fix behavior for job names with blanks
tomaswolf Jul 4, 2015
e41072e
Cleanup: attempt to fix race condition.
tomaswolf Jul 6, 2015
78a71d8
Cleanup: make Path.contains() more precise.
tomaswolf Jul 6, 2015
712c127
Cleanup: minor fixes.
tomaswolf Jul 7, 2015
cb6ad5e
Cleanup: whitespace & formatting.
tomaswolf Jul 7, 2015
046227a
Cleanup: remove a pointless override in a test class.
tomaswolf Jul 7, 2015
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ work*/
.idea/

# eclipse project file
.factorypath
.settings
.classpath
.project
Expand Down
157 changes: 119 additions & 38 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,23 @@
<parent>
<groupId>org.jenkins-ci.plugins</groupId>
<artifactId>plugin</artifactId>
<version>1.409</version>
<relativePath>../pom.xml</relativePath>
<version>1.565.3</version>
</parent>

<artifactId>scm-sync-configuration</artifactId>
<name>SCM Sync Configuration Plugin</name>
<version>0.0.8.1-SNAPSHOT</version>
<version>0.0.9-SNAPSHOT</version>
<packaging>hpi</packaging>
<url>http://wiki.jenkins-ci.org/display/JENKINS/SCM+Sync+configuration+plugin</url>
<description>SCM Sync Configuration Jenkins plugin is aimed at 2 main features : First, keep sync'ed your config.xml (and other ressources) jenkins files with a SCM repository (backup), Secondly, track changes (and author) made on every file with commit messages.</description>

<licenses>
<license>
<name>MIT</name>
<url>http://www.opensource.org/licenses/mit-license.php</url>
</license>
</licenses>

<developers>
<developer>
<id>fcamblor</id>
Expand All @@ -29,11 +35,9 @@

<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>

<powermock.version>1.4.8</powermock.version>
</properties>

<!-- get every artifact through maven.glassfish.org, which proxies all the artifacts that we need -->
<repositories>
<repository>
<id>repo.jenkins-ci.org</id>
Expand All @@ -51,10 +55,67 @@
<build>
<pluginManagement>
<plugins>
<plugin>
<plugin>
<groupId>org.eclipse.m2e</groupId>
<artifactId>lifecycle-mapping</artifactId>
<version>1.0.0</version>
<configuration>
<lifecycleMappingMetadata>
<pluginExecutions>
<pluginExecution>
<pluginExecutionFilter>
<groupId>org.codehaus.gmaven</groupId>
<artifactId>gmaven-plugin</artifactId>
<versionRange>[1.5,)</versionRange>
<goals>
<goal>generateTestStubs</goal>
<goal>testCompile</goal>
</goals>
</pluginExecutionFilter>
<action>
<execute>
<runOnIncremental>false</runOnIncremental>
</execute >
</action>
</pluginExecution>
<pluginExecution>
<pluginExecutionFilter>
<groupId>org.codehaus.plexus</groupId>
<artifactId>plexus-maven-plugin</artifactId>
<versionRange>[1.3.8,)</versionRange>
<goals>
<goal>merge-descriptors</goal>
</goals>
</pluginExecutionFilter>
<action>
<execute>
<runOnIncremental>false</runOnIncremental>
</execute >
</action>
</pluginExecution>
<pluginExecution>
<pluginExecutionFilter>
<groupId>com.google.code.maven-replacer-plugin</groupId>
<artifactId>maven-replacer-plugin</artifactId>
<versionRange>[1.3.2,)</versionRange>
<goals>
<goal>replace</goal>
</goals>
</pluginExecutionFilter>
<action>
<execute>
<runOnIncremental>false</runOnIncremental>
</execute >
</action>
</pluginExecution>
</pluginExecutions>
</lifecycleMappingMetadata>
</configuration>
</plugin>
<plugin>
<artifactId>maven-release-plugin</artifactId>
<!-- To have pushChanges parameter available -->
<version>2.5</version>
<version>2.5.1</version>
<configuration>
<!-- Git scm specific behaviour -->
<localCheckout>true</localCheckout>
Expand All @@ -71,9 +132,19 @@
</plugins>
</pluginManagement>
<plugins>
<plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.1</version><!--$NO-MVN-MAN-VER$-->
<configuration>
<source>1.6</source>
<target>1.6</target>
</configuration>
</plugin>
<plugin>
<groupId>org.codehaus.plexus</groupId>
<artifactId>plexus-maven-plugin</artifactId>
<version>1.3.8</version>
<executions>
<execution>
<id>merge</id>
Expand All @@ -89,6 +160,37 @@
</execution>
</executions>
</plugin>
<plugin>
<!-- Fix the injected tests source generated by maven-hpi-plugin. -->
<groupId>com.google.code.maven-replacer-plugin</groupId>
<artifactId>maven-replacer-plugin</artifactId>
<version>1.3.2</version>
<executions>
<execution>
<phase>process-test-sources</phase>
<goals>
<goal>replace</goal>
</goals>
</execution>
</executions>
<configuration>
<includes>
<include>target/inject-tests/*.java</include>
<include>target/generated-test-sources/injected/*.java</include>
</includes>
<regex>false</regex>
<replacements>
<replacement>
<token>Map parameters = new HashMap();</token>
<value>Map&lt;String,String&gt; parameters = new HashMap&lt;String,String&gt;();</value>
</replacement>
<replacement>
<token>new org.jvnet.hudson.test.PluginAutomaticTestBuilder()</token>
<value>org.jvnet.hudson.test.PluginAutomaticTestBuilder</value>
</replacement>
</replacements>
</configuration>
</plugin>
</plugins>
</build>

Expand All @@ -97,7 +199,7 @@
<dependency>
<groupId>org.jenkins-ci.main</groupId>
<artifactId>maven-plugin</artifactId>
<version>${project.parent.version}</version>
<version>2.3</version>
<exclusions>
<exclusion>
<!-- Conflicts with org.jenkins-ci.plugins:subversion dependency -->
Expand All @@ -122,27 +224,25 @@
</dependencyManagement>

<dependencies>
<dependency>
<groupId>org.sonatype.sisu</groupId>
<artifactId>sisu-inject-plexus</artifactId>
<version>2.6.0</version>
</dependency>

<dependency>
<groupId>org.apache.maven.scm</groupId>
<artifactId>maven-scm-manager-plexus</artifactId>
<version>1.9.1</version>
<!--
<!-- Prevent pulling in old stuff. We use the sisu plexus from above. -->
<exclusions>
<exclusion>
<groupId>org.codehaus.plexus</groupId>
<artifactId>plexus-container-default</artifactId>
</exclusion>
</exclusions>
-->
</dependency>
<!--
<dependency>
<groupId>org.sonatype.sisu</groupId>
<artifactId>sisu-inject-plexus</artifactId>
<version>1.4.3.1</version>
</dependency>
-->


<dependency>
<groupId>org.jenkins-ci.plugins</groupId>
<artifactId>subversion</artifactId>
Expand Down Expand Up @@ -175,26 +275,7 @@
<artifactId>powermock-api-mockito</artifactId>
<version>${powermock.version}</version>
<scope>test</scope>
</dependency>
<!-- Fixing easymock to 3.0 because transitive dependency grabbed by powermock only allow to mock interfaces -->
<dependency>
<groupId>org.mockito</groupId>
<artifactId>mockito-core</artifactId>
<version>1.8.5</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.8.1</version>
<type>jar</type>
<scope>test</scope>
</dependency>
<dependency>
<groupId>com.google.guava</groupId>
<artifactId>guava</artifactId>
<version>12.0.1</version>
</dependency>
</dependencies>

<scm>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,22 +1,31 @@
package hudson.plugins.scm_sync_configuration;

import hudson.model.Hudson;

import java.io.File;

import jenkins.model.Jenkins;

public class JenkinsFilesHelper {

public static String buildPathRelativeToHudsonRoot(File file){
File hudsonRoot = Hudson.getInstance().getRootDir();
if(!file.getAbsolutePath().startsWith(hudsonRoot.getAbsolutePath())){
throw new IllegalArgumentException("Err ! File ["+file.getAbsolutePath()+"] seems not to reside in ["+hudsonRoot.getAbsolutePath()+"] !");
}
String truncatedPath = file.getAbsolutePath().substring(hudsonRoot.getAbsolutePath().length()+1); // "+1" because we don't need ending file separator
return truncatedPath.replaceAll("\\\\", "/");
}
public static String buildPathRelativeToHudsonRoot(File file) {
File jenkinsRoot = Jenkins.getInstance().getRootDir();
String jenkinsRootPath = jenkinsRoot.getAbsolutePath();
String fileAbsolutePath = file.getAbsolutePath();
if (fileAbsolutePath.equals(jenkinsRootPath)) {
// Hmmm. Should never occur.
throw new IllegalArgumentException("Cannot build relative path to $JENKINS_HOME for $JENKINS_HOME itself; would be empty.");
}
if (!jenkinsRootPath.endsWith(File.separator)) {
jenkinsRootPath += File.separator;
}
if (!fileAbsolutePath.startsWith(jenkinsRootPath)) {
// Oops, the file is not relative to $JENKINS_HOME
return null;
}
String truncatedPath = fileAbsolutePath.substring(jenkinsRootPath.length());
return truncatedPath.replace(File.separatorChar, '/');
}

public static File buildFileFromPathRelativeToHudsonRoot(String pathRelativeToHudsonRoot){
File hudsonRoot = Hudson.getInstance().getRootDir();
return new File(hudsonRoot.getAbsolutePath()+File.separator+pathRelativeToHudsonRoot);
public static File buildFileFromPathRelativeToHudsonRoot(String pathRelativeToJenkinsRoot){
return new File(Jenkins.getInstance().getRootDir(), pathRelativeToJenkinsRoot);
}
}
Loading