Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Build simple clojure webproject with leiningen and jenkins

I have a simple web project based on clojure, that just contains some markdown files in the resources folder. Previously I ran it with

cd my-project
lein ring server

and then I viewed the running project in the browser at http://localhost:port.

Now I wanted to integrate this process with jenkins so I

  • created a clojure project locally (in eclipse)
  • added leiningen support to my jenkins (add path to leiningen-standalone.jar in config)
  • added the build step 'build project using leiningen' in the jenkins job config
  • use jenkins to checkout from SCM and build the project

But then, Jenkins always complains about

> java -client -XX:+TieredCompilation
> -Xbootclasspath/a:/home/.lein/self-installs/clojure-1.8.0.jar 
> -Dfile.encoding=UTF-8 
> -Dmaven.wagon.http.ssl.easy=false 
> -Dleiningen.original.pwd=/var/lib/jenkins/jobs/my-project/workspace
> -cp /home/.lein/self-installs/clojure-1.8.0.jar clojure.main -m leiningen.core.main install 
> 
> Error: Could not find or load main class clojure.main
> Build step 'Build project using leiningen' marked build as failure

I assumed, jenkins is missing the clojure.jar and it's not installing it to the .m2 repository, so I added it manually to

/var/lib/jenkins/.m2/repository/org/clojure/clojure/1.8.0/clojure-1.8.0.jar

But that doesn't change anything for the build.

How to tell jenkins where to find the clojure.main? Any hints, what I am missing?

like image 356
ulrich Avatar asked Jan 19 '17 09:01

ulrich


2 Answers

tl;dr - check permissions

When you setup leiningen+plugin for Jenkins make sure that the service account that jenkins is running under is the owner and has permissions to the leiningen-standalone.jar

In my case I installed leiningen at /var/lib/jenkins/.lein which was the default for the jenkins install and changed owner to jenkins:jenkins

like image 117
Scott Avatar answered Nov 06 '22 03:11

Scott


Have you added clojure as a dependency in your project.clj?

:dependencies [[org.clojure/clojure "1.8.0"]]
like image 43
Alex Miller Avatar answered Nov 06 '22 04:11

Alex Miller