Example #1
0
// GetScript fetches the build script (.drone.yml) from the remote
// repository and returns in string format.
func (g *Gitlab) Script(user *model.User, repo *model.Repo, build *model.Build) ([]byte, []byte, error) {
	var client = NewClient(g.URL, user.Token, g.SkipVerify)
	id, err := GetProjectId(g, client, repo.Owner, repo.Name)
	if err != nil {
		return nil, nil, err
	}

	out1, err := client.RepoRawFile(id, build.Commit, ".drone.yml")
	if err != nil {
		return nil, nil, err
	}
	out2, err := client.RepoRawFile(id, build.Commit, ".drone.sec")
	if err != nil {
		return out1, nil, nil
	}
	return out1, out2, err
}
Example #2
0
File: gitlab.go Project: Ablu/drone
// File fetches a file from the remote repository and returns in string format.
func (g *Gitlab) File(user *model.User, repo *model.Repo, build *model.Build, f string) ([]byte, error) {
	var client = NewClient(g.URL, user.Token, g.SkipVerify)
	id, err := GetProjectId(g, client, repo.Owner, repo.Name)
	if err != nil {
		return nil, err
	}

	out, err := client.RepoRawFile(id, build.Commit, f)
	if err != nil {
		return nil, err
	}
	return out, err
}