tcutil/tcutil.go
func PublishTask(queue *tcqueue.Queue, taskID string, tdr tcqueue.TaskDefinitionRequest, workerGroup, workerID string, artifacts []ArtifactSource) error {
	workerType := tdr.WorkerType
	provisionerID := tdr.ProvisionerID
	cwrq := tcqueue.ClaimWorkRequest{
		Tasks:       1,
		WorkerGroup: workerGroup,
		WorkerID:    workerID,
	}
	log.Printf("Creating task %v", taskID)
	_, err := queue.CreateTask(taskID, &tdr)
	if err != nil {
		return fmt.Errorf("Exception thrown creating task %v:\n%s", taskID, err)
	}
	log.Printf("Claiming work for provisionerId/workerType %v/%v", provisionerID, workerType)
	cwrs, err := queue.ClaimWork(provisionerID, workerType, &cwrq)
	if err != nil {
		return fmt.Errorf("Exception thrown claiming task %v:\n%s", taskID, err)
	}
	taskCreds := cwrs.Tasks[0].Credentials
	taskQueue := tcqueue.New(&tcclient.Credentials{
		ClientID:         taskCreds.ClientID,
		AccessToken:      taskCreds.AccessToken,
		Certificate:      taskCreds.Certificate,
		AuthorizedScopes: nil,
	}, "")
	taskQueue.BaseURL = queue.BaseURL
	for _, as := range artifacts {
		err = as.Upload(taskQueue, taskID)
		if err != nil {
			return fmt.Errorf("Exception uploading artifact %v for task %v: %v", as.Name, taskID, err)
		}
	}

	log.Printf("Resolving task %v", taskID)
	_, err = taskQueue.ReportCompleted(taskID, "0")
	if err != nil {
		return fmt.Errorf("Exception reporting task %v completed: %v", taskID, err)
	}
	return nil
}
func PublishTask(queue *tcqueue.Queue, taskID string, tdr tcqueue.TaskDefinitionRequest, workerGroup, workerID string, artifacts []ArtifactSource) error {
	workerType := tdr.WorkerType
	provisionerID := tdr.ProvisionerID
	cwrq := tcqueue.ClaimWorkRequest{
		Tasks:       1,
		WorkerGroup: workerGroup,
		WorkerID:    workerID,
	}
	log.Printf("Creating task %v", taskID)
	_, err := queue.CreateTask(taskID, &tdr)
	if err != nil {
		return fmt.Errorf("Exception thrown creating task %v:\n%s", taskID, err)
	}
	log.Printf("Claiming work for provisionerId/workerType %v/%v", provisionerID, workerType)
	cwrs, err := queue.ClaimWork(provisionerID, workerType, &cwrq)
	if err != nil {
		return fmt.Errorf("Exception thrown claiming task %v:\n%s", taskID, err)
	}
	taskCreds := cwrs.Tasks[0].Credentials
	taskQueue := tcqueue.New(&tcclient.Credentials{
		ClientID:         taskCreds.ClientID,
		AccessToken:      taskCreds.AccessToken,
		Certificate:      taskCreds.Certificate,
		AuthorizedScopes: nil,
	}, "")
	taskQueue.BaseURL = queue.BaseURL
	for _, as := range artifacts {
		err = as.Upload(taskQueue, taskID)
		if err != nil {
			return fmt.Errorf("Exception uploading artifact %v for task %v: %v", as.Name, taskID, err)
		}
	}

	log.Printf("Resolving task %v", taskID)
	_, err = taskQueue.ReportCompleted(taskID, "0")
	if err != nil {
		return fmt.Errorf("Exception reporting task %v completed: %v", taskID, err)
	}
	return nil
}
// PublishTask submits the task `taskID` with definition `tdr` using `queue`. The
// task is claimed using `workerGroup` and `workerID`, and then `artifacts` are
// uploaded in sequence using taskcluster-lib-artifact-go.  This function is useful for
// e.g.  integration tests for the various taskcluster go libraries and
// utilities that rely on tasks and/or artifact content to test their features.