calabash-android给出“没有找到密钥库”。在Jenkins下运行时

时间:2014-04-23 12:14:19

标签: android jenkins android-gradle calabash

我有一个简单的测试android项目,我可以使用“。\ gradlew calabashDebug”在我自己登录的DOS shell中测试。但是,当我在持续集成服务器上的Jenkins下运行项目时,它失败并显示“找不到密钥库”。错误 (见下面的堆栈跟踪)。

07:54:04.462 [DEBUG] [org.gradle.process.internal.DefaultExecHandle] Changing state to: STARTING
07:54:04.464 [DEBUG] [org.gradle.process.internal.DefaultExecHandle] Waiting until process started: command 'cmd'.
07:54:04.507 [INFO] [org.gradle.process.internal.ProcessParentingInitializer] An attempt to initialize for well behaving parent process finished.
07:54:04.513 [DEBUG] [org.gradle.process.internal.DefaultExecHandle] Changing state to: STARTED
07:54:04.513 [DEBUG] [org.gradle.process.internal.ExecHandleRunner] waiting until streams are handled...
07:54:04.514 [INFO] [org.gradle.process.internal.DefaultExecHandle] Successfully started process 'command 'cmd''
07:54:05.111 [QUIET] [system.out] No test server found for this combination of app and calabash version. Recreating test server.
07:54:05.111 [QUIET] [system.out] No keystores found.
07:54:05.112 [QUIET] [system.out] Please create one or run calabash-android setup to configure calabash-android to use an existing keystore.
07:54:05.117 [DEBUG] [org.gradle.process.internal.DefaultExecHandle] Changing state to: FAILED
07:54:05.118 [DEBUG] [org.gradle.process.internal.DefaultExecHandle] Process 'command 'cmd'' finished with exit value 1 (state: FAILED)
07:54:05.119 [DEBUG] [org.gradle.api.internal.tasks.execution.ExecuteAtMostOnceTaskExecuter] Finished executing task ':calabashDebug'
07:54:05.119 [LIFECYCLE] [class org.gradle.TaskExecutionLogger] :calabashDebug FAILED
07:54:05.120 [INFO] [org.gradle.execution.taskgraph.AbstractTaskPlanExecutor] :calabashDebug (Thread[main,5,main]) completed. Took 0.666 secs.
07:54:05.120 [DEBUG] [org.gradle.execution.taskgraph.AbstractTaskPlanExecutor] Task worker [Thread[main,5,main]] finished, busy: 1.014 secs, idle: 0.016 secs
07:54:05.125 [ERROR] [org.gradle.BuildExceptionReporter] 
07:54:05.127 [ERROR] [org.gradle.BuildExceptionReporter] FAILURE: Build failed with an exception.
07:54:05.127 [ERROR] [org.gradle.BuildExceptionReporter] 
07:54:05.127 [ERROR] [org.gradle.BuildExceptionReporter] * What went wrong:
07:54:05.129 [ERROR] [org.gradle.BuildExceptionReporter] Execution failed for task ':calabashDebug'.
07:54:05.129 [ERROR] [org.gradle.BuildExceptionReporter] > Process 'command 'cmd'' finished with non-zero exit value 1
07:54:05.130 [ERROR] [org.gradle.BuildExceptionReporter] 
07:54:05.131 [ERROR] [org.gradle.BuildExceptionReporter] * Exception is:
07:54:05.132 [ERROR] [org.gradle.BuildExceptionReporter] org.gradle.api.tasks.TaskExecutionException: Execution failed for task ':calabashDebug'.
07:54:05.132 [ERROR] [org.gradle.BuildExceptionReporter]    at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.executeActions(ExecuteActionsTaskExecuter.java:69)
07:54:05.132 [ERROR] [org.gradle.BuildExceptionReporter]    at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.execute(ExecuteActionsTaskExecuter.java:46)
07:54:05.133 [ERROR] [org.gradle.BuildExceptionReporter]    at org.gradle.api.internal.tasks.execution.PostExecutionAnalysisTaskExecuter.execute(PostExecutionAnalysisTaskExecuter.java:35)
07:54:05.133 [ERROR] [org.gradle.BuildExceptionReporter]    at org.gradle.api.internal.tasks.execution.SkipUpToDateTaskExecuter.execute(SkipUpToDateTaskExecuter.java:64)
07:54:05.133 [ERROR] [org.gradle.BuildExceptionReporter]    at org.gradle.api.internal.tasks.execution.ValidatingTaskExecuter.execute(ValidatingTaskExecuter.java:58)
07:54:05.134 [ERROR] [org.gradle.BuildExceptionReporter]    at org.gradle.api.internal.tasks.execution.SkipEmptySourceFilesTaskExecuter.execute(SkipEmptySourceFilesTaskExecuter.java:42)
07:54:05.134 [ERROR] [org.gradle.BuildExceptionReporter]    at org.gradle.api.internal.tasks.execution.SkipTaskWithNoActionsExecuter.execute(SkipTaskWithNoActionsExecuter.java:52)
07:54:05.134 [ERROR] [org.gradle.BuildExceptionReporter]    at org.gradle.api.internal.tasks.execution.SkipOnlyIfTaskExecuter.execute(SkipOnlyIfTaskExecuter.java:53)
07:54:05.134 [ERROR] [org.gradle.BuildExceptionReporter]    at org.gradle.api.internal.tasks.execution.ExecuteAtMostOnceTaskExecuter.execute(ExecuteAtMostOnceTaskExecuter.java:43)
07:54:05.135 [ERROR] [org.gradle.BuildExceptionReporter]    at org.gradle.api.internal.AbstractTask.executeWithoutThrowingTaskFailure(AbstractTask.java:289)
07:54:05.135 [ERROR] [org.gradle.BuildExceptionReporter]    at org.gradle.execution.taskgraph.AbstractTaskPlanExecutor$TaskExecutorWorker.executeTask(AbstractTaskPlanExecutor.java:79)
07:54:05.135 [ERROR] [org.gradle.BuildExceptionReporter]    at org.gradle.execution.taskgraph.AbstractTaskPlanExecutor$TaskExecutorWorker.processTask(AbstractTaskPlanExecutor.java:63)
07:54:05.136 [ERROR] [org.gradle.BuildExceptionReporter]    at org.gradle.execution.taskgraph.AbstractTaskPlanExecutor$TaskExecutorWorker.run(AbstractTaskPlanExecutor.java:51)
07:54:05.136 [ERROR] [org.gradle.BuildExceptionReporter]    at org.gradle.execution.taskgraph.DefaultTaskPlanExecutor$1.run(DefaultTaskPlanExecutor.java:33)
07:54:05.137 [ERROR] [org.gradle.BuildExceptionReporter]    at org.gradle.internal.Factories$1.create(Factories.java:22)
07:54:05.137 [ERROR] [org.gradle.BuildExceptionReporter]    at org.gradle.cache.internal.DefaultCacheAccess.longRunningOperation(DefaultCacheAccess.java:198)
07:54:05.137 [ERROR] [org.gradle.BuildExceptionReporter]    at org.gradle.cache.internal.DefaultCacheAccess.longRunningOperation(DefaultCacheAccess.java:266)
07:54:05.137 [ERROR] [org.gradle.BuildExceptionReporter]    at org.gradle.cache.internal.DefaultPersistentDirectoryStore.longRunningOperation(DefaultPersistentDirectoryStore.java:135)
07:54:05.138 [ERROR] [org.gradle.BuildExceptionReporter]    at org.gradle.api.internal.changedetection.state.DefaultTaskArtifactStateCacheAccess.longRunningOperation(DefaultTaskArtifactStateCacheAccess.java:95)
07:54:05.138 [ERROR] [org.gradle.BuildExceptionReporter]    at org.gradle.execution.taskgraph.DefaultTaskPlanExecutor.process(DefaultTaskPlanExecutor.java:31)
07:54:05.138 [ERROR] [org.gradle.BuildExceptionReporter]    at org.gradle.execution.taskgraph.DefaultTaskGraphExecuter.execute(DefaultTaskGraphExecuter.java:86)
07:54:05.138 [ERROR] [org.gradle.BuildExceptionReporter]    at org.gradle.execution.SelectedTaskExecutionAction.execute(SelectedTaskExecutionAction.java:29)
07:54:05.139 [ERROR] [org.gradle.BuildExceptionReporter]    at org.gradle.execution.DefaultBuildExecuter.execute(DefaultBuildExecuter.java:61)
07:54:05.139 [ERROR] [org.gradle.BuildExceptionReporter]    at org.gradle.execution.DefaultBuildExecuter.access$200(DefaultBuildExecuter.java:23)
07:54:05.139 [ERROR] [org.gradle.BuildExceptionReporter]    at org.gradle.execution.DefaultBuildExecuter$2.proceed(DefaultBuildExecuter.java:67)
07:54:05.140 [ERROR] [org.gradle.BuildExceptionReporter]    at org.gradle.execution.DryRunBuildExecutionAction.execute(DryRunBuildExecutionAction.java:32)
07:54:05.140 [ERROR] [org.gradle.BuildExceptionReporter]    at org.gradle.execution.DefaultBuildExecuter.execute(DefaultBuildExecuter.java:61)
07:54:05.140 [ERROR] [org.gradle.BuildExceptionReporter]    at org.gradle.execution.DefaultBuildExecuter.execute(DefaultBuildExecuter.java:54)
07:54:05.140 [ERROR] [org.gradle.BuildExceptionReporter]    at org.gradle.initialization.DefaultGradleLauncher.doBuildStages(DefaultGradleLauncher.java:166)
07:54:05.141 [ERROR] [org.gradle.BuildExceptionReporter]    at org.gradle.initialization.DefaultGradleLauncher.doBuild(DefaultGradleLauncher.java:113)
07:54:05.141 [ERROR] [org.gradle.BuildExceptionReporter]    at org.gradle.initialization.DefaultGradleLauncher.run(DefaultGradleLauncher.java:81)
07:54:05.141 [ERROR] [org.gradle.BuildExceptionReporter]    at org.gradle.launcher.exec.InProcessBuildActionExecuter$DefaultBuildController.run(InProcessBuildActionExecuter.java:64)
07:54:05.142 [ERROR] [org.gradle.BuildExceptionReporter]    at org.gradle.launcher.cli.ExecuteBuildAction.run(ExecuteBuildAction.java:33)
07:54:05.142 [ERROR] [org.gradle.BuildExceptionReporter]    at org.gradle.launcher.cli.ExecuteBuildAction.run(ExecuteBuildAction.java:24)
07:54:05.142 [ERROR] [org.gradle.BuildExceptionReporter]    at org.gradle.launcher.exec.InProcessBuildActionExecuter.execute(InProcessBuildActionExecuter.java:35)
07:54:05.143 [ERROR] [org.gradle.BuildExceptionReporter]    at org.gradle.launcher.exec.InProcessBuildActionExecuter.execute(InProcessBuildActionExecuter.java:26)
07:54:05.143 [ERROR] [org.gradle.BuildExceptionReporter]    at org.gradle.launcher.cli.RunBuildAction.run(RunBuildAction.java:50)
07:54:05.143 [ERROR] [org.gradle.BuildExceptionReporter]    at org.gradle.internal.Actions$RunnableActionAdapter.execute(Actions.java:171)
07:54:05.144 [ERROR] [org.gradle.BuildExceptionReporter]    at org.gradle.launcher.cli.CommandLineActionFactory$ParseAndBuildAction.execute(CommandLineActionFactory.java:201)
07:54:05.144 [ERROR] [org.gradle.BuildExceptionReporter]    at org.gradle.launcher.cli.CommandLineActionFactory$ParseAndBuildAction.execute(CommandLineActionFactory.java:174)
07:54:05.144 [ERROR] [org.gradle.BuildExceptionReporter]    at org.gradle.launcher.cli.CommandLineActionFactory$WithLogging.execute(CommandLineActionFactory.java:170)
07:54:05.144 [ERROR] [org.gradle.BuildExceptionReporter]    at org.gradle.launcher.cli.CommandLineActionFactory$WithLogging.execute(CommandLineActionFactory.java:139)
07:54:05.145 [ERROR] [org.gradle.BuildExceptionReporter]    at org.gradle.launcher.cli.ExceptionReportingAction.execute(ExceptionReportingAction.java:33)
07:54:05.145 [ERROR] [org.gradle.BuildExceptionReporter]    at org.gradle.launcher.cli.ExceptionReportingAction.execute(ExceptionReportingAction.java:22)
07:54:05.145 [ERROR] [org.gradle.BuildExceptionReporter]    at org.gradle.launcher.Main.doAction(Main.java:46)
07:54:05.145 [ERROR] [org.gradle.BuildExceptionReporter]    at org.gradle.launcher.bootstrap.EntryPoint.run(EntryPoint.java:45)
07:54:05.146 [ERROR] [org.gradle.BuildExceptionReporter]    at org.gradle.launcher.Main.main(Main.java:37)
07:54:05.146 [ERROR] [org.gradle.BuildExceptionReporter]    at org.gradle.launcher.bootstrap.ProcessBootstrap.runNoExit(ProcessBootstrap.java:50)
07:54:05.146 [ERROR] [org.gradle.BuildExceptionReporter]    at org.gradle.launcher.bootstrap.ProcessBootstrap.run(ProcessBootstrap.java:32)
07:54:05.147 [ERROR] [org.gradle.BuildExceptionReporter]    at org.gradle.launcher.GradleMain.main(GradleMain.java:23)
07:54:05.147 [ERROR] [org.gradle.BuildExceptionReporter]    at org.gradle.wrapper.BootstrapMainStarter.start(BootstrapMainStarter.java:33)
07:54:05.147 [ERROR] [org.gradle.BuildExceptionReporter]    at org.gradle.wrapper.WrapperExecutor.execute(WrapperExecutor.java:130)
07:54:05.148 [ERROR] [org.gradle.BuildExceptionReporter]    at org.gradle.wrapper.GradleWrapperMain.main(GradleWrapperMain.java:48)
07:54:05.148 [ERROR] [org.gradle.BuildExceptionReporter] Caused by: org.gradle.process.internal.ExecException: Process 'command 'cmd'' finished with non-zero exit value 1
07:54:05.148 [ERROR] [org.gradle.BuildExceptionReporter]    at org.gradle.process.internal.DefaultExecHandle$ExecResultImpl.assertNormalExitValue(DefaultExecHandle.java:361)
07:54:05.149 [ERROR] [org.gradle.BuildExceptionReporter]    at org.gradle.process.internal.DefaultExecAction.execute(DefaultExecAction.java:31)
07:54:05.149 [ERROR] [org.gradle.BuildExceptionReporter]    at org.gradle.api.tasks.Exec.exec(Exec.java:63)
07:54:05.149 [ERROR] [org.gradle.BuildExceptionReporter]    at org.gradle.internal.reflect.JavaMethod.invoke(JavaMethod.java:63)
07:54:05.149 [ERROR] [org.gradle.BuildExceptionReporter]    at org.gradle.api.internal.project.taskfactory.AnnotationProcessingTaskFactory$StandardTaskAction.doExecute(AnnotationProcessingTaskFactory.java:219)
07:54:05.150 [ERROR] [org.gradle.BuildExceptionReporter]    at org.gradle.api.internal.project.taskfactory.AnnotationProcessingTaskFactory$StandardTaskAction.execute(AnnotationProcessingTaskFactory.java:212)
07:54:05.150 [ERROR] [org.gradle.BuildExceptionReporter]    at org.gradle.api.internal.project.taskfactory.AnnotationProcessingTaskFactory$StandardTaskAction.execute(AnnotationProcessingTaskFactory.java:201)
07:54:05.150 [ERROR] [org.gradle.BuildExceptionReporter]    at org.gradle.api.internal.AbstractTask$TaskActionWrapper.execute(AbstractTask.java:533)
07:54:05.150 [ERROR] [org.gradle.BuildExceptionReporter]    at org.gradle.api.internal.AbstractTask$TaskActionWrapper.execute(AbstractTask.java:516)
07:54:05.151 [ERROR] [org.gradle.BuildExceptionReporter]    at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.executeAction(ExecuteActionsTaskExecuter.java:80)
07:54:05.151 [ERROR] [org.gradle.BuildExceptionReporter]    at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.executeActions(ExecuteActionsTaskExecuter.java:61)
07:54:05.151 [ERROR] [org.gradle.BuildExceptionReporter]    ... 52 more

