Skip to content

Commit

Permalink
branch name should be url-encoded
Browse files Browse the repository at this point in the history
  • Loading branch information
jk1 committed Feb 23, 2015
1 parent 64eeb7e commit de3e367
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 11 deletions.
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -65,10 +65,11 @@ Changing dependencies may be also resolved against particular [feature branches]

```groovy
dependencies {
compile tc(buildTypeId: 'bt345', version: 'lastSuccessful', artifactPath: 'testng-6.8.8.jar', branch: 'master')
compile tc(buildTypeId: 'bt345', version: 'lastSuccessful', artifactPath: 'KotlinJpsPlugin/kotlin-jps-plugin.jar', branch: 'master')
}
```

Branch name should be specified exactly as it's known to TeamCity with no encoding applied.
Default branch will be used if branch value is not specified explicitly.

###Pinning the build
Expand Down
12 changes: 6 additions & 6 deletions consumer/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -15,20 +15,20 @@ configurations.all {

dependencies {
// reference arbitrary files as artifacts
compile tc('bt345:0.10.195:kotlin-compiler-0.10.195.zip')
compile tc('bt345:0.10.1094:kotlin-compiler-0.10.1094.zip')
// with self-explanatory map dependency notation
compile tc(buildTypeId: 'bt345', version: '0.10.195', artifactPath: 'kotlin-compiler-for-maven.jar')
compile tc(buildTypeId: 'bt345', version: '0.10.1094', artifactPath: 'kotlin-compiler-for-maven.jar')
// subfolders are supported
compile tc('bt345:0.10.195:KotlinJpsPlugin/kotlin-jps-plugin.jar')
compile tc('bt345:0.10.1094:KotlinJpsPlugin/kotlin-jps-plugin.jar')
// archive traversal is available with '!' symbol
compile tc('bt345:0.10.195:kotlin-compiler-0.10.195.zip!/kotlinc/build.txt')
compile tc('bt345:0.10.1094:kotlin-compiler-0.10.1094.zip!/kotlinc/build.txt')
// Use TeamCity version aliases to declare snapshot-like dependencies
compile tc('bt351:lastFinished:plugin-verifier.jar')
compile tc('bt131:lastPinned:javadocs/index.html')
compile tc('bt337:lastSuccessful:odata4j.zip')
compile tc('bt132:sameChainOrLastFinished:index.html')
// with feature branches supported
compile tc(buildTypeId: 'bt345', version: 'lastSuccessful', artifactPath: 'testng-6.8.8.jar', branch: 'master')
// with feature branches supported*/
compile tc(buildTypeId: 'bt390', version: 'lastSuccessful', artifactPath: 'updatePlugins.xml', branch: 'master')
}

defaultTasks 'listdeps'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ class BranchScopedArtifactVersion extends ArtifactVersion {
@Override
def resolve(Project project, String btid) {
String request = url(project.teamcityServer.url, btid)
String response = "<no response recorded>"
String response = "No response recorded. Rerun with --stacktrace to see an exception."
try {
HttpURLConnection connection = request.toURL().openConnection()
response = connection.inputStream.withReader { Reader reader -> reader.text }
Expand All @@ -35,13 +35,13 @@ class BranchScopedArtifactVersion extends ArtifactVersion {
throw new GradleException(message)
}
} catch (Exception e) {
String message = "Unable to resolve $version in $branch.\nRequest: GET $request \nServer response: \n $response"
throw new GradleException(message, e)
throw new GradleException("Unable to resolve $version in $branch. Request: GET $request", e)
}
}

private def url(String server, String btid) {
def query = "buildType:$btid,branch:$branch${versionPlaceholders[version]}/number"
def branchEncoded = URLEncoder.encode(branch, "utf-8");
def query = "buildType:$btid,branch:$branchEncoded${versionPlaceholders[version]}/number"
return "${server}/guestAuth/app/rest/builds/$query"
}
}

0 comments on commit de3e367

Please sign in to comment.