代码之家  ›  专栏  ›  技术社区  ›  Schadenfreude

无法通过Jenkins文件运行“fastlane”命令

  •  1
  • Schadenfreude  · 技术社区  · 6 年前

    我写了一封信 Gradle task 执行 fastlane supply 通过命令行执行命令。任务如下所示:

    task uploadToPlayStore(type: Exec) {
        group = "upload"
        commandLine "fastlane", "supply",
                "--aab", "$project.rootDir/app/build/outputs/bundle/upload/${archiveFile}.aab",
                "--mapping", "$project.rootDir/app/build/outputs/mapping/upload/mapping.txt",
                "--skip_upload_apk", "true",
                "--skip_upload_metadata", "true",
                "--skip_upload_images", "true",
                "--skip_upload_screenshots", "true",
                "--track", "internal",
                "--package_name", "$appPackage",
                "--json_key", "~/Documents/key.json"
    }
    

    这个任务在我运行它的Jenkins slave上的终端上成功运行,并通过Android Studio作为 梯度任务 通过它的终端 ./gradlew uploadToPlayStore . 起初,在我做了一个无效缓存并重新启动Android Studio之前,它并没有通过Android Studio的终端正常运行。它给出了以下错误:

    org.gradle.api.tasks.TaskExecutionException: Execution failed for task ':app:uploadToPlayStore'.
    ...............
    Caused by: org.gradle.process.internal.ExecException: A problem occurred starting process 'command 'fastlane''
    ...............
    Caused by: net.rubygrapefruit.platform.NativeException: Could not start 'fastlane'
    ...............
    Caused by: java.io.IOException: Cannot run program "fastlane" (in directory "/Users/..."): error=2, No such file or directory
    ...............
    Caused by: java.io.IOException: error=2, No such file or directory
    

    目前,当我尝试运行Jenkins Multibranch管道时,我遇到了与之前在Android Studio中遇到的相同的错误。根据我目前的发现,詹金斯似乎找不到 fastlane 出于某种原因,我命令你。我试着设置一个 Environment Variable 对于构建节点,我正在构建我的项目,但仍然会得到相同的错误。

    stage Jenkinsfile Fastlane 任务:

    stage('Upload To Google Play Store') {
                steps {
                    script {
                        if (env.BRANCH_NAME.startsWith("release")) {
                            sh './gradlew uploadToPlayStore --stacktrace'
                        } else {
                            echo 'Skipping stage since we\'re not on a release branch...'
                        }
                    }
                }
            }
    

    当以以下方式运行命令时: "~/.rvm/rubies/ruby-2.4.2/bin/fastlane", "supply", ... --debug 标记激活我得到以下堆栈跟踪:

    22:54:51.135 [DEBUG] [org.gradle.process.internal.DefaultExecHandle] Changing state to: STARTING
    22:54:51.137 [DEBUG] [org.gradle.process.internal.DefaultExecHandle] Waiting until process started: command '/Users/bild_nachine/.rvm/rubies/ruby-2.4.2/bin/fastlane'.
    22:54:51.147 [DEBUG] [org.gradle.process.internal.DefaultExecHandle] Changing state to: STARTED
    22:54:51.147 [INFO] [org.gradle.process.internal.DefaultExecHandle] Successfully started process 'command '/Users/bild_nachine/.rvm/rubies/ruby-2.4.2/bin/fastlane''
    22:54:51.148 [DEBUG] [org.gradle.process.internal.ExecHandleRunner] waiting until streams are handled...
    22:54:51.150 [ERROR] [system.err] env: ruby_executable_hooks: No such file or directory
    22:54:51.152 [DEBUG] [org.gradle.process.internal.DefaultExecHandle] Changing state to: FAILED
    22:54:51.152 [DEBUG] [org.gradle.process.internal.DefaultExecHandle] Process 'command '/Users/bild_nachine/.rvm/rubies/ruby-2.4.2/bin/fastlane'' finished with exit value 127 (state: FAILED)
    

    gem env 通过 Script Console Jenkins node 我得到了不同的RUBYGEMS版本,gem路径和shell路径。我目前正在努力使 詹金斯结 使用安装在机器上的Ruby Gems,而不是它自己的(或类似的东西)。

    更新(3): EnvInject

    2 回复  |  直到 5 年前
        1
  •  2
  •   Schadenfreude    5 年前

    解决办法如下:

    1. 安装 RVM RBEnv 在你的詹金斯奴隶身上
    2. 安装 Fastlane
    3. Jenkinsfile
        2
  •  0
  •   chedabob    6 年前

    您通常需要手动设置路径,因为Jenkins从机无法获取完整路径。

    可以通过从机的配置页面上的Jenkins仪表板(管理Jenkins->管理节点->>>配置)完成此操作。

    您可以通过运行找到fastlane的安装位置 which fastlane