问题是没有迹象表明默认情况下密钥库的位置。我已经尝试将密钥库放在JENKINS_HOME目录下的.android \ debug.keystore中。我还尝试将calabash_settings文件(以及.calabash_settings文件)与以下内容放在一起:

{"keystore_location":"C:\\Program Files (x86)\\Jenkins\\.android\\debug.keystore","keystore_password":"android","keystore_alias":"androiddebugkey"}

我发现一个问题是我在build.gradle中使用的gradle-calabash-android-plugin没有为它产生的calabash-gradle命令指定“-v”或“--verbose”。我已经创建了一个fork和一个pull请求,并更改了gradle-calabash-android-plugin项目来解决这个问题:github.com/Pedlar/gradle-calabash-android-plugin/pull/6

使用新版本的gradle-calabash-android-plugin后,我得到了有用的调试输出:

15:29:02.455 [INFO] [org.gradle.process.internal.DefaultExecHandle] Successfully started process 'command 'cmd''
15:29:03.608 [QUIET] [system.out] 2014-04-23 15:29:03 - JDK found on PATH.
15:29:03.608 [QUIET] [system.out] 2014-04-23 15:29:03 - JDK found at: C:\Program Files\Java\jdk1.8.0
15:29:03.608 [QUIET] [system.out] 2014-04-23 15:29:03 - Android SDK found at: C:\AndroidSDK\adt-bundle-windows-x86_64-20140321\adt-bundle-windows-x86_64-20140321\sdk
15:29:03.608 [QUIET] [system.out] No test server found for this combination of app and calabash version. Recreating test server.
15:29:03.608 [QUIET] [system.out] 2014-04-23 15:29:03 - "\Program Files\Java\jdk1.8.0\bin/keytool.exe" -v -printcert -J"-Dfile.encoding=utf-8" -file "C:/Windows/Temp/d20140423-5912-102klgo/META-INF/CERT.RSA"
15:29:03.608 [QUIET] [system.out] 2014-04-23 15:29:03 - MD5 fingerprint for signing cert (C:/Users/jenkins/.jenkins/jobs/Toasty/workspace/build/apk/workspace-debug-unaligned.apk): 11:FC:53:97:85:19:6C:2F:FA:AF:00:B4:DC:A1:68:1E
15:29:03.608 [QUIET] [system.out] 2014-04-23 15:29:03 - C:/Users/jenkins/.jenkins/jobs/Toasty/workspace/build/apk/workspace-debug-unaligned.apk was signed with a certificate with fingerprint 11:FC:53:97:85:19:6C:2F:FA:AF:00:B4:DC:A1:68:1E
15:29:03.608 [QUIET] [system.out] 2014-04-23 15:29:03 - Trying to read keystore from: C:/Windows/system32/config/systemprofile/.android/debug.keystore - no such file
15:29:03.608 [QUIET] [system.out] 2014-04-23 15:29:03 - Trying to read keystore from: C:/Users/jenkins/.jenkins/jobs/Toasty/workspace/debug.keystore - no such file
15:29:03.608 [QUIET] [system.out] 2014-04-23 15:29:03 - Trying to read keystore from: C:/Windows/system32/config/systemprofile/.local/share/Xamarin/Mono/ for/ Android/debug.keystore - no such file
15:29:03.608 [QUIET] [system.out] 2014-04-23 15:29:03 - Trying to read keystore from: C:/Windows/system32/config/systemprofile/AppData/Local/Xamarin/Mono for Android/debug.keystore - no such file
15:29:03.608 [QUIET] [system.out] No keystores found.

