命令 git 以非零退出值 128 结束 [英] command git finished with non-zero exit value 128

查看:72
本文介绍了命令 git 以非零退出值 128 结束的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当我将Android项目从Eclipse迁移到Android Studio时,使用travis ci构建项目时,出现以下错误.

When I migrate Android project from Eclipse to Android Studio, use travis ci to build the project, it has the following errors.

FAILURE:构建失败,出现异常.
* 哪里:
构建文件 '/home/travis/build/Logan676/seadroid/app/build.gradle' 行:20
* 出了什么问题:
评估项目:app"时出现问题.
进程 'command'git'' 以非零退出值 128 结束

FAILURE: Build failed with an exception.
* Where:
Build file '/home/travis/build/Logan676/seadroid/app/build.gradle' line: 20
* What went wrong:
A problem occurred evaluating project ':app'.
Process 'command 'git'' finished with non-zero exit value 128

build.gradle 文件是

the build.gradle file is

    buildscript {
        repositories {
            jcenter()
        }
        dependencies {
            classpath 'com.android.tools.build:gradle:0.13.0'
        }
    }
    apply plugin: 'com.android.application'

    repositories {
        jcenter()
    }

    /*
     * Gets the version name from the latest Git tag
     */
    def getVersionName = { ->
        def stdout = new ByteArrayOutputStream()
        exec {
            // LINE 20 IS HERER!!!!!!!!!!!!!
            commandLine 'git', 'describe', '--tags' 
            standardOutput = stdout
        }
        return stdout.toString().trim()
    }
    def getVersionCode = { ->
        def stdout = new ByteArrayOutputStream()
        exec {
            commandLine 'git', 'rev-list', '--count', "HEAD"
            standardOutput = stdout
        }
        return Integer.valueOf(stdout.toString().trim())
    }


    dependencies {
        compile 'com.android.support:support-v4:21.0.+'
        compile 'com.actionbarsherlock:actionbarsherlock:4.4.0@aar'
        compile 'com.inkapplications.viewpageindicator:library:2.4.3'
        compile 'com.github.kevinsawicki:http-request:5.6'
        compile 'commons-io:commons-io:2.4'
        compile 'com.google.guava:guava:18.0'
        compile 'com.nostra13.universalimageloader:universal-image-loader:1.9.3'
        compile project(':libraries:NewQuickAction')
        compile project(':libraries:MarkdownView')
        compile project(':libraries:PullToRefresh')
    }

    android {
        compileSdkVersion rootProject.ext.compileSdkVersion
        buildToolsVersion rootProject.ext.buildToolsVersion

        defaultConfig {
            minSdkVersion rootProject.ext.minSdkVersion
            targetSdkVersion rootProject.ext.targetSdkVersion
            versionCode getVersionCode()
            versionName getVersionName()
        }

        lintOptions {
            abortOnError false
        }

        signingConfigs {
            release {
                // Signing code for manual signing
                //storeFile file(System.console().readLine("\n\$ Enter keystore path: "))
                //storePassword System.console().readPassword("\n\$ Enter keystore      password: ").toString()
                //keyAlias System.console().readLine("\n\$ Enter key alias: ")
                //keyPassword System.console().readPassword("\n\$ Enter key password:    ").toString()
            }
        }

        buildTypes {
            release {
                //signingConfig signingConfigs.release
                runProguard true
                proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-project.txt'
            }
        }
    }

我猜是由于未安装 git 错误造成的.但我不知道如何修复它.也许它需要一些脚本来自动安装 git.所以任何人都可以帮我修改上面显示的 Gradle 文件.

I guess it caused by not installed git error. But I don`t know how to fix it. Maybe it needs some script to automatically install git. So anyone can help me modify the Gradle file as showed above.

推荐答案

我从代码中的 git 命令输出中捕获修订属性中的修订(unix/first exec/和 windows/second exec/通用代码,命令 git must work从控制台)

I catch revision in revision property from git command output in the code (code universal for unix /first exec/ and windows /second exec/, command git must work from console)

def os = System.getProperty("os.name").toLowerCase()
def revision = new ByteArrayOutputStream()
if (!os.contains("windows")) {
    exec {
        executable "/bin/sh"
        args "-c", "echo -n `git rev-list HEAD | wc -l | sed 's/^[ ^t]*//'`"
        standardOutput = revision;
    }
} else {
    exec {
        executable "cmd"
        args "/c", "git rev-list HEAD | find /c /v \"\""
        standardOutput = revision;
    }
    revision = revision as String
    revision = revision.trim()
};

您可以根据需要更改代码.

You can change code for you needed.

这篇关于命令 git 以非零退出值 128 结束的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