не удалось запустить команды maven на удаленном сервере Centos 7 - PullRequest
0 голосов
/ 31 октября 2018

Дженкинс может получить репо внутри /var/lib/jenkins/workspace/demo_2 но Maven не может запустить mvn clean verify -Dwebdriver.driver=chrome и выдайте следующую ошибку.

Started by user Aditi
Building on master in workspace /var/lib/jenkins/workspace/demo_2
[WS-CLEANUP] Deleting project workspace...
[WS-CLEANUP] Done
[ssh-agent] Looking for ssh-agent implementation...
[ssh-agent]   Exec ssh-agent (binary ssh-agent on a remote machine)
$ ssh-agent
SSH_AUTH_SOCK=/tmp/ssh-xGCSGsv8AXIe/agent.18464
SSH_AGENT_PID=18467
[ssh-agent] Started.
Running ssh-add (command line suppressed)
Identity added: /var/lib/jenkins/workspace/demo_2@tmp/private_key_6332013581283531930.key (/var/lib/jenkins/workspace/demo_2@tmp/private_key_6332013581283531930.key)
[ssh-agent] Using credentials Aditi
Cloning the remote Git repository
Cloning repository https://aditi_store@bitbucket.org/storetech/riverbed.git
 > git init /var/lib/jenkins/workspace/demo_2 # timeout=10
Fetching upstream changes from https://aditi_store@bitbucket.org/storetech/riverbed.git
 > git --version # timeout=10
