GithubHelp home page GithubHelp logo

jenkins-docs / simple-java-maven-app Goto Github PK

View Code? Open in Web Editor NEW
419.0 419.0 27.4K 37 KB

For an introductory tutorial on how to use Jenkins to build a simple Java application with Maven.

Home Page: https://jenkins.io/doc/tutorials/build-a-java-app-with-maven/

Java 44.51% Shell 55.49%

simple-java-maven-app's People

Contributors

dependabot[bot] avatar gilesgas avatar markewaite avatar notmyfault avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

simple-java-maven-app's Issues

Not working: nonexistent directory

I followed the tutorial and I got this error. Does anyone know what went wrong?

Obtained Jenkinsfile from git /home/code/pathashala/jenkins/sjma
[Pipeline] node
Running on Jenkins in /var/jenkins_home/workspace/sjma
[Pipeline] {
[Pipeline] stage
[Pipeline] { (Declarative: Checkout SCM)
[Pipeline] checkout
Cloning the remote Git repository
Cloning repository /home/code/pathashala/jenkins/sjma
 > git init /var/jenkins_home/workspace/sjma # timeout=10
Fetching upstream changes from /home/code/pathashala/jenkins/sjma
 > git --version # timeout=10
 > git fetch --tags --progress /home/code/pathashala/jenkins/sjma +refs/heads/*:refs/remotes/origin/*
 > git config remote.origin.url /home/code/pathashala/jenkins/sjma # timeout=10
 > git config --add remote.origin.fetch +refs/heads/*:refs/remotes/origin/* # timeout=10
 > git config remote.origin.url /home/code/pathashala/jenkins/sjma # timeout=10
Fetching upstream changes from /home/code/pathashala/jenkins/sjma
 > git fetch --tags --progress /home/code/pathashala/jenkins/sjma +refs/heads/*:refs/remotes/origin/*
 > git rev-parse refs/remotes/origin/master^{commit} # timeout=10
 > git rev-parse refs/remotes/origin/origin/master^{commit} # timeout=10
Checking out Revision 47e6c3653478ad31521d0959077b7036adfd4d67 (refs/remotes/origin/master)
 > git config core.sparsecheckout # timeout=10
 > git checkout -f 47e6c3653478ad31521d0959077b7036adfd4d67
Commit message: "meow"
First time build. Skipping changelog.
[Pipeline] }
[Pipeline] // stage
[Pipeline] withEnv
[Pipeline] {
[Pipeline] stage
[Pipeline] { (Declarative: Agent Setup)
[Pipeline] sh
[sjma] Running shell script
+ docker pull maven:3-alpine
3-alpine: Pulling from library/maven
88286f41530e: Pulling fs layer
009f6e766a1b: Pulling fs layer
86ed68184682: Pulling fs layer
f9cdc72bb970: Pulling fs layer
7e4415124188: Pulling fs layer
f6ba1c32fdb3: Pulling fs layer
8f690e3687b2: Pulling fs layer
7e4415124188: Waiting
f6ba1c32fdb3: Waiting
8f690e3687b2: Waiting
f9cdc72bb970: Waiting
009f6e766a1b: Download complete
f9cdc72bb970: Download complete
86ed68184682: Verifying Checksum
86ed68184682: Download complete
7e4415124188: Verifying Checksum
7e4415124188: Download complete
f6ba1c32fdb3: Download complete
8f690e3687b2: Verifying Checksum
8f690e3687b2: Download complete
88286f41530e: Verifying Checksum
88286f41530e: Download complete
88286f41530e: Pull complete
009f6e766a1b: Pull complete
86ed68184682: Pull complete
f9cdc72bb970: Pull complete
7e4415124188: Pull complete
f6ba1c32fdb3: Pull complete
8f690e3687b2: Pull complete
Digest: sha256:400fb45cfcedfc492ff91319ea0a58f570172f8cf65f40b9b14931f44a6c1417
Status: Downloaded newer image for maven:3-alpine
[Pipeline] }
[Pipeline] // stage
[Pipeline] sh
[sjma] Running shell script
+ docker inspect -f . maven:3-alpine
.
[Pipeline] withDockerContainer
Jenkins does not seem to be running inside a container
$ docker run -t -d -u 0:0 -v /root/.m2:/root/.m2 -w /var/jenkins_home/workspace/sjma -v /var/jenkins_home/workspace/sjma:/var/jenkins_home/workspace/sjma:rw,z -v /var/jenkins_home/workspace/sjma@tmp:/var/jenkins_home/workspace/sjma@tmp:rw,z -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** --entrypoint cat maven:3-alpine
[Pipeline] {
[Pipeline] stage
[Pipeline] { (Build)
[Pipeline] sh
[sjma] Running shell script
sh: can't create /var/jenkins_home/workspace/sjma@tmp/durable-cd13b59e/jenkins-log.txt: nonexistent directory
sh: can't create /var/jenkins_home/workspace/sjma@tmp/durable-cd13b59e/jenkins-result.txt: nonexistent directory
[Pipeline] }
[Pipeline] // stage
[Pipeline] }
$ docker stop --time=1 5f92084ceb1bb8d412e4507dee0c2f537ebbf4895ed62e7eba59cd8b389371ac
$ docker rm -f 5f92084ceb1bb8d412e4507dee0c2f537ebbf4895ed62e7eba59cd8b389371ac
[Pipeline] // withDockerContainer
[Pipeline] }
[Pipeline] // withEnv
[Pipeline] }
[Pipeline] // node
[Pipeline] End of Pipeline
ERROR: script returned exit code -2
Finished: FAILURE

java.lang.NoSuchMethodError: No such DSL method 'triggers' found among steps

I want to create pull_request automatically in bit bucket based on build success condtion.
However after appending PR jenkinsfile code it is throwing error mention in subject line.
triggers method not found.

Please help to write Jenkinsfile DSL groovy code for how to create new PR everytime if build success .

Following is my Jenkinsfile code.

def gitUrl(){

 return "${env.GIT_URL}";

}

def gitSourcebranch(){
return env.SOURCE_BRANCH;
}

def gitTargetbranch(){
return env.TARGET_BRANCH;
}

def environment(){
return env.ENVIRONMENTS; // this is env variable create in jenkins job

}

def branch(){
return env.BRANCH;
}

def UserEmail(){
return env.git_conf_email;
}

def UserName(){
return env.git_conf_user;
}

def Gitlab_Pass(){
return env.GITLAB_PASS;
}

def ansibleVaultCredentials() {

 if (env.VAULT_PASS != null) // created in credential in secret file with id vault_secure
       return env.VAULT_PASS;
 else
      return '';

}

stage('git_checkout'){
node('dockercon2'){
checkout([$class: 'GitSCM',
branches: [[name: "${gitSourcebranch()}"]],
doGenerateSubmoduleConfigurations: false, extensions: [[$class: 'CleanBeforeCheckout'],
[$class: 'PerBuildTag'], [$class: 'WipeWorkspace']],
submoduleCfg: [],
userRemoteConfigs: [[credentialsId: 'bitbucket_glone_cred',
name: 'origin', refspec: "+refs/heads/${env.SOURCE_BRANCH}:refs/remotes/origin/${env.SOURCE_BRANCH}",
url: "${gitUrl()}"]]])
stage ('git_buildhost'){
git branch: "${gitSourcebranch()}",
credentialsId: 'bitbucket_glone_cred', url: "${gitUrl()}"
withCredentials([usernamePassword(credentialsId: 'bitbucket_glone_cred',
passwordVariable: 'bit_pass', usernameVariable: 'bit_user')]){
sh "git config credential.username ${UserName()}"
sh "git config credential.helper ${Gitlab_Pass()}"
sh "git config --global user.email ${UserEmail()}"
sh "git config --global user.name ${UserName()}"
//sh "set +x /bin/sh -c "echo ${ansibleVaultCredentials()}>vault_passwd.txt""
sh "set +x; echo ${ansibleVaultCredentials()} >> vault_passwd.txt"
sh "echo pass"
sh "cat vault_passwd.txt"
sh "ansible-vault decrypt --vault-password-file vault_passwd.txt test2.sh && sh test2.sh"
}//stage git_buildhost closer
// } // Closing paranthesis for withCredential
} // Closin paranthesis for node
}// This parenthesis for Shttps_gitlba_clone_crede

stage('PR'){
if (currentBuild.result == null || currentBuild.result == 'SUCCESS')
triggers{
bitbucketPullRequestCreatedAction()
}
scm {
git {
remote {
url("${gitUrl()}")
}
}
steps {
shell('figlet START pull request created')
}
}
}
}//first

maven repository is not reused!!!!

Jenkins version: Jenkins2.164.2
docker args: -v /var/local/.m2:/root/.m2
Downlod jar file every time.

It work.
docker run -v /var/local/.m2:/root/.m2 maven:3-alpine mvn help:evaluate -Dexpression=settings.localRepository
It does not work.
docker run -t -d -u 117:125 -v /var/local/.m2:/root/.m2 maven:3-alpine mvn help:evaluate -Dexpression=settings.localRepository

log file:
log.txt

it provides access

package com.companyname.bank;

/**

  • Hello world!

*/
public class App {
public static void main( String[] args ){
System.out.println( "Hello World!" );
}
}

java.lang.NoSuchMethodError: No such DSL method 'get' found among steps [archive, bat, b

Hi ,

I am facing this error while doing build for my pipeline job.

java.lang.NoSuchMethodError: No such DSL method 'get' found among steps [archive, bat, build, catchError, checkout, deleteDir, dir, dockerFingerprintFrom, dockerFingerprintRun, echo, emailext, emailextrecipients, envVarsForTool, error, fileExists, findBuildScans, getContext, git, input, isUnix, junit, library, libraryResource, load, lock, mail, milestone, node, parallel, powershell, properties, pwd, pwsh, readFile, readTrusted, resolveScm, retry, script, sh, sleep, stage, stash, step, svn, timeout, timestamps, tm, tool, unarchive, unstable, unstash, validateDeclarativePipeline, waitUntil, warnError, withContext, withCredentials, withDockerContainer, withDockerRegistry, withDockerServer, withEnv, withGradle, wrap, writeFile, ws] or symbols [all, allOf, always, ant, antFromApache,

Expected a step @ line 11, column 17

I was running the build with the pipeline provided in the guide and I got the following error

`Obtained Jenkinsfile from git /home/Documents/Code/jenkins/simple-java-maven-app

org.codehaus.groovy.control.MultipleCompilationErrorsException: startup failed:

WorkflowScript: 11: Expected a step @ line 11, column 17.

               sh 'mvn -B -DskipTests clean package'g`

Failure to pass unit test. Maven version issue

My pipeline failed the Unit tests due to exit code 1. I think I followed the instructions carefully, I have the latest version of Maven installed, yet my app cannot pass the unit tests because the maven-enforcer-plugin says my version 3.6.3 is not in the allowed range of 3.8.6.

My declarative pipeline code is:
pipeline { agent any stages { stage("Clean Up") { steps{ deleteDir() } } stage("Clone Repo"){ steps { sh "git clone https://github.com/jenkins-docs/simple-java-maven-app.git" } } stage("Build"){ steps { dir("simple-java-maven-app") { sh "mvn clean install" } } } stage("Test"){ steps{ dir("simple-java-maven-app") { sh "mvn test" } } } } }

Source option 6 is no longer supported. Use 7 or later

I attempted to run this in Jenkins and it returned this error. Any idea on how to fix?

[ERROR] COMPILATION ERROR : [INFO] ------------------------------------------------------------- [ERROR] Source option 6 is no longer supported. Use 7 or later. [ERROR] Target option 6 is no longer supported. Use 7 or later. [INFO] 2 errors [INFO] ------------------------------------------------------------- [INFO] ------------------------------------------------------------------------ [INFO] BUILD FAILURE [INFO] ------------------------------------------------------------------------ [INFO] Total time: 0.842 s [INFO] Finished at: 2021-06-15T12:38:35-04:00 [INFO] ------------------------------------------------------------------------ [ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.8.1:compile (default-compile) on project my-app: Compilation failure: Compilation failure: [ERROR] Source option 6 is no longer supported. Use 7 or later. [ERROR] Target option 6 is no longer supported. Use 7 or later. [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 Build step 'Invoke top-level Maven targets' marked build as failure Finished: FAILURE

java.lang.NoSuchMethodError: No such DSL method 'agent' found among steps

Hi,I learned from the Tutorials chapter "Build a Java app with Maven", I've followed the tutorials, but when I run it, I report this error.

java.lang.NoSuchMethodError:` No such DSL method 'agent' found among steps [archive, bat, build, catchError, checkout, deleteDir, dir, dockerFingerprintFrom, dockerFingerprintRun, echo, envVarsForTool, error, fileExists, getContext, git, input, isUnix, jiraComment, jiraIssueSelector, jiraSearch, junit, library, libraryResource, load, mail, milestone, node, parallel, powershell, properties, publishHTML, pwd, readFile, readTrusted, resolveScm, retry, script, sh, sleep, stage, stash, step, svn, timeout, tm, tool, unarchive, unstash, validateDeclarativePipeline, waitUntil, withContext, withCredentials, withDockerContainer, withDockerRegistry, withDockerServer, withEnv, wrap, writeFile, ws] or symbols [all, allOf, always, any, anyOf, apiToken, architecture, archiveArtifacts, artifactManager, authorizationMatrix, batchFile, bitbucket, booleanParam, branch, buildButton, buildDiscarder, caseInsensitive, caseSensitive, certificate, changelog, changeset, checkoutToSubdirectory, choice, choiceParam, clock, cloud, command, credentials, cron, crumb, defaultView, demand, disableConcurrentBuilds, disableResume, docker, dockerCert, dockerfile, downloadSettings, downstream, dumb, durabilityHint, envVars, environment, expression, file, fileParam, filePath, fingerprint, frameOptions, freeStyle, freeStyleJob, fromScm, fromSource, git, github, githubPush, headRegexFilter, headWildcardFilter, hyperlink, hyperlinkToModels, inheriting, inheritingGlobal, installSource, jdk, jdkInstaller, jgit, jgitapache, jnlp, jobName, label, lastDuration, lastFailure, lastGrantedAuthorities, lastStable, lastSuccess, legacy, legacySCM, list, local, location, logRotator, loggedInUsersCanDoAnything, masterBuild, maven, maven3Mojos, mavenErrors, mavenMojos, mavenWarnings, modernSCM, myView, node, nodeProperties, nonInheriting, nonStoredPasswordParam, none, not, overrideIndexTriggers, paneStatus, parameters, password, pattern, pipeline-model, pipelineTriggers, plainText, plugin, pollSCM, projectNamingStrategy, proxy, queueItemAuthenticator, quietPeriod, remotingCLI, run, runParam, schedule, scmRetryCount, search, security, shell, skipDefaultCheckout, skipStagesAfterUnstable, slave, sourceRegexFilter, sourceWildcardFilter, sshUserPrivateKey, stackTrace, standard, status, string, stringParam, swapSpace, text, textParam, tmpSpace, toolLocation, unsecured, upstream, usernameColonPassword, usernamePassword, viewsTabBar, weather, zfs, zip] or globals [currentBuild, docker, env, params, pipeline, scm]

Stage Logs (Deliver)

when i run the project on a docker jenkins ,a error has be found in the step of "Deliver" , error below


Pipeline] { (Deliver)
[Pipeline] sh

  • ./jenkins/scripts/deliver.sh
    /var/jenkins_home/workspace/simple-java-maven-app@tmp/durable-d387edf0/script.sh: line 1: ./jenkins/scripts/deliver.sh: Permission denied

Error: Unable to access jarfile target/my-app

image

image

`+ ./jenkins/scripts/deliver.sh
The following Maven command installs your Maven-built Java application
into the local Maven repository, which will ultimately be stored in
Jenkinss local Maven repository (and the "maven-repository" Docker data
volume).

  • mvn jar:jar install:install help:evaluate -Dexpression=project.name
    [�[1;34mINFO�[m] Scanning for projects...
    [�[1;34mINFO�[m]
    [�[1;34mINFO�[m] �[1m----------------------< �[0;36mcom.mycompany.app:my-app�[0;1m >----------------------�[m
    [�[1;34mINFO�[m] �[1mBuilding my-app 1.0-SNAPSHOT�[m
    [�[1;34mINFO�[m] �[1m--------------------------------[ jar ]---------------------------------�[m
    [�[1;34mINFO�[m]
    [�[1;34mINFO�[m] �[1m--- �[0;32mmaven-jar-plugin:3.3.0:jar�[m �[1m(default-cli)�[m @ �[36mmy-app�[0;1m ---�[m
    [�[1;34mINFO�[m]
    [�[1;34mINFO�[m] �[1m--- �[0;32mmaven-install-plugin:2.4:install�[m �[1m(default-cli)�[m @ �[36mmy-app�[0;1m ---�[m
    [�[1;34mINFO�[m] Installing /var/jenkins_home/workspace/Github Pipeline/target/my-app-1.0-SNAPSHOT.jar to /var/jenkins_home/.m2/repository/com/mycompany/app/my-app/1.0-SNAPSHOT/my-app-1.0-SNAPSHOT.jar
    [�[1;34mINFO�[m] Installing /var/jenkins_home/workspace/Github Pipeline/pom.xml to /var/jenkins_home/.m2/repository/com/mycompany/app/my-app/1.0-SNAPSHOT/my-app-1.0-SNAPSHOT.pom
    [�[1;34mINFO�[m]
    [�[1;34mINFO�[m] �[1m----------------------< �[0;36mcom.mycompany.app:my-app�[0;1m >----------------------�[m
    [�[1;34mINFO�[m] �[1mBuilding my-app 1.0-SNAPSHOT�[m
    [�[1;34mINFO�[m] �[1m--------------------------------[ jar ]---------------------------------�[m
    [�[1;34mINFO�[m]
    [�[1;34mINFO�[m] �[1m--- �[0;32mmaven-help-plugin:3.4.0:evaluate�[m �[1m(default-cli)�[m @ �[36mmy-app�[0;1m ---�[m
    [�[1;34mINFO�[m] No artifact parameter specified, using 'com.mycompany.app:my-app:jar:1.0-SNAPSHOT' as project.
    [�[1;34mINFO�[m]
    my-app
    [�[1;34mINFO�[m] �[1m------------------------------------------------------------------------�[m
    [�[1;34mINFO�[m] �[1;32mBUILD SUCCESS�[m
    [�[1;34mINFO�[m] �[1m------------------------------------------------------------------------�[m
    [�[1;34mINFO�[m] Total time: 2.177 s
    [�[1;34mINFO�[m] Finished at: 2023-12-31T16:25:52Z
    [�[1;34mINFO�[m] �[1m------------------------------------------------------------------------�[m
    �[0m�[0m+ set +x
    The following complex command extracts the value of the element
    within of your Java/Maven projects "pom.xml" file.
    ++ mvn help:evaluate -Dexpression=project.name
    ++ grep '^[^\[]'
    �[0m+ NAME='my-app
    �[0m'
  • set +x
    The following complex command behaves similarly to the previous one but
    extracts the value of the element within instead.
    ++ mvn help:evaluate -Dexpression=project.version
    ++ grep '^[^\[]'
    �[0m+ VERSION='1.0-SNAPSHOT
    �[0m'
  • set +x
    The following command runs and outputs the execution of your Java
    application (which Jenkins built using Maven) to the Jenkins UI.
  • java -jar target/my-app '�[0m-1.0-SNAPSHOT' '�[0m.jar'
    Error: Unable to access jarfile target/my-app`

Build Failure

Started by user Admin
Running as SYSTEM
Building in workspace /var/jenkins_home/workspace/maven-job
No credentials specified

git rev-parse --is-inside-work-tree # timeout=10
Fetching changes from the remote Git repository
git config remote.origin.url https://github.com/jenkins-docs/simple-java-maven-app.git # timeout=10
Fetching upstream changes from https://github.com/jenkins-docs/simple-java-maven-app.git
git --version # timeout=10
git fetch --tags --progress -- https://github.com/jenkins-docs/simple-java-maven-app.git +refs/heads/:refs/remotes/origin/
git rev-parse refs/remotes/origin/master^{commit} # timeout=10
git rev-parse refs/remotes/origin/origin/master^{commit} # timeout=10
Checking out Revision 0d85b7e (refs/remotes/origin/master)
git config core.sparsecheckout # timeout=10
git checkout -f 0d85b7e
Commit message: "Amend README.md"
git rev-list --no-walk 0d85b7e # timeout=10
Unpacking https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/3.6.0/apache-maven-3.6.0-bin.zip to /var/jenkins_home/tools/hudson.tasks.Maven_MavenInstallation/Maven-3.6.0 on Jenkins
[maven-job] $ /var/jenkins_home/tools/hudson.tasks.Maven_MavenInstallation/Maven-3.6.0/bin/mvn -B -DskipTests clean package
[INFO] Scanning for projects...
[INFO]
[INFO] ----------------------< com.mycompany.app:my-app >----------------------
[INFO] Building my-app 1.0-SNAPSHOT
[INFO] --------------------------------[ jar ]---------------------------------
[INFO]
[INFO] --- maven-clean-plugin:2.5:clean (default-clean) @ my-app ---
[INFO] Deleting /var/jenkins_home/workspace/maven-job/target
[INFO]
[INFO] --- maven-resources-plugin:2.6:resources (default-resources) @ my-app ---
[WARNING] Using platform encoding (UTF-8 actually) to copy filtered resources, i.e. build is platform dependent!
[INFO] skip non existing resourceDirectory /var/jenkins_home/workspace/maven-job/src/main/resources
[INFO]
[INFO] --- maven-compiler-plugin:3.1:compile (default-compile) @ my-app ---
[INFO] Changes detected - recompiling the module!
[WARNING] File encoding has not been set, using platform encoding UTF-8, i.e. build is platform dependent!
[INFO] Compiling 1 source file to /var/jenkins_home/workspace/maven-job/target/classes
Build step 'Invoke top-level Maven targets' marked build as failure
Finished: FAILURE

The path /root/.m2 is not shared from the host and is not known to Docker.

Obtained Jenkinsfile from git /home/Documents/Github/simple-java-maven-app
[Pipeline] Start of Pipeline
[Pipeline] node
Running on Jenkins in /var/jenkins_home/workspace/test
[Pipeline] {
[Pipeline] stage
[Pipeline] { (Declarative: Checkout SCM)
[Pipeline] checkout
Selected Git installation does not exist. Using Default
The recommended git tool is: NONE
No credentials specified

git rev-parse --resolve-git-dir /var/jenkins_home/workspace/test/.git # timeout=10
Fetching changes from the remote Git repository
git config remote.origin.url /home/Documents/Github/simple-java-maven-app # timeout=10
Fetching upstream changes from /home/Documents/Github/simple-java-maven-app
git --version # timeout=10
git --version # 'git version 2.36.2'
git fetch --tags --force --progress -- /home/Documents/Github/simple-java-maven-app +refs/heads/:refs/remotes/origin/ # timeout=10
git rev-parse refs/remotes/origin/master^{commit} # timeout=10
Checking out Revision 86be5e399595cf017991b41faf66f9b42f46c344 (refs/remotes/origin/master)
git config core.sparsecheckout # timeout=10
git checkout -f 86be5e399595cf017991b41faf66f9b42f46c344 # timeout=10
Commit message: "Add initial Jenkinsfile"
git rev-list --no-walk 86be5e399595cf017991b41faf66f9b42f46c344 # timeout=10
[Pipeline] }
[Pipeline] // stage
[Pipeline] withEnv
[Pipeline] {
[Pipeline] isUnix
[Pipeline] withEnv
[Pipeline] {
[Pipeline] sh

  • docker inspect -f . maven:3-alpine
    .
    [Pipeline] }
    [Pipeline] // withEnv
    [Pipeline] withDockerContainer
    Jenkins seems to be running inside container 82e819576101f6536611bd49f6faba27fff328bceb5da99074799e574cea4b44
    $ docker run -t -d -u 0:0 -v /root/.m2:/root/.m2 -w /var/jenkins_home/workspace/test --volumes-from 82e819576101f6536611bd49f6faba27fff328bceb5da99074799e574cea4b44 -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** maven:3-alpine cat
    [Pipeline] // withDockerContainer
    [Pipeline] }
    [Pipeline] // withEnv
    [Pipeline] }
    [Pipeline] // node
    [Pipeline] End of Pipeline
    Also: org.jenkinsci.plugins.workflow.actions.ErrorAction$ErrorId: d0b21357-c086-4903-ba7a-8880d166a9d7
    java.io.IOException: Failed to run image 'maven:3-alpine'. Error: docker: Error response from daemon: Mounts denied:
    The path /root/.m2 is not shared from the host and is not known to Docker.
    You can configure shared paths from Docker -> Preferences... -> Resources -> File Sharing.
    See https://docs.docker.com/desktop/mac for more info.
    at org.jenkinsci.plugins.docker.workflow.client.DockerClient.run(DockerClient.java:148)
    at org.jenkinsci.plugins.docker.workflow.WithContainerStep$Execution.start(WithContainerStep.java:200)
    at org.jenkinsci.plugins.workflow.cps.DSL.invokeStep(DSL.java:322)
    at org.jenkinsci.plugins.workflow.cps.DSL.invokeMethod(DSL.java:196)
    at org.jenkinsci.plugins.workflow.cps.CpsScript.invokeMethod(CpsScript.java:124)
    at org.codehaus.groovy.runtime.callsite.PogoMetaClassSite.call(PogoMetaClassSite.java:47)
    at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCall(CallSiteArray.java:47)
    at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:116)
    at com.cloudbees.groovy.cps.sandbox.DefaultInvoker.methodCall(DefaultInvoker.java:20)
    at org.jenkinsci.plugins.docker.workflow.Docker$Image.inside(Docker.groovy:140)
    at org.jenkinsci.plugins.docker.workflow.Docker.node(Docker.groovy:66)
    at org.jenkinsci.plugins.docker.workflow.Docker$Image.inside(Docker.groovy:125)
    at org.jenkinsci.plugins.docker.workflow.declarative.DockerPipelineScript.runImage(DockerPipelineScript.groovy:54)
    at org.jenkinsci.plugins.docker.workflow.declarative.AbstractDockerPipelineScript.configureRegistry(AbstractDockerPipelineScript.groovy:63)
    at org.jenkinsci.plugins.docker.workflow.declarative.AbstractDockerPipelineScript.run(AbstractDockerPipelineScript.groovy:50)
    at org.jenkinsci.plugins.pipeline.modeldefinition.agent.CheckoutScript.checkoutAndRun(CheckoutScript.groovy:61)
    at cps.transform(Native Method)
    at com.cloudbees.groovy.cps.impl.ContinuationGroup.methodCall(ContinuationGroup.java:90)
    at com.cloudbees.groovy.cps.impl.FunctionCallBlock$ContinuationImpl.dispatchOrArg(FunctionCallBlock.java:116)
    at com.cloudbees.groovy.cps.impl.FunctionCallBlock$ContinuationImpl.fixArg(FunctionCallBlock.java:85)
    at jdk.internal.reflect.GeneratedMethodAccessor77.invoke(Unknown Source)
    at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
    at java.base/java.lang.reflect.Method.invoke(Unknown Source)
    at com.cloudbees.groovy.cps.impl.ContinuationPtr$ContinuationImpl.receive(ContinuationPtr.java:72)
    at com.cloudbees.groovy.cps.impl.ClosureBlock.eval(ClosureBlock.java:46)
    at com.cloudbees.groovy.cps.Next.step(Next.java:83)
    at com.cloudbees.groovy.cps.Continuable$1.call(Continuable.java:152)
    at com.cloudbees.groovy.cps.Continuable$1.call(Continuable.java:146)
    at org.codehaus.groovy.runtime.GroovyCategorySupport$ThreadCategoryInfo.use(GroovyCategorySupport.java:136)
    at org.codehaus.groovy.runtime.GroovyCategorySupport.use(GroovyCategorySupport.java:275)
    at com.cloudbees.groovy.cps.Continuable.run0(Continuable.java:146)
    at org.jenkinsci.plugins.workflow.cps.SandboxContinuable.access$001(SandboxContinuable.java:18)
    at org.jenkinsci.plugins.workflow.cps.SandboxContinuable.run0(SandboxContinuable.java:51)
    at org.jenkinsci.plugins.workflow.cps.CpsThread.runNextChunk(CpsThread.java:187)
    at org.jenkinsci.plugins.workflow.cps.CpsThreadGroup.run(CpsThreadGroup.java:420)
    at org.jenkinsci.plugins.workflow.cps.CpsThreadGroup$2.call(CpsThreadGroup.java:330)
    at org.jenkinsci.plugins.workflow.cps.CpsThreadGroup$2.call(CpsThreadGroup.java:294)
    at org.jenkinsci.plugins.workflow.cps.CpsVmExecutorService$2.call(CpsVmExecutorService.java:67)
    at java.base/java.util.concurrent.FutureTask.run(Unknown Source)
    at hudson.remoting.SingleLaneExecutorService$1.run(SingleLaneExecutorService.java:139)
    at jenkins.util.ContextResettingExecutorService$1.run(ContextResettingExecutorService.java:28)
    at jenkins.security.ImpersonatingExecutorService$1.run(ImpersonatingExecutorService.java:68)
    at jenkins.util.ErrorLoggingExecutorService.lambda$wrap$0(ErrorLoggingExecutorService.java:51)
    at java.base/java.util.concurrent.Executors$RunnableAdapter.call(Unknown Source)
    at java.base/java.util.concurrent.FutureTask.run(Unknown Source)
    at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
    at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
    at java.base/java.lang.Thread.run(Unknown Source)
    Finished: FAILURE
    I use Docker Desktop and the file sharing contains /Users
    截屏2023-06-16 下午5 50 45

Deliver Stage build failed on Jenkins

Get this following error when trying to run the maven app on Jenkins.

+ ./jenkins/scripts/deliver.sh
The following Maven command installs your Maven-built Java application
into the local Maven repository, which will ultimately be stored in
Jenkinss local Maven repository (and the "maven-repository" Docker data
volume).
+ mvn jar:jar install:install help:evaluate -Dexpression=project.name
[�[1;34mINFO�[m] Scanning for projects...
[�[1;34mINFO�[m] 
[�[1;34mINFO�[m] �[1m----------------------< �[0;36mcom.mycompany.app:my-app�[0;1m >----------------------�[m
[�[1;34mINFO�[m] �[1mBuilding my-app 1.0-SNAPSHOT�[m
[�[1;34mINFO�[m] �[1m--------------------------------[ jar ]---------------------------------�[m
[�[1;34mINFO�[m] 
[�[1;34mINFO�[m] �[1m--- �[0;32mmaven-jar-plugin:3.3.0:jar�[m �[1m(default-cli)�[m @ �[36mmy-app�[0;1m ---�[m
[�[1;34mINFO�[m] 
[�[1;34mINFO�[m] �[1m--- �[0;32mmaven-install-plugin:2.4:install�[m �[1m(default-cli)�[m @ �[36mmy-app�[0;1m ---�[m
[�[1;34mINFO�[m] Installing /var/jenkins_home/workspace/GitHub Pipeline/target/my-app-1.0-SNAPSHOT.jar to /var/jenkins_home/.m2/repository/com/mycompany/app/my-app/1.0-SNAPSHOT/my-app-1.0-SNAPSHOT.jar
[�[1;34mINFO�[m] Installing /var/jenkins_home/workspace/GitHub Pipeline/pom.xml to /var/jenkins_home/.m2/repository/com/mycompany/app/my-app/1.0-SNAPSHOT/my-app-1.0-SNAPSHOT.pom
[�[1;34mINFO�[m] 
[�[1;34mINFO�[m] �[1m----------------------< �[0;36mcom.mycompany.app:my-app�[0;1m >----------------------�[m
[�[1;34mINFO�[m] �[1mBuilding my-app 1.0-SNAPSHOT�[m
[�[1;34mINFO�[m] �[1m--------------------------------[ jar ]---------------------------------�[m
[�[1;34mINFO�[m] 
[�[1;34mINFO�[m] �[1m--- �[0;32mmaven-help-plugin:3.4.0:evaluate�[m �[1m(default-cli)�[m @ �[36mmy-app�[0;1m ---�[m
[�[1;34mINFO�[m] No artifact parameter specified, using 'com.mycompany.app:my-app:jar:1.0-SNAPSHOT' as project.
[�[1;34mINFO�[m] 
my-app
[�[1;34mINFO�[m] �[1m------------------------------------------------------------------------�[m
[�[1;34mINFO�[m] �[1;32mBUILD SUCCESS�[m
[�[1;34mINFO�[m] �[1m------------------------------------------------------------------------�[m
[�[1;34mINFO�[m] Total time:  0.732 s
[�[1;34mINFO�[m] Finished at: 2024-04-09T16:53:28Z
[�[1;34mINFO�[m] �[1m------------------------------------------------------------------------�[m
�[0m�[0m+ set +x
The following command extracts the value of the <name/> element
within <project/> of your Java/Maven projects "pom.xml" file.
++ mvn -q -DforceStdout help:evaluate -Dexpression=project.name
�[0m+ NAME='my-app�[0m'
+ set +x
The following command behaves similarly to the previous one but
extracts the value of the <version/> element within <project/> instead.
++ mvn -q -DforceStdout help:evaluate -Dexpression=project.version
�[0m+ VERSION='1.0-SNAPSHOT�[0m'
+ set +x
The following command runs and outputs the execution of your Java
application (which Jenkins built using Maven) to the Jenkins UI.
+ java -jar 'target/my-app�[0m-1.0-SNAPSHOT�[0m.jar'
Error: Unable to access jarfile target/my-app�[0m-1.0-SNAPSHOT�[0m.jar
image

Compilation failure: Source option 5 is no longer supported. Use 6 or later. Target option 1.5 is no longer supported. Use 1.6 or later.

Hi,

I tried compiling the maven project via Sonarqube using the command:
mvn clean complie sonar:sonar -Dsonar.host.url=<mylocalhost> -Dsonar.login=<logintoken>

However, the compile failed with errors of

[ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.1:compile (default-compile) on project my-app: Compilation failure: Compilation failure: 
[ERROR] Source option 5 is no longer supported. Use 6 or later.
[ERROR] Target option 1.5 is no longer supported. Use 1.6 or later.
[ERROR] -> [Help 1]
org.apache.maven.lifecycle.LifecycleExecutionException: Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.1:compile (default-compile) on project my-app: Compilation failure

I assume something is outdated and maven doesn't support old version of it

Getting Maven version error while building the app in Jenkins

Progress (5): 587 kB | 354 kB | 327 kB | 389 kB | 99 kB

Downloaded from central: https://repo.maven.apache.org/maven2/org/apache/commons/commons-lang3/3.12.0/commons-lang3-3.12.0.jar (587 kB at 126 kB/s)
Downloaded from central: https://repo.maven.apache.org/maven2/org/apache/maven/shared/maven-dependency-tree/3.1.1/maven-dependency-tree-3.1.1.jar (99 kB at 21 kB/s)
Downloaded from central: https://repo.maven.apache.org/maven2/commons-codec/commons-codec/1.15/commons-codec-1.15.jar (354 kB at 74 kB/s)
Downloaded from central: https://repo.maven.apache.org/maven2/commons-io/commons-io/2.11.0/commons-io-2.11.0.jar (327 kB at 68 kB/s)
Downloaded from central: https://repo.maven.apache.org/maven2/org/apache-extras/beanshell/bsh/2.0b6/bsh-2.0b6.jar (389 kB at 81 kB/s)
[�[1;31mERROR�[m] Rule 0: org.apache.maven.plugins.enforcer.RequireMavenVersion failed with message:
Detected Maven Version: 3.6.3 is not in the allowed range [3.8.6,).
[�[1;34mINFO�[m] �[1m------------------------------------------------------------------------�[m
[�[1;34mINFO�[m] �[1;31mBUILD FAILURE�[m
[�[1;34mINFO�[m] �[1m------------------------------------------------------------------------�[m
[�[1;34mINFO�[m] Total time: 01:15 min
[�[1;34mINFO�[m] Finished at: 2023-02-09T19:14:22Z
[�[1;34mINFO�[m] �[1m------------------------------------------------------------------------�[m

org.opentest4j.AssertionFailedError: "message" is not "Hello World!"

Hello,

I am new to Jenkins and just started by watching a tutorial. I forked this repo and used it in Jenkins along with maven. But it keeps giving error even if output is wrong. Could you help me understand it maybe I did something wrong on my side and not able to find any articles related to this and I also tried different versions of JDK 17/14.

To be more elaborate.

  1. I installed git and maven plugins
  2. I set my global config tools with : jdk-17.0.5 , apache-maven-3.8.6 and git from my local computer
  3. I create a new maven project and added the GitHub repo URL + GitHub hook trigger options
  4. I click on build
  5. I get error message

Error is : "message" is not "Hello World!"

Stack trace: org.opentest4j.AssertionFailedError: "message" is not "Hello World!"
at org.junit.jupiter.api.AssertionUtils.fail(AssertionUtils.java:38)
at org.junit.jupiter.api.Assertions.fail(Assertions.java:135)
at com.mycompany.app.AppTest.testAppMain(AppTest.java:42)

Standard Output: Hello World!

Build failed: docker pull

Hello,

I started the tutorial and now I am at the first run of the pipeline.
When arrived at the "docker pull" command Jenkins throws the following error:

+ docker pull python:2-alpine
/var/jenkins_home/workspace/simple-python-pyinstaller-app@tmp/durable-358c4a38/script.sh: 1: /var/jenkins_home/workspace/simple-python-pyinstaller-app@tmp/durable-358c4a38/script.sh: docker: not found
script returned exit code 127

I am using Jenkins via Docker image on the Windows Docker Desktop application (WSL2). I attached the Jenkins log file.

Jenkins tutorial failing due to maven 3.8.1 and Tests not passing

Hi.

So I'm learning a bit of Jenkins and found 2 problems when using this Git project following the tutorial for Building a Java app and Maven with Jenkins.
I'm using Windows running Jenkins in Docker with Linux containers.

1st problem, it cannot Build the project because Jenkinsfile suggested by documentation or tutorial uses maven:3.8.1-adoptopenjdk-11 but enforcer complains it should be at least 3.8.6, so I had to manually change it in Jenkinsfile to maven:3.8.6-openjdk-18 for this to build.

2nd problem, it cannot pass Tests. It always says "message" is not "Hello World!".
I tried everything I barely know, saving string to variables, using compareTo(), using equals(), checking the strings with println... no matter what I tried it always returns erro and I cannot finish the tutorial. I printed AssertionError e message and it shows this trace:

-------------------------------------------------------
 T E S T S
-------------------------------------------------------

Running com.mycompany.app.AppTest
Hello World!
org.opentest4j.AssertionFailedError: expected: <Hello World!
> but was: <>
Tests run: 2, Failures: 1, Errors: 0, Skipped: 0, Time elapsed: 0.017 sec <<< FAILURE!
com.mycompany.app.AppTest.testAppMain()  Time elapsed: 0.015 sec  <<< FAILURE!
org.opentest4j.AssertionFailedError: "message" is not "Hello World!"
	at org.junit.jupiter.api.AssertionUtils.fail(AssertionUtils.java:38)
	at org.junit.jupiter.api.Assertions.fail(Assertions.java:135)
	at com.mycompany.app.AppTest.testAppMain(AppTest.java:43)

Results :

Failed tests:   com.mycompany.app.AppTest.testAppMain(): "message" is not "Hello World!"

Tests run: 2, Failures: 1, Errors: 0, Skipped: 0

[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time:  1.572 s
[INFO] Finished at: 2022-12-19T11:56:12Z
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-surefire-plugin:2.12.4:test (default-test) on project my-app: There are test failures.
[ERROR] 
[ERROR] Please refer to /var/jenkins_home/workspace/simple-java-maven-app/target/surefire-reports for the individual test results.

Jenkins test failed

I'm out of ideas. I'm very limited at Java, Jenkins and so and I cannot understand why an official tutorial does not work by default, but no documentation is provided to workaround any errors. I'm very frustrated.
I saw this project was updated 2 days ago. Was it not tested? Was it tested following the Jenkins tutorial? Using Windows?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.