现在我不确定为什么calabash-android试图从“C:/Windows/system32/config/systemprofile/.android/debug.keystore”而不是“C:/Users/jenkins/.android”中读取密钥库/debug.keystore”。我使用服务器上名为jenkins的用户的登录凭据,将jenkins作为Windows系统服务运行。

所以我添加了一个文件C:\ Windows \ system32 \ config \ systemprofile.android \ debug.keystore。仍然得到相同的错误,这是奇怪的。

我是Windows平台开发的新手,所以它可能像愚蠢的白色空间或斜线方向问题一样微不足道,但我无法弄明白。谢谢你的帮助。

2 个答案:

答案 0 :(得分:1)

事实证明,我原来的大部分问题源于我将Jenkins安装为以本地系统帐户运行的服务(请参阅服务属性中的LogOn选项卡)。这导致Jenkins在各种系统目录中读/写内容,并可能遇到一些权限问题。

解决方案是:

  1. 删除jenkins Windows服务
  2. 在服务器上创建一个jenkins本地帐户
  3. 以jenkins用户
  4. 的身份登录为新的jenkins用户并再次安装jenkins
  5. 配置jenkins时一定要确保使用服务属性/登录/此帐户/。\ jenkins
  6. 确保在完成所有操作后重新启动服务
  7. 这是我最后忘记做的最后一步 - Doh!一旦我这样做,一切都很好!

