Hello Fábio,
Could you have installed a JRE instead of installing a JDK on your build
agent?
Can you please:
- Add the following instruction in your Jenkinsfile just before the
invocation sh "mvn..." (1):
- sh "which java"
- sh "which javac"
- Re run the pipeline
- Share the Jenkinsfile you use?
- share the build logs with us
Note that if "which javac" fails then your problem is that you have
installed a JRE when Maven requires a JDK.
- A solution is to install a jdk on CentOS "sudo yum install
java-1.8.0-openjdk-devel". See http://openjdk.java.net/install/
- An alternative is to install a JDK through Jenkins Tool Installer
Cyrille
(1) sample
pipeline {
agent any
stages {
stage ("Build") {
steps {
git "https://github.com/cyrille-leclerc/my-jar.git"
withMaven(maven:"maven-3.5.2") {
writeFile file: '.archive-jenkins-maven-event-spy-logs', text:
''
sh "which java"
sh "which javac"
sh "mvn clean deploy"
}
}
}
}
}
On Wednesday, February 14, 2018 at 7:42:01 PM UTC+1, Fábio Cabrita wrote:
>
> Hello,
>
> Its my first time using jenkins and I am still learning how it works, so
> if you see some unnecessary info dont be mad lol.
>
> I am using a CentOS 7, and I have installed JAVA(openjdk version
> "1.8.0_161") and MAVEN(Apache Maven 3.5.2).
>
> Now, I have imported the repo from this tutorial(
> https://www.youtube.com/watch?v=s73nhwYBtzE), to my new account at
> bitbucket.
>
> As plugins I have install several that to me was looking necessary for
> that tutorial: https://pastebin.com/zU19r8PV
>
> Then I created a new Pipeline at Jenkins with the right login for my
> bitbucket repo git.
>
> Then tried to 'Build Now' but it fails at Compile Stage:
>
> [INFO] --- maven-compiler-plugin:3.1:compile (default-compile) @
> jenkins-example ---
> [INFO] Changes detected - recompiling the module!
> [INFO] Compiling 1 source file to
> /var/lib/jenkins/workspace/jenkins-example/target/classes
> [INFO] -------------------------------------------------------------
> *[ERROR] COMPILATION ERROR :*
> [INFO] -------------------------------------------------------------
> *[ERROR] No compiler is provided in this environment. Perhaps you are
> running on a JRE rather than a JDK?*
> [INFO] 1 error
> [INFO] 1 error
> [INFO] -------------------------------------------------------------
> [INFO]
> ------------------------------------------------------------------------
> [INFO] BUILD FAILURE
> [INFO]
> ------------------------------------------------------------------------
> [INFO] Total time: 0.767 s
> [INFO] Finished at: 2018-02-13T16:45:06Z
> [INFO] Final Memory: 9M/102M
> [INFO]
> ------------------------------------------------------------------------
> [INFO] [jenkins-event-spy] Generated
> /var/lib/jenkins/workspace/jenkins-example@tmp/withMavenabb6bf9d/maven-spy-20180213-164505-820349381958923572055.log
> *[ERROR] Failed to execute goal
> org.apache.maven.plugins:maven-compiler-plugin:3.1:compile
> (default-compile) on project jenkins-example: Compilation failure*
> *[ERROR] No compiler is provided in this environment. Perhaps you are
> running on a JRE rather than a JDK?*
> *[ERROR] -> [Help 1]*
> *[ERROR] *
> *[ERROR] To see the full stack trace of the errors, re-run Maven with the
> -e switch.*
> *[ERROR] Re-run Maven using the -X switch to enable full debug logging.*
> *[ERROR] *
> *[ERROR] For more information about the errors and possible solutions,
> please read the following articles:*
> *[ERROR] [Help 1]
> http://cwiki.apache.org/confluence/display/MAVEN/MojoFailureException
> <http://cwiki.apache.org/confluence/display/MAVEN/MojoFailureException>*
>
> Now a side of having JAVA and MAVIN installed in CentOS, I was trying to
> use JDK from java.sun.com(with an account from Oracle) and Maven from
> Apache through Jenkins webservice in Global Tool Configuration but still I
> have the same output errors.
>
> Also at Maven I add the name of maven_3_5_2 and change it in jenkinsfile
> in that repo that I have cloned to my account.
>
> This is a noob question, but I need some guidence here =|
>
> Thanks!
>
--
You received this message because you are subscribed to the Google Groups
"Jenkins Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/jenkinsci-users/5ddae108-8576-46dc-9e3d-b19eda55de38%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.