我想创建一个标签并将其推送到我的git仓库(私有(private))。
目前,我的build.gradle看起来像这样

buildscript {
repositories {
    jcenter()
}
dependencies {
    classpath 'com.android.tools.build:gradle:1.3.0'
    classpath "org.ajoberstar:grgit:1.3.0"

    // NOTE: Do not place your application dependencies here; they belong
    // in the individual module build.gradle files
}
}

 allprojects {
repositories {
    jcenter()
}
}

我有一个任务可以克隆存储库:
task cloneTest <<{
def myRepo = org.ajoberstar.grgit.Grgit.clone(dir: 'C:\\Rep1', uri: 'https://bitbucket.org/..)

 }

现在,我想添加另一个任务来为私有(private)GitHub存储库创建/推送标签,并且已经通过了http://ajoberstar.org/grgit/docs/groovydoc/org/ajoberstar/grgit/operation/TagAddOp.html这个链接
但是我无法在我的gradle文件中使用它。目前我正在这样写
task createTag <<{
def grgit = org.ajoberstar.grgit.Grgit.open(dir: 'C:\\Rep1')
grgit.tag.add(name: 'new-Tag', message: 'Some Message!')
}

该解决方案在http://ajoberstar.org/grgit/docs/groovydoc/org/ajoberstar/grgit/operation/TagAddOp.html中给出。但这说“添加无法解决”。我不知道怎么了我需要更改的grgit版本吗?

最佳答案

这工作:

task createTag <<{
def grgit = org.ajoberstar.grgit.Grgit.open(dir: 'dir_loc')
grgit.tag.add(name: 'new-Tage', message: 'Some Message!')
grgit.push(tags: true)
}

我可以在bitbucket中看到我的标签

我正在使用classpath'org.ajoberstar:grgit:1.3.0'。它在add和push关键字上显示错误,但是当我在cli上运行任务时,它可以成功运行。所以,这完全可以

10-05 23:36