<commit_before>package gocd

import (
	"github.com/servehub/serve/manifest"
	"github.com/servehub/utils"
)

func init() {
	manifest.PluginRegestry.Add("gocd.pipeline.run", goCdPipelineRun{})
}

type goCdPipelineRun struct{}

func (p goCdPipelineRun) Run(data manifest.Manifest) error {
	url := data.GetString("api-url")
	name := data.GetString("pipeline-name")

	resp, err := goCdSchedule(name, url, data.GetTree("schedule").String(), map[string]string{"Accept": "application/vnd.go.cd.v1+json"})

	if err == nil && resp.StatusCode == 404 {
		return utils.RunCmd(
			"serve gocd.pipeline.create --ssh-repo=$GO_MATERIAL_URL_SOURCES --branch=%s",
			data.GetString("branch"),
		)
	}

	return err
}<commit_msg>gocd.pipeline.run: trigger pipeline after creation<commit_after>package gocd

import (
	"github.com/servehub/serve/manifest"
	"github.com/servehub/utils"
)

func init() {
	manifest.PluginRegestry.Add("gocd.pipeline.run", goCdPipelineRun{})
}

type goCdPipelineRun struct{}

func (p goCdPipelineRun) Run(data manifest.Manifest) error {
	url := data.GetString("api-url")
	name := data.GetString("pipeline-name")

	resp, err := goCdSchedule(name, url, data.GetTree("schedule").String(), map[string]string{"Accept": "application/vnd.go.cd.v1+json"})

	if err == nil && resp.StatusCode == 404 {
		if err := utils.RunCmd(
			"serve gocd.pipeline.create --ssh-repo=$GO_MATERIAL_URL_SOURCES --branch=%s",
			data.GetString("branch"),
		); err != nil {
			return err
		}

		_, err := goCdSchedule(name, url, data.GetTree("schedule").String(), map[string]string{"Accept": "application/vnd.go.cd.v1+json"})
		return err
	}

	return err
}
{'fraction_non_alphanumeric': 0.16901408450704225, 'fraction_numerical': 0.005511328842620943, 'mean_word_length': 5.007352941176471, 'pattern_counts': {'":': 3, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '491668', 'n_tokens_mistral': 618, 'n_tokens_neox': 580, 'n_words': 103}