using GIT_ASKPASS to set credentials aditi's bitbucket credentials
 > git fetch --tags --progress https://aditi_store@bitbucket.org/storetech/riverbed.git +refs/heads/*:refs/remotes/origin/*
 > git config remote.origin.url https://aditi_store@bitbucket.org/storetech/riverbed.git # timeout=10
 > git config --add remote.origin.fetch +refs/heads/*:refs/remotes/origin/* # timeout=10
 > git config remote.origin.url https://aditi_store@bitbucket.org/storetech/riverbed.git # timeout=10
Fetching upstream changes from https://aditi_store@bitbucket.org/storetech/riverbed.git
using GIT_ASKPASS to set credentials aditi's bitbucket credentials
 > git fetch --tags --progress https://aditi_store@bitbucket.org/storetech/riverbed.git +refs/heads/*:refs/remotes/origin/*
 > git rev-parse origin/pemissionsTests^{commit} # timeout=10
Checking out Revision 46dd6e8872bfa4f89fc8b988279f4ac336521e18 (origin/pemissionsTests)
 > git config core.sparsecheckout # timeout=10
 > git checkout -f 46dd6e8872bfa4f89fc8b988279f4ac336521e18
Commit message: "permission test initial commit"
 > git rev-list --no-walk 46dd6e8872bfa4f89fc8b988279f4ac336521e18 # timeout=10
[demo_2] $ mvn clean verify -Dwebdriver.driver=chrome
FATAL: command execution failed
java.io.IOException: error=2, No such file or directory
    at java.lang.UNIXProcess.forkAndExec(Native Method)
    at java.lang.UNIXProcess.<init>(UNIXProcess.java:247)
    at java.lang.ProcessImpl.start(ProcessImpl.java:134)
    at java.lang.ProcessBuilder.start(ProcessBuilder.java:1029)
Caused: java.io.IOException: Cannot run program "mvn" (in directory "/var/lib/jenkins/workspace/demo_2"): error=2, No such file or directory
    at java.lang.ProcessBuilder.start(ProcessBuilder.java:1048)
    at hudson.Proc$LocalProc.<init>(Proc.java:249)
    at hudson.Proc$LocalProc.<init>(Proc.java:218)
    at hudson.Launcher$LocalLauncher.launch(Launcher.java:935)
    at hudson.Launcher$ProcStarter.start(Launcher.java:454)
    at hudson.Launcher$ProcStarter.join(Launcher.java:465)
    at hudson.tasks.Maven.perform(Maven.java:368)
    at hudson.tasks.BuildStepMonitor$1.perform(BuildStepMonitor.java:20)
    at hudson.model.AbstractBuild$AbstractBuildExecution.perform(AbstractBuild.java:744)
    at hudson.model.Build$BuildExecution.build(Build.java:206)
    at hudson.model.Build$BuildExecution.doRun(Build.java:163)
    at hudson.model.AbstractBuild$AbstractBuildExecution.run(AbstractBuild.java:504)
    at hudson.model.Run.execute(Run.java:1815)
    at hudson.model.FreeStyleBuild.run(FreeStyleBuild.java:43)
    at hudson.model.ResourceController.execute(ResourceController.java:97)
    at hudson.model.Executor.run(Executor.java:429)
Build step 'Invoke top-level Maven targets' marked build as failure
$ ssh-agent -k
unset SSH_AUTH_SOCK;
unset SSH_AGENT_PID;
echo Agent pid 18467 killed;
[ssh-agent] Stopped.
Finished: FAILURE

Если я войду через putty на этот сервер Centos 7, перейдите в папку demo_2 и запустите mvn clean verify -Dwebdriver.driver=chrome -e с переключателем -e, это выдает ошибку ниже

[ERROR] Failed to execute goal org.apache.maven.plugins:maven-resources-plugin:2.6:testResources (default-testResources) on project demo-automation-tests: Cannot create resource output directory: /var/lib/jenkins/workspace/demo_2/target/test-classes -> [Help 1]
org.apache.maven.lifecycle.LifecycleExecutionException: Failed to execute goal org.apache.maven.plugins:maven-resources-plugin:2.6:testResources (default-testResources) on project demo-automation-tests: Cannot create resource output directory: /var/lib/jenkins/workspace/demo_2/target/test-classes
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:213)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:154)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:146)
    at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject (LifecycleModuleBuilder.java:117)
    at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject (LifecycleModuleBuilder.java:81)
    at org.apache.maven.lifecycle.internal.builder.singlethreaded.SingleThreadedBuilder.build (SingleThreadedBuilder.java:56)
    at org.apache.maven.lifecycle.internal.LifecycleStarter.execute (LifecycleStarter.java:128)
    at org.apache.maven.DefaultMaven.doExecute (DefaultMaven.java:305)
    at org.apache.maven.DefaultMaven.doExecute (DefaultMaven.java:192)
    at org.apache.maven.DefaultMaven.execute (DefaultMaven.java:105)
    at org.apache.maven.cli.MavenCli.execute (MavenCli.java:954)
    at org.apache.maven.cli.MavenCli.doMain (MavenCli.java:288)
    at org.apache.maven.cli.MavenCli.main (MavenCli.java:192)
    at sun.reflect.NativeMethodAccessorImpl.invoke0 (Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke (NativeMethodAccessorImpl.java:62)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke (DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke (Method.java:498)
    at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced (Launcher.java:289)
    at org.codehaus.plexus.classworlds.launcher.Launcher.launch (Launcher.java:229)
    at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode (Launcher.java:415)
    at org.codehaus.plexus.classworlds.launcher.Launcher.main (Launcher.java:356)
Caused by: org.apache.maven.plugin.MojoExecutionException: Cannot create resource output directory: /var/lib/jenkins/workspace/demo_2/target/test-classes
    at org.apache.maven.plugin.resources.ResourcesMojo.execute (ResourcesMojo.java:307)
    at org.apache.maven.plugin.resources.TestResourcesMojo.execute (TestResourcesMojo.java:73)
    at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo (DefaultBuildPluginManager.java:137)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:208)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:154)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:146)
    at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject (LifecycleModuleBuilder.java:117)
    at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject (LifecycleModuleBuilder.java:81)
    at org.apache.maven.lifecycle.internal.builder.singlethreaded.SingleThreadedBuilder.build (SingleThreadedBuilder.java:56)
    at org.apache.maven.lifecycle.internal.LifecycleStarter.execute (LifecycleStarter.java:128)
    at org.apache.maven.DefaultMaven.doExecute (DefaultMaven.java:305)
    at org.apache.maven.DefaultMaven.doExecute (DefaultMaven.java:192)
    at org.apache.maven.DefaultMaven.execute (DefaultMaven.java:105)
    at org.apache.maven.cli.MavenCli.execute (MavenCli.java:954)
    at org.apache.maven.cli.MavenCli.doMain (MavenCli.java:288)
    at org.apache.maven.cli.MavenCli.main (MavenCli.java:192)
    at sun.reflect.NativeMethodAccessorImpl.invoke0 (Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke (NativeMethodAccessorImpl.java:62)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke (DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke (Method.java:498)
    at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced (Launcher.java:289)
    at org.codehaus.plexus.classworlds.launcher.Launcher.launch (Launcher.java:229)
    at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode (Launcher.java:415)
    at org.codehaus.plexus.classworlds.launcher.Launcher.main (Launcher.java:356)
Caused by: org.apache.maven.shared.filtering.MavenFilteringException: Cannot create resource output directory: /var/lib/jenkins/workspace/demo_2/target/test-classes
    at org.apache.maven.shared.filtering.DefaultMavenResourcesFiltering.filterResources (DefaultMavenResourcesFiltering.java:215)
    at org.apache.maven.plugin.resources.ResourcesMojo.execute (ResourcesMojo.java:301)
    at org.apache.maven.plugin.resources.TestResourcesMojo.execute (TestResourcesMojo.java:73)
    at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo (DefaultBuildPluginManager.java:137)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:208)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:154)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:146)
    at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject (LifecycleModuleBuilder.java:117)
    at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject (LifecycleModuleBuilder.java:81)
    at org.apache.maven.lifecycle.internal.builder.singlethreaded.SingleThreadedBuilder.build (SingleThreadedBuilder.java:56)
    at org.apache.maven.lifecycle.internal.LifecycleStarter.execute (LifecycleStarter.java:128)
    at org.apache.maven.DefaultMaven.doExecute (DefaultMaven.java:305)
    at org.apache.maven.DefaultMaven.doExecute (DefaultMaven.java:192)
    at org.apache.maven.DefaultMaven.execute (DefaultMaven.java:105)
    at org.apache.maven.cli.MavenCli.execute (MavenCli.java:954)
    at org.apache.maven.cli.MavenCli.doMain (MavenCli.java:288)
    at org.apache.maven.cli.MavenCli.main (MavenCli.java:192)
    at sun.reflect.NativeMethodAccessorImpl.invoke0 (Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke (NativeMethodAccessorImpl.java:62)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke (DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke (Method.java:498)
    at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced (Launcher.java:289)
    at org.codehaus.plexus.classworlds.launcher.Launcher.launch (Launcher.java:229)
    at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode (Launcher.java:415)
    at org.codehaus.plexus.classworlds.launcher.Launcher.main (Launcher.java:356)
[ERROR]
[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/MojoExecutionException

Полагаю, у maven нет прав на создание каталога, но это те же учетные данные, которые я использую для Jenkins и использую для входа через putty

Как работает git?

Что мне здесь не хватает? Эта неспособность maven создавать каталог происходит только внутри /var/lib/jenkins, она прекрасно работает внутри

/home/aditi.a/workspace, если я скопирую то же рабочее пространство.

.profile file

export M3_HOME=/home/aditi.a/apache-maven-3.5.4/bin
export PATH=$PATH:$M3_HOME

export JMETER_HOME=/home/aditi.a/apache-jmeter-5.0/bin
export PATH=$PATH:$JMETER_HOME

export JAVA_HOME=/usr/java/jdk1.8.0_192-amd64
export PATH=$PATH:$HOME/bin:$JAVA_HOME/bin

export DISPLAY=:99

1 Ответ

0 голосов
/ 31 октября 2018

Попробуйте mvn в том же каталоге, где вы пытаетесь запустить тесты, и он не работает.

Если в нем указано mvn command not found, то maven, который вы установили и имеете в своем файле .profile, подходит только для вашего дома / пользователя, т. Е. home/aditi.a только

Попробуйте скопировать содержимое файла .profile в эти места также

  1. /home/aditi.a/.bashrc,
  2. /root/.profile и
  3. /root/.bashrc
Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...