spring-attic / spring-cloud-pipelines

[DEPRECATED] Codebase containing Concourse and Jenkins opinionated pipelines. Moved to https://github.com/CloudPipelines/
https://github.com/CloudPipelines/
Apache License 2.0
235 stars 175 forks source link

Write a project crawler #170

Closed marcingrzejszczak closed 6 years ago

marcingrzejszczak commented 6 years ago

in order to properly generate pipelines we need to crawl through the most common git storages like

and allow hooking in whatever else you have. We need to allow

this will work really smoothly with Jenkins Job DSL and kind of well with jenkinsfile (for both we use a seed job) for concourse we need to access the concourse API somehow

GITHUB

Getting a list of repos

We used to call such code (worth adding authentication to it)

def organization = binding.variables['ORGANIZATION_NAME'] ?: 'microhackathon-test'
def reposApi = new URL("https://api.github.com/orgs/${organization}/repos")

Getting the file

we can reuse the same abstraction we have in release tools (https://github.com/spring-cloud/spring-cloud-release-tools/blob/master/spring-cloud-release-tools-core/src/main/java/org/springframework/cloud/release/internal/git/GithubMilestones.java)

boolean descriptorExists = new RtGithub("user", "pass").repos().get(new Coordinates.Simple("org", "repo")).contents().exists("sc-pipelines.yml", "master");
if (descriptorExists) {
String descriptorContents = new java.util.Scanner(new RtGithub("user", "pass").repos().get(new Coordinates.Simple("org", "repo")).contents().get("sc-pipelines.yml").raw())).useDelimiter("\\A").next()
}

possible parameterizations: