jenkins

package
v1.3.3 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 28, 2023 License: Apache-2.0 Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CheckGHIssuesFailures

func CheckGHIssuesFailures(issueJenkinsURLFails map[int]GHIssue, testFailure Test, flakeSimilarity float64) (int, float64)

CheckGHIssuesFailures checks if the given testFailure is similar to any of the GH issues from 'issueJenkinsURLFails'. If found, returns the issue number and its similarity.

func GHIssueComment

func GHIssueComment(prNumber int, similarity float64, failure BuildFailure) (string, string, error)

GHIssueComment returns an issue comment that can be used in GH issues to track which PRs are hitting certain flakes.

func GHIssueDescription

func GHIssueDescription(failure BuildFailure) (string, string, error)

GHIssueDescription returns an issue description that can be used when creating a new GH issue flake.

func IsJenkinsFailure

func IsJenkinsFailure(state, description string) bool

func IsSimilarFlake

func IsSimilarFlake(test1, test2 Test, flakeSimilarity float64) float64

IsSimilarFlake checks if test1 and test2 have a similarity greater than 'flakeSimilarity'. If they have, it returns the similarity of both tests if they don't have returns -1.

func PRCommentFailure

func PRCommentFailure(failure BuildFailure) (string, error)

func PRCommentKnownFlakes

func PRCommentKnownFlakes(jobName string, issues map[int][]string) (string, error)

func PRCommentNewGHIssues

func PRCommentNewGHIssues(issues []int) (string, error)

func PRCommentUnknownFlakes

func PRCommentUnknownFlakes(jobName string, failures []BuildFailure, issues map[int][]string) (string, error)

func SplitJobNameNumber

func SplitJobNameNumber(link string) (string, int64)

Types

type BuildFailure

type BuildFailure struct {
	BuildNumber int64  `json:"build-number"`
	JobName     string `json:"job-name"`
	// Artifacts is a list of URLs for such artifacts
	Artifacts []string `json:"artifacts"`
	// URL is the URL for the BuildFailure
	URL string `json:"url"`
	Test
}

func FilterFlakes

func FilterFlakes(log *zerolog.Logger, flakeCfg FlakeConfig, jobFailures []BuildFailure, jobFailURL string) []BuildFailure

FilterFlakes filters the given flakes accordingly the configuration set in flakeConfig. If the number of flakes is greater than the maximum possible flakes per test, it will print a warning message in the logs and return nil.

type FlakeConfig

type FlakeConfig interface {
	GetMaxFlakesPerTest() int
	CommonFailure(str string) bool
}

type GHIssue

type GHIssue struct {
	Title string `json:"title"`
	Test
}

func ParseGHIssue

func ParseGHIssue(title string, body string) GHIssue

type JenkinsClient

type JenkinsClient struct {
	*gojenkins.Jenkins
	// contains filtered or unexported fields
}

func NewJenkinsClient

func NewJenkinsClient(ctx context.Context, url string, serverMode bool) (*JenkinsClient, error)

NewJenkinsClient creates a new JenkinsClient. If 'serverMode' is set, UX log messages are not printed, for example loading bars.

func (*JenkinsClient) GetJobFailure

func (jc *JenkinsClient) GetJobFailure(ctx context.Context, jobName string, buildNumber int64) (int, []BuildFailure, error)

GetJobFailure returns the PR number, or 0 if not found and a list of BuildFailures for the given buildNumber of the jobName. If the Build no longer exists no errors are returned and the list of BuildFailures is also nil.

func (*JenkinsClient) GetJobFrom

func (jc *JenkinsClient) GetJobFrom(ctx context.Context, jobName string,
	filterFlakes func(jobFailures []BuildFailure, jobFailURL string) []BuildFailure) (JenkinsFailures, error)

GetJobFrom returns all failures filtered by 'filterFlakes' from the given jenkins URL.

func (*JenkinsClient) GetTestResults

func (jc *JenkinsClient) GetTestResults(ctx context.Context, jobName string) (JenkinsFailures, error)

GetTestResults returns all test results of a job.

type JenkinsFailures

type JenkinsFailures map[int][]BuildFailure

JenkinsFailures maps a PR to a slice of BuildFailures

type Test

type Test struct {
	TestName       string `json:"test-name"`
	FailureOutput  string `json:"failure-output"`
	StackTrace     string `json:"stack-trace"`
	StandardOutput string `json:"standard-output"`
	StandardError  string `json:"standard-error"`
}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL