You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@bigtop.apache.org by rv...@apache.org on 2017/03/24 18:40:44 UTC
bigtop git commit: BIGTOP-2306 Add support for specifying git
repository access credentials
Repository: bigtop
Updated Branches:
refs/heads/master b8959afe6 -> 02e617c22
BIGTOP-2306 Add support for specifying git repository access credentials
Project: http://git-wip-us.apache.org/repos/asf/bigtop/repo
Commit: http://git-wip-us.apache.org/repos/asf/bigtop/commit/02e617c2
Tree: http://git-wip-us.apache.org/repos/asf/bigtop/tree/02e617c2
Diff: http://git-wip-us.apache.org/repos/asf/bigtop/diff/02e617c2
Branch: refs/heads/master
Commit: 02e617c22454f61060e07137abd8209ca1dccfef
Parents: b8959af
Author: Andrew Purtell <ap...@apache.org>
Authored: Fri Mar 24 11:39:04 2017 -0700
Committer: Roman Shaposhnik <rv...@apache.org>
Committed: Fri Mar 24 11:39:04 2017 -0700
----------------------------------------------------------------------
packages.gradle | 52 ++++++++++++++++++++++++++++++++++++++++------------
1 file changed, 40 insertions(+), 12 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/bigtop/blob/02e617c2/packages.gradle
----------------------------------------------------------------------
diff --git a/packages.gradle b/packages.gradle
index f6b8543..d1e558d 100644
--- a/packages.gradle
+++ b/packages.gradle
@@ -15,19 +15,13 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-import org.ajoberstar.grgit.*
import groovy.json.JsonOutput
+import java.net.URI
buildscript {
repositories {
mavenCentral()
}
- dependencies {
- classpath 'org.ajoberstar:grgit:0.4.1'
- // To handle symbolic links when cloning git repos, the jgit.java7 jar
- // must be added to the classpath.
- classpath 'org.eclipse.jgit:org.eclipse.jgit.java7:3.6.2.201501210735-r'
- }
}
apply plugin: 'java'
@@ -186,6 +180,15 @@ def genTasks = { target ->
def final GIT_REF = config.bigtop.components[target].git.ref
def final GIT_DIR = config.bigtop.components[target].git.dir
+ def GIT_USER_NAME = BOM_map[variable + '_GIT_USER_NAME']
+ if (!GIT_USER_NAME)
+ GIT_USER_NAME = BOM_map['GIT_USER_NAME']
+ def GIT_ACCESS_TOKEN = BOM_map[variable + '_GIT_ACCESS_TOKEN']
+ if (!GIT_ACCESS_TOKEN)
+ GIT_ACCESS_TOKEN = BOM_map['GIT_ACCESS_TOKEN']
+
+ def devNull = new org.apache.bigtop.NullOutputStream()
+
if (!DOWNLOAD_URL)
return
@@ -200,11 +203,36 @@ def genTasks = { target ->
dir = TARBALL_DST.substring(0, TARBALL_DST.lastIndexOf(".t"))
}
delete("${DL_DIR}/${dir}")
- Grgit.clone(
- uri: GIT_REPO,
- refToCheckout: GIT_REF,
- dir: new File("${DL_DIR}/${dir}")
- )
+ if (GIT_USER_NAME && GIT_ACCESS_TOKEN) {
+ def uri = new URI(GIT_REPO)
+ if (!GIT_REPO.toLowerCase().startsWith("http")) {
+ println("\tGit credentials supported only with 'http' or 'https' schemes");
+ return
+ }
+ uri = new URI(uri.getScheme(),
+ "${GIT_USER_NAME}:${GIT_ACCESS_TOKEN}".toString(), // userInfo
+ uri.getHost(), uri.getPort(), uri.getPath(), uri.getQuery(),
+ uri.getFragment())
+ exec {
+ workingDir DL_DIR
+ commandLine "git clone --depth 1 ${uri} ${dir}".split()
+ errorOutput devNull
+ standardOutput devNull
+ }
+ } else {
+ exec {
+ workingDir DL_DIR
+ commandLine "git clone --depth 1 ${GIT_REPO} ${dir}".split()
+ errorOutput devNull
+ standardOutput devNull
+ }
+ }
+ exec {
+ workingDir "$DL_DIR/${dir}"
+ commandLine "git checkout $GIT_REF".split()
+ errorOutput devNull
+ standardOutput devNull
+ }
delete("${DL_DIR}/${dir}/.git")
exec {
workingDir DL_DIR