示例#1
0
func (e *Engine) Run() (Result, error) {
	defer e.reporter.Shutdown()

	wg := sync.WaitGroup{}

	wg.Add(1)
	go func() {
		reportLogChunks("console", e.clientLog, e.reporter)
		wg.Done()
	}()

	e.clientLog.Writeln("changes-client version: " + version.GetVersion())

	e.reporter.Init(e.config)

	e.reporter.PushJobstepStatus(STATUS_IN_PROGRESS, "")

	result, err := e.runBuildPlan()

	e.clientLog.Writeln(fmt.Sprintf("==> Build finished! Recorded result as %s", result))

	e.reporter.PushJobstepStatus(STATUS_FINISHED, result.String())

	e.clientLog.Close()

	wg.Wait()

	return result, err
}
示例#2
0
// Return our global Sentry client, or nil if none was configured.
func GetClient() *raven.Client {
	sentryClientMux.Lock()
	defer sentryClientMux.Unlock()
	if sentryClient != nil {
		return sentryClient
	}

	if sentryDsn == "" {
		return nil
	}

	if client, err := raven.NewClient(sentryDsn, map[string]string{
		"version": version.GetVersion(),
	}); err != nil {
		// TODO: Try to avoid potentially dying fatally in a getter;
		// we may want to log an error and move on, we might want defers
		// to fire, etc. This will probably mean not creating the client
		// lazily.
		log.Fatal(err)
	} else {
		sentryClient = client
	}
	sentryClient.Transport = &NoisyTransport{sentryClient.Transport}

	return sentryClient
}
示例#3
0
func (e *Engine) Run() (Result, error) {
	e.reporter.Init(e.config)
	defer e.reporter.Shutdown()

	var wg sync.WaitGroup

	wg.Add(1)
	go func() {
		reportLogChunks("console", e.clientLog, e.reporter)
		wg.Done()
	}()

	e.clientLog.Writeln("changes-client version: " + version.GetVersion())
	e.clientLog.Printf("Running jobstep %s for %s (%s)", e.config.JobstepID, e.config.Project.Name, e.config.Project.Slug)

	e.reporter.PushJobstepStatus(STATUS_IN_PROGRESS, "")

	result, err := e.runBuildPlan()

	e.clientLog.Printf("==> Build finished! Recorded result as %s", result)

	e.reporter.PushJobstepStatus(STATUS_FINISHED, result.String())

	e.clientLog.Close()

	wg.Wait()

	return result, err
}
示例#4
0
func main() {
	showVersion := flag.Bool("version", false, "Prints changes-client version")
	exitResult := flag.Bool("exit-result", false, "Determine exit code from result")
	flag.Parse()

	if *showVersion {
		fmt.Println(version.GetVersion())
		return
	}

	success := run()
	if !success && *exitResult {
		log.Fatal("[client] exit: 1")
	}
	log.Println("[client] exit: 0")
}