Skip to content

Commit

Permalink
Rename build to pipeline in code (woodpecker-ci#1224)
Browse files Browse the repository at this point in the history
Ref:  woodpecker-ci#745

Co-authored-by: Anbraten <anton@ju60.de>
Co-authored-by: 6543 <6543@obermui.de>
  • Loading branch information
3 people authored and simmstein committed Dec 1, 2022
1 parent 64c9304 commit 9b849bc
Show file tree
Hide file tree
Showing 224 changed files with 4,590 additions and 3,830 deletions.
27 changes: 17 additions & 10 deletions agent/runner.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
// Copyright 2022 Woodpecker Authors
// Copyright 2018 Drone.IO Inc.
//
// Licensed under the Apache License, Version 2.0 (the "License");
Expand Down Expand Up @@ -80,20 +81,20 @@ func (r *Runner) Run(ctx context.Context) error {
timeout = time.Duration(minutes) * time.Minute
}

repoName := extractRepositoryName(work.Config) // hack
buildNumber := extractBuildNumber(work.Config) // hack
repoName := extractRepositoryName(work.Config) // hack
pipelineNumber := extractPipelineNumber(work.Config) // hack

r.counter.Add(
work.ID,
timeout,
repoName,
buildNumber,
pipelineNumber,
)
defer r.counter.Done(work.ID)

logger := log.With().
Str("repo", repoName).
Str("build", buildNumber).
Str("pipeline", pipelineNumber).
Str("id", work.ID).
Logger()

Expand Down Expand Up @@ -288,6 +289,10 @@ func (r *Runner) Run(ctx context.Context) error {

// TODO: find better way to update this state and move it to pipeline to have the same env in cli-exec
state.Pipeline.Step.Environment["CI_MACHINE"] = r.hostname
state.Pipeline.Step.Environment["CI_PIPELINE_STATUS"] = "success"
state.Pipeline.Step.Environment["CI_PIPELINE_STARTED"] = strconv.FormatInt(state.Pipeline.Time, 10)
state.Pipeline.Step.Environment["CI_PIPELINE_FINISHED"] = strconv.FormatInt(time.Now().Unix(), 10)
// DEPRECATED
state.Pipeline.Step.Environment["CI_BUILD_STATUS"] = "success"
state.Pipeline.Step.Environment["CI_BUILD_STARTED"] = strconv.FormatInt(state.Pipeline.Time, 10)
state.Pipeline.Step.Environment["CI_BUILD_FINISHED"] = strconv.FormatInt(time.Now().Unix(), 10)
Expand All @@ -299,6 +304,8 @@ func (r *Runner) Run(ctx context.Context) error {
state.Pipeline.Step.Environment["CI_SYSTEM_ARCH"] = runtime.GOOS + "/" + runtime.GOARCH

if state.Pipeline.Error != nil {
state.Pipeline.Step.Environment["CI_PIPELINE_STATUS"] = "failure"
// DEPRECATED
state.Pipeline.Step.Environment["CI_BUILD_STATUS"] = "failure"
state.Pipeline.Step.Environment["CI_JOB_STATUS"] = "failure"
}
Expand All @@ -311,9 +318,9 @@ func (r *Runner) Run(ctx context.Context) error {
pipeline.WithTracer(defaultTracer),
pipeline.WithEngine(*r.engine),
pipeline.WithDescription(map[string]string{
"ID": work.ID,
"Repo": repoName,
"Build": buildNumber,
"ID": work.ID,
"Repo": repoName,
"Pipeline": pipelineNumber,
}),
).Run()

Expand Down Expand Up @@ -363,7 +370,7 @@ func extractRepositoryName(config *backend.Config) string {
return config.Stages[0].Steps[0].Environment["CI_REPO"]
}

// extract build number from the configuration
func extractBuildNumber(config *backend.Config) string {
return config.Stages[0].Steps[0].Environment["CI_BUILD_NUMBER"]
// extract pipeline number from the configuration
func extractPipelineNumber(config *backend.Config) string {
return config.Stages[0].Steps[0].Environment["CI_PIPELINE_NUMBER"]
}
23 changes: 12 additions & 11 deletions agent/state.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
// Copyright 2022 Woodpecker Authors
// Copyright 2018 Drone.IO Inc.
//
// Licensed under the Apache License, Version 2.0 (the "License");
Expand Down Expand Up @@ -29,23 +30,23 @@ type State struct {
}

type Info struct {
ID string `json:"id"`
Repo string `json:"repository"`
Build string `json:"build_number"`
Started time.Time `json:"build_started"`
Timeout time.Duration `json:"build_timeout"`
ID string `json:"id"`
Repo string `json:"repository"`
Pipeline string `json:"build_number"`
Started time.Time `json:"build_started"`
Timeout time.Duration `json:"build_timeout"`
}

func (s *State) Add(id string, timeout time.Duration, repo, build string) {
func (s *State) Add(id string, timeout time.Duration, repo, pipeline string) {
s.Lock()
s.Polling--
s.Running++
s.Metadata[id] = Info{
ID: id,
Repo: repo,
Build: build,
Timeout: timeout,
Started: time.Now().UTC(),
ID: id,
Repo: repo,
Pipeline: pipeline,
Timeout: timeout,
Started: time.Now().UTC(),
}
s.Unlock()
}
Expand Down
28 changes: 0 additions & 28 deletions cli/build/build.go

This file was deleted.

44 changes: 0 additions & 44 deletions cli/build/build_approve.go

This file was deleted.

44 changes: 0 additions & 44 deletions cli/build/build_decline.go

This file was deleted.

73 changes: 0 additions & 73 deletions cli/build/build_info.go

This file was deleted.

45 changes: 0 additions & 45 deletions cli/build/build_kill.go

This file was deleted.

Loading

0 comments on commit 9b849bc

Please sign in to comment.