答案 1 :(得分:0)

我们今天在Windows 10下发现了同样的Jenkins 2.9。 Gradle尝试将工件下载到\ Windows \ System32 \ config \ systemprofile.gradle \ _caches \ modules-2 \ files-2.1 \中,然后失败。

我认为这是一个詹金斯问题,而不是仅仅与葫芦有关。 Jenkins服务安装为" Local System"默认情况下。正如Farrukh Najmi发现的,这导致了这个问题。

您可以稍后重新配置Jenkins以另一个用户身份运行。 事实上,我想知道你是否应该这样做。 Jenkins as LocalSystem被认为是一个安全问题(https://jenkins-ci.org/issue/27016)。

不过,Jenkins一定不能按照之前的建议重新安装:

如何重新配置​​Jenkins以用户身份运行" Brian"

(From an Admin Terminal or Powershell)
sc.exe stop jenkins
sc.exe config "jenkins" obj= ".\Brian" password= "Brianspassword"
sc.exe start jenkins

...已完成。 (在sc.exe语法中" ="之后关注令人惊讶的空格。)

提示

首次尝试时,服务启动失败

  

错误1069"由于登录失败,服务未启动。"

原因:用户可能没有授予运行服务的权利,请参阅https://serverfault.com/questions/197881/sc-exe-create-service-password-issue 对于我们为Jenkins制作的任何新系统用户来说尤其如此。

解决方案:我最简单的解决方案是运行services.msc,右键单击GUI中的Service,选择Properties。在此处修改用户密码。 现在,作为副作用,Services.msc非常友好地向用户授予了缺失的权利。它会通过弹出对话框通知您。

另一个陷阱是密码中的特殊字符,需要在shell中进行转义。 (我会使用只有字母的密码。或者再次在services.msc的GUI中输入密码。)