github.com/ouraigua/jenkins-library@v0.0.0-20231028010029-fbeaf2f3aa9b/pkg/jenkins/job.go (about) 1 package jenkins 2 3 import ( 4 "context" 5 6 "github.com/bndr/gojenkins" 7 ) 8 9 // Task is an interface to abstract gojenkins.Task. 10 // mock generated with: mockery --name Job --dir pkg/jenkins --output pkg/jenkins/mocks 11 type Job interface { 12 Poll(context.Context) (int, error) 13 InvokeSimple(ctx context.Context, params map[string]string) (int64, error) 14 GetJob() *gojenkins.Job 15 } 16 17 // JobImpl is a wrapper struct for gojenkins.Task that respects the Task interface. 18 type JobImpl struct { 19 Job *gojenkins.Job 20 } 21 22 // Poll refers to the gojenkins.Job.Poll function. 23 func (t *JobImpl) Poll(ctx context.Context) (int, error) { 24 return t.Job.Poll(ctx) 25 } 26 27 // InvokeSimple refers to the gojenkins.Job.InvokeSimple function. 28 func (t *JobImpl) InvokeSimple(ctx context.Context, params map[string]string) (int64, error) { 29 return t.Job.InvokeSimple(ctx, params) 30 } 31 32 // GetJob returns wrapped gojenkins.Job. 33 func (t *JobImpl) GetJob() *gojenkins.Job { 34 return t.Job 35 }