我想创建一个标签并将其推送到我的 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 中看到我的标签
我正在使用类路径 'org.ajoberstar:grgit:1.3.0' 。它在添加和推送关键字时显示错误,但是当我在 cli 上运行任务时它运行成功。所以,这完全正常
关于github - 使用 gradle git 插件为私有(private)存储库创建/推送标签,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34728028/