RE: Creating a FreeStyleProject outside JUnit?

2013-01-18 Thread jserup
My first  approach was to simply:

public class JenkinsApiTest {
  public void test()  {
ItemGroup itemGroup = new MyItemGroup();
FreeStyleProject p = new FreeStyleProject(itemGroup, "n0");
p.getConfigFile().asString();
  }

this results in the AbstractProject constructor being called:

protected AbstractProject(ItemGroup parent, String name) {
super(parent,name);

if(!Jenkins.getInstance().getNodes().isEmpty()) {
// if a new job is configured with Hudson that already has slave
nodes
// make it roamable by default
canRoam = true;
}
}

which throws a NullPointerException most likely because a Jenkins instance
has not been created. I seems that creating types from hudson.model.*
package requires a running Jenkins instance and hence the whole
HudsonTestCase setup is necessary



--
View this message in context: 
http://jenkins.361315.n4.nabble.com/Creating-a-FreeStyleProject-outside-JUnit-tp4651594p4651931.html
Sent from the Jenkins users mailing list archive at Nabble.com.


Re: Creating a FreeStyleProject outside JUnit?

2013-01-16 Thread jserup
Ok makes sense but is possible to create eg. a FreeStyleProject /outside/ a
Junit TestRunner. Seems a bit strange that this can only be done through a
TestRunner.



--
View this message in context: 
http://jenkins.361315.n4.nabble.com/Creating-a-FreeStyleProject-outside-JUnit-tp4651594p4651665.html
Sent from the Jenkins users mailing list archive at Nabble.com.


Creating a FreeStyleProject outside JUnit?

2013-01-15 Thread jserup
I am creating a FreeStyleProject using this test class: 

import org.jvnet.hudson.test.HudsonTestCase; 
import org.apache.commons.io.FileUtils; 
import hudson.model.*; 
import hudson.tasks.Shell; 

public class AppTest extends HudsonTestCase 
{ 
public void test1() throws Exception { 
FreeStyleProject project = createFreeStyleProject(); 
project.getBuildersList().add(new Shell("echo hello")); 

FreeStyleBuild build = project.scheduleBuild2(0).get(); 
System.out.println(build.getDisplayName()+" completed"); 

// TODO: change this to use HtmlUnit 
String s = FileUtils.readFileToString(build.getLogFile()); 
assertTrue(s.contains("+ echo hello")); 
} 
} 

From: 

https://wiki.jenkins-ci.org/display/JENKINS/Unit+Test

But is it only possible to create a FreeStyleProject (and other project
types) from a JUnit test? If I do: 

public class Main { 
public void runit() throws Exception{ 
AppTest at = new AppTest(); 
at.test1(); 
} 

public static void main(String[] args) throws Exception { 
Main main = new Main(); 
main.runit(); 
} 
} 


I get: 

Exception in thread "main" java.lang.NullPointerException 
at
org.jvnet.hudson.test.HudsonTestCase.createUniqueProjectName(HudsonTestCase.java:688)
 
at
org.jvnet.hudson.test.HudsonTestCase.createFreeStyleProject(HudsonTestCase.java:652)
 
at com.build.jenkins.AppTest.test1(AppTest.java:10) 
at com.build.jenkins.Main.runit(MMain.java:7) 
at com.build.jenkins.Main.main(MMain.java:13) 

I have also looked at: hudson.triggers.TriggerStartTest which use: 

@Rule public JenkinsRule j = new JenkinsRule(); 

instead. But moving that outside a Junit test class gives an error similar
to the above. 


Its seems that its only possible to create objects from hudson.model.*
inside JUnit test or am I missing an alternative approach? 

Here are the dependencies that I use: 


org.jenkins-ci.main
jenkins-core
1.498



org.jenkins-ci.main
jenkins-test-harness
1.498



org.jenkins-ci.main
1.498
jenkins-war
war


org.jenkins-ci.main
1.498
jenkins-war
war-for-test


available from : 

http://repo.jenkins-ci.org/webapp/browserepo.html?6



--
View this message in context: 
http://jenkins.361315.n4.nabble.com/Creating-a-FreeStyleProject-outside-JUnit-tp4651594.html
Sent from the Jenkins users mailing list archive at Nabble.com.


Re: Developing a Jenkins plugin?

2012-11-21 Thread jserup
Thanks!



--
View this message in context: 
http://jenkins.361315.n4.nabble.com/Developing-a-Jenkins-plugin-tp4646762p4646790.html
Sent from the Jenkins users mailing list archive at Nabble.com.


Developing a Jenkins plugin?

2012-11-20 Thread jserup
When you create a maven job on Jenkins you can enable "Build whenever a
snapshot dependency has been build".

I would like to create the same functionality for a gradle job/free style
job as a plugin for jenkins and am therefore reading this guide:

https://wiki.jenkins-ci.org/display/JENKINS/Plugin+tutorial

But is it possible to access the source for the jenkins maven job options
(especially the one mentioned above) to get some inspiration on how they
have done it?



--
View this message in context: 
http://jenkins.361315.n4.nabble.com/Developing-a-Jenkins-plugin-tp4646762.html
Sent from the Jenkins users mailing list archive at Nabble.com.


Build whenever a SNAPSHOT dependency is built - Gradle/Jenkins integration?

2012-10-04 Thread jserup
This is a cross post from:

http://forums.gradle.org/gradle/topics/build_whenever_a_snapshot_dependency_is_built_gradle_jenkins_integration?rfm=1

When building a maven project on Jenkins its possible to specify the build
trigger:

Build whenever a SNAPSHOT dependency is built

This works out of the box.

I have a Gradle project that I build with gradle (v. 1.2) on Jenkins (ver.
1.483) using Artifactory as my binary storage. But cannot find the same
option. Are there any Gradle plugins for Jenkins that enables this
functionality or is it possible to configure it globally in a .gradle file?



--
View this message in context: 
http://jenkins.361315.n4.nabble.com/Build-whenever-a-SNAPSHOT-dependency-is-built-Gradle-Jenkins-integration-tp4642172.html
Sent from the Jenkins users mailing list archive at Nabble.com.


.m2 repository on slave1 not visible when building with slave2?

2012-10-02 Thread jserup
We have a bunch of gradle jobs that are build with the maven plugin meaning
that the build artifacts gets deployed to the local .m2 repo. On Jenkins we
have added 4 slaves each with its own .m2 repo.

We have two projects A and B where B depends on A. If A gets build on slave2
and B gets build on slave1 B fails since it cannot see A in its local .m2
repo (we are still in the process of setting up deployment to a repository
manager but need our builds to work until then).

Is it possible for build jobs to consider/read across .m2 repos on all
slaves but only deploy to its own .m2?

Alternatively setting up a global .m2 for all slaves to use. Should be
rather trivial but to my understanding also more risky - concurrent access
issues?



--
View this message in context: 
http://jenkins.361315.n4.nabble.com/m2-repository-on-slave1-not-visible-when-building-with-slave2-tp4642005.html
Sent from the Jenkins users mailing list archive at Nabble.com.


Specify different JDK for maven sub modules?

2012-10-01 Thread jserup
In Jenkins ver. 1.483 its possible to specify a JDK to use when building eg.
a maven project. Now I need to specify this on the sub-module layer like:

parent
  -> child.a (jdk5)
  -> child.b (jdk6)

Is this currently supported in jenkins or are there any plans to support
this? I have tried to specify this using the maven-compiler-plugin but the
build does not fail when I specify JDK6 in the job configuration and then
for a sub project specify JDk5.



--
View this message in context: 
http://jenkins.361315.n4.nabble.com/Specify-different-JDK-for-maven-sub-modules-tp4641975.html
Sent from the Jenkins users mailing list archive at Nabble.com.


Re: Inheriting JDK installations from master on slave?

2012-09-25 Thread jserup
my bad after closer inspection it was actually meant to fail with jdk5 :-)



--
View this message in context: 
http://jenkins.361315.n4.nabble.com/Inheriting-JDK-installations-from-master-on-slave-tp4641292p4641307.html
Sent from the Jenkins users mailing list archive at Nabble.com.


Inheriting JDK installations from master on slave?

2012-09-25 Thread jserup
I have installed Jenkins ver. 1.482 on an ubuntu machine and added a slave on
another Ubuntu machine. Under "Jenkins ->Configuration" I have added jdk5,
jdk6 and jdk7 and checked install from java.sun.com.

Some of the jobs run on the slave needs to be build with jdk5 so in the
relevant job configuration I specify jdk5 (which I have specified in
theglobal configuration).

But on my slave I only have jdk7 and jdk6 in /usr/lib/jvm. Is the jdk
specification on the master passed to the slave or will it only work if I
also installed jdk5 on my slave?

Currently the jdk5 job fails if I specify jdk5 in the job configuration -
even though it build fine locally with jdk5.




--
View this message in context: 
http://jenkins.361315.n4.nabble.com/Inheriting-JDK-installations-from-master-on-slave-tp4641292.html
Sent from the Jenkins users mailing list archive at Nabble.com.


Configuration slicer/groovy script for common Gradle tasks?

2012-09-21 Thread jserup
Anyone found a plugin - or have written a script - for Jenkins that makes it
possible to specify a list of common gradle tasks (eg. clean --refresh
dependencies test install) for a set of jenkins jobs?

I have installed the Configuration Slicer plugin and it has this for maven
projects but not for gradle :-(



--
View this message in context: 
http://jenkins.361315.n4.nabble.com/Configuration-slicer-groovy-script-for-common-Gradle-tasks-tp4640976.html
Sent from the Jenkins users mailing list archive at Nabble.com.


ERROR: Problem fetching from origin ... : fatal: Authentication failed

2012-09-18 Thread jserup
I am running Jenkins ver. 1.466.1 on an Ubuntu machine with "Jenkins GIT
plugin 1.1.23".

Some of the jobs fetches changes from a git repository on another ubuntu
machine (running git version 1.7.10) using the following format under
"Source code management" in the job configuration:

https://jenkins:pass@host/.../test.git

These jobs run hourly even though there has been no src change.  But now and
then (approx once every 10th build) jenkins gives this error and the build
fails:



Fetching changes from 1 remote Git repository
Fetching upstream changes from https://jenkins:pass@host/git
ERROR: Problem fetching from origin / origin - could be unavailable.
Continuing anyway
hudson.plugins.git.GitException: Command "git fetch -t
https://jenkins:pass@host/git +refs/heads/*:refs/remotes/origin/*"
returned status code 128:
stdout: 
stderr: fatal: Authentication failed

at hudson.plugins.git.GitAPI.launchCommandIn(GitAPI.java:863)
at hudson.plugins.git.GitAPI.launchCommand(GitAPI.java:824)
at hudson.plugins.git.GitAPI.fetch(GitAPI.java:198)
at hudson.plugins.git.GitAPI.fetch(GitAPI.java:1071)
at hudson.plugins.git.GitSCM.fetchFrom(GitSCM.java:810)
at hudson.plugins.git.GitSCM.access$100(GitSCM.java:76)
at hudson.plugins.git.GitSCM$2.invoke(GitSCM.java:1076)
at hudson.plugins.git.GitSCM$2.invoke(GitSCM.java:1044)
at hudson.FilePath$FileCallableWrapper.call(FilePath.java:2193)
at hudson.remoting.UserRequest.perform(UserRequest.java:118)
at hudson.remoting.UserRequest.perform(UserRequest.java:48)
at hudson.remoting.Request$2.run(Request.java:326)
at
hudson.remoting.InterceptingExecutorService$1.call(InterceptingExecutorService.java:72)
at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:334)
at java.util.concurrent.FutureTask.run(FutureTask.java:166)
at
java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1110)
at
java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:603)
at java.lang.Thread.run(Thread.java:722)
ERROR: Could not fetch from any repository
FATAL: Could not fetch from any repository
hudson.plugins.git.GitException: Could not fetch from any repository
at hudson.plugins.git.GitSCM$2.invoke(GitSCM.java:1083)
at hudson.plugins.git.GitSCM$2.invoke(GitSCM.java:1044)
at hudson.FilePath$FileCallableWrapper.call(FilePath.java:2193)
at hudson.remoting.UserRequest.perform(UserRequest.java:118)
at hudson.remoting.UserRequest.perform(UserRequest.java:48)
at hudson.remoting.Request$2.run(Request.java:326)
at
hudson.remoting.InterceptingExecutorService$1.call(InterceptingExecutorService.java:72)
at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:334)
at java.util.concurrent.FutureTask.run(FutureTask.java:166)
at
java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1110)
at
java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:603)
at java.lang.Thread.run(Thread.java:722)


I am considering to follow the advice given below but would like to hear if
anyone has experienced the same strange behaviour?

https://issues.jenkins-ci.org/browse/JENKINS-11576

(Gotchas)
https://wiki.jenkins-ci.org/display/JENKINS/Git+Plugin



--
View this message in context: 
http://jenkins.361315.n4.nabble.com/ERROR-Problem-fetching-from-origin-fatal-Authentication-failed-tp4640475.html
Sent from the Jenkins users mailing list archive at Nabble.com.