Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Revert breaking changes #2444

Closed
wants to merge 3 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
"prettier.configPath": "./web/.prettierrc.js",
"prettier.ignorePath": "./web/.prettierignore",
"cSpell.words": [
"Curr",
"doublestar",
"multierr"
]
Expand Down
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,7 @@ test-server-datastore-coverage: ## Test server datastore with coverage report

test-ui: ui-dependencies ## Test UI code
(cd web/; pnpm run lint)
(cd web/; pnpm run format:check)
(cd web/; pnpm run formatcheck)
(cd web/; pnpm run typecheck)
(cd web/; pnpm run test)

Expand Down
14 changes: 13 additions & 1 deletion agent/tracer.go
Original file line number Diff line number Diff line change
Expand Up @@ -76,11 +76,23 @@ func (r *Runner) createTracer(ctxmeta context.Context, logger zerolog.Logger, wo
state.Pipeline.Step.Environment["CI_STEP_STARTED"] = strconv.FormatInt(state.Pipeline.Time, 10)
state.Pipeline.Step.Environment["CI_STEP_FINISHED"] = strconv.FormatInt(time.Now().Unix(), 10)

state.Pipeline.Step.Environment["CI_SYSTEM_PLATFORM"] = runtime.GOOS + "/" + runtime.GOARCH
state.Pipeline.Step.Environment["CI_SYSTEM_ARCH"] = runtime.GOOS + "/" + runtime.GOARCH

// 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)
state.Pipeline.Step.Environment["CI_JOB_STATUS"] = "success"
state.Pipeline.Step.Environment["CI_JOB_STARTED"] = strconv.FormatInt(state.Pipeline.Time, 10)
state.Pipeline.Step.Environment["CI_JOB_FINISHED"] = strconv.FormatInt(time.Now().Unix(), 10)

if state.Pipeline.Error != nil {
state.Pipeline.Step.Environment["CI_PIPELINE_STATUS"] = "failure"
state.Pipeline.Step.Environment["CI_STEP_STATUS"] = "failure"

// DEPRECATED
state.Pipeline.Step.Environment["CI_BUILD_STATUS"] = "failure"
state.Pipeline.Step.Environment["CI_JOB_STATUS"] = "failure"
}

return nil
Expand Down
14 changes: 7 additions & 7 deletions cli/exec/flags.go
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ var flags = []cli.Flag{
Value: "woodpecker",
},
&cli.StringFlag{
EnvVars: []string{"CI_SYSTEM_URL"},
EnvVars: []string{"CI_SYSTEM_URL", "CI_SYSTEM_LINK"},
Name: "system-link",
Value: "https://github.com/woodpecker-ci/woodpecker",
},
Expand All @@ -143,11 +143,11 @@ var flags = []cli.Flag{
Name: "repo-remote-id",
},
&cli.StringFlag{
EnvVars: []string{"CI_REPO_URL"},
EnvVars: []string{"CI_REPO_URL", "CI_REPO_LINK"},
Name: "repo-link",
},
&cli.StringFlag{
EnvVars: []string{"CI_REPO_CLONE_URL"},
EnvVars: []string{"CI_REPO_CLONE_URL", "CI_REPO_REMOTE"},
Name: "repo-clone-url",
},
&cli.StringFlag{
Expand Down Expand Up @@ -192,7 +192,7 @@ var flags = []cli.Flag{
Value: "manual",
},
&cli.StringFlag{
EnvVars: []string{"CI_PIPELINE_URL"},
EnvVars: []string{"CI_PIPELINE_URL", "CI_PIPELINE_LINK"},
Name: "pipeline-link",
},
&cli.StringFlag{
Expand Down Expand Up @@ -256,7 +256,7 @@ var flags = []cli.Flag{
Name: "prev-pipeline-event",
},
&cli.StringFlag{
EnvVars: []string{"CI_PREV_PIPELINE_URL"},
EnvVars: []string{"CI_PREV_PIPELINE_URL", "CI_PREV_PIPELINE_LINK"},
Name: "prev-pipeline-link",
},
&cli.StringFlag{
Expand Down Expand Up @@ -296,11 +296,11 @@ var flags = []cli.Flag{
Name: "workflow-name",
},
&cli.IntFlag{
EnvVars: []string{"CI_WORKFLOW_NUMBER"},
EnvVars: []string{"CI_WORKFLOW_NUMBER", "CI_JOB_NUMBER"},
Name: "workflow-number",
},
&cli.IntFlag{
EnvVars: []string{"CI_STEP_NAME"},
EnvVars: []string{"CI_STEP_NAME", "CI_JOB_NUMBER"},
Name: "step-name",
},
&cli.StringSliceFlag{
Expand Down
39 changes: 21 additions & 18 deletions docs/docs/20-usage/20-pipeline-syntax.md
Original file line number Diff line number Diff line change
Expand Up @@ -452,7 +452,7 @@ Run on pushes to the default branch for the repository `owner/repo`:

```yaml
when:
- evaluate: 'CI_PIPELINE_EVENT == "push" && CI_REPO == "owner/repo" && CI_COMMIT_BRANCH == CI_REPO_DEFAULT_BRANCH'
- evaluate: 'CI_BUILD_EVENT == "push" && CI_REPO == "owner/repo" && CI_COMMIT_BRANCH == CI_REPO_DEFAULT_BRANCH'
```

Run on commits created by user `woodpecker-ci`:
Expand Down Expand Up @@ -603,6 +603,26 @@ Woodpecker has integrated support for matrix builds. Woodpecker executes a separ

For more details check the [matrix build docs](./30-matrix-workflows.md).

## `platform`

To configure your pipeline to only be executed on an agent with a specific platform, you can use the `platform` key.
Have a look at the official [go docs](https://go.dev/doc/install/source) for the available platforms. The syntax of the platform is `GOOS/GOARCH` like `linux/arm64` or `linux/amd64`.

Example:

Assuming we have two agents, one `arm` and one `amd64`. Previously this pipeline would have executed on **either agent**, as Woodpecker is not fussy about where it runs the pipelines. By setting the following option it will only be executed on an agent with the platform `linux/arm64`.

```diff
+platform: linux/arm64

steps:
build:
image: golang
commands:
- go build
- go test
```

## `labels`

You can set labels for your pipeline to select an agent to execute the pipeline on. An agent will pick up and run a pipeline when **every** label assigned to a pipeline matches the agents labels.
Expand All @@ -628,23 +648,6 @@ steps:
- go test
```

### Filter by platform

To configure your pipeline to only be executed on an agent with a specific platform, you can use the `platform` key.
Have a look at the official [go docs](https://go.dev/doc/install/source) for the available platforms. The syntax of the platform is `GOOS/GOARCH` like `linux/arm64` or `linux/amd64`.

Example:

Assuming we have two agents, one `linux/arm` and one `linux/amd64`. Previously this pipeline would have executed on **either agent**, as Woodpecker is not fussy about where it runs the pipelines. By setting the following option it will only be executed on an agent with the platform `linux/arm64`.

```diff
+labels:
+ platform: linux/arm64

steps:
[...]
```

## `variables`

Woodpecker supports [YAML anchors & aliases](https://yaml.org/spec/1.2.2/#3222-anchors-and-aliases) in the pipeline configuration. These can be used as variables to not repeat yourself.
Expand Down
4 changes: 2 additions & 2 deletions docs/docs/20-usage/50-environment.md
Original file line number Diff line number Diff line change
Expand Up @@ -66,8 +66,8 @@ This is the reference list of all environment variables available to your pipeli
| `CI_COMMIT_REF` | commit ref |
| `CI_COMMIT_REFSPEC` | commit ref spec |
| `CI_COMMIT_BRANCH` | commit branch (equals target branch for pull requests) |
| `CI_COMMIT_SOURCE_BRANCH` | commit source branch (empty if event is not `pull_request`) |
| `CI_COMMIT_TARGET_BRANCH` | commit target branch (empty if event is not `pull_request`) |
| `CI_COMMIT_SOURCE_BRANCH` | commit source branch |
| `CI_COMMIT_TARGET_BRANCH` | commit target branch |
| `CI_COMMIT_TAG` | commit tag name (empty if event is not `tag`) |
| `CI_COMMIT_PULL_REQUEST` | commit pull request number (empty if event is not `pull_request`) |
| `CI_COMMIT_PULL_REQUEST_LABELS` | labels assigned to pull request (empty if event is not `pull_request`) |
Expand Down
2 changes: 1 addition & 1 deletion docs/docs/30-administration/22-backends/40-kubernetes.md
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ See the [kubernetes documentation](https://kubernetes.io/docs/concepts/security/
### nodeSelector

Specify the label which is used to select the node where the job should be executed. Labels defined here will be appended to a list already containing "kubernetes.io/arch".
By default the pod will use "kubernetes.io/arch" inferred from top-level "platform" setting which is deducted from the agents' environment variable CI_SYSTEM_PLATFORM. To overwrite this, you need to specify this label in the nodeSelector section.
By default the pod will use "kubernetes.io/arch" inferred from top-level "platform" setting which is deducted from the agents' environment variable CI_SYSTEM_ARCH. To overwrite this, you need to specify this label in the nodeSelector section.
See the [kubernetes documentation](https://kubernetes.io/docs/concepts/scheduling-eviction/assign-pod-node/#nodeselector) for more information on using nodeSelector.

### tolerations
Expand Down
7 changes: 2 additions & 5 deletions docs/docs/91-migrations.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,9 @@

Some versions need some changes to the server configuration or the pipeline configuration files.

## next (1.1.0)
## next

- Drop deprecated `CI_BUILD_*`, `CI_PREV_BUILD_*`, `CI_JOB_*`, `*_LINK`, `CI_SYSTEM_ARCH`, `CI_REPO_REMOTE` built-in environment variables
- Drop deprecated `pipeline:` keyword for steps in yaml config
- Drop deprecated `branches:` keyword for global branch filter
- Deprecate `platform:` filter in favor of `labels:`, [read more](./20-usage/20-pipeline-syntax.md#filter-by-platform)
No breaking changes

## 1.0.0

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -459,7 +459,7 @@ Run on pushes to the default branch for the repository `owner/repo`:

```yaml
when:
- evaluate: 'CI_PIPELINE_EVENT == "push" && CI_REPO == "owner/repo" && CI_COMMIT_BRANCH == CI_REPO_DEFAULT_BRANCH'
- evaluate: 'CI_BUILD_EVENT == "push" && CI_REPO == "owner/repo" && CI_COMMIT_BRANCH == CI_REPO_DEFAULT_BRANCH'
```

Run on commits created by user `woodpecker-ci`:
Expand Down Expand Up @@ -612,10 +612,6 @@ For more details check the [matrix build docs](./30-matrix-workflows.md).

## `platform`

:::warning
will be deprecated with v1.1.0 in favor of labels.
:::

To configure your pipeline to only be executed on an agent with a specific platform, you can use the `platform` key.
Have a look at the official [go docs](https://go.dev/doc/install/source) for the available platforms. The syntax of the platform is `GOOS/GOARCH` like `linux/arm64` or `linux/amd64`.

Expand Down
4 changes: 2 additions & 2 deletions docs/versioned_docs/version-1.0/20-usage/50-environment.md
Original file line number Diff line number Diff line change
Expand Up @@ -65,8 +65,8 @@ This is the reference list of all environment variables available to your pipeli
| `CI_COMMIT_REF` | commit ref |
| `CI_COMMIT_REFSPEC` | commit ref spec |
| `CI_COMMIT_BRANCH` | commit branch (equals target branch for pull requests) |
| `CI_COMMIT_SOURCE_BRANCH` | commit source branch (empty if event is not `pull_request`) |
| `CI_COMMIT_TARGET_BRANCH` | commit target branch (empty if event is not `pull_request`) |
| `CI_COMMIT_SOURCE_BRANCH` | commit source branch |
| `CI_COMMIT_TARGET_BRANCH` | commit target branch |
| `CI_COMMIT_TAG` | commit tag name (empty if event is not `tag`) |
| `CI_COMMIT_PULL_REQUEST` | commit pull request number (empty if event is not `pull_request`) |
| `CI_COMMIT_PULL_REQUEST_LABELS` | labels assigned to pull request (empty if event is not `pull_request`) |
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ See the [kubernetes documentation](https://kubernetes.io/docs/concepts/security/
### nodeSelector

Specify the label which is used to select the node where the job should be executed. Labels defined here will be appended to a list already containing "kubernetes.io/arch".
By default the pod will use "kubernetes.io/arch" inferred from top-level "platform" setting which is deducted from the agents' environment variable CI_SYSTEM_PLATFORM. To overwrite this, you need to specify this label in the nodeSelector section.
By default the pod will use "kubernetes.io/arch" inferred from top-level "platform" setting which is deducted from the agents' environment variable CI_SYSTEM_ARCH. To overwrite this, you need to specify this label in the nodeSelector section.
See the [kubernetes documentation](https://kubernetes.io/docs/concepts/scheduling-eviction/assign-pod-node/#nodeselector) for more information on using nodeSelector.

Example pipeline configuration:
Expand Down
2 changes: 1 addition & 1 deletion pipeline/backend/kubernetes/pod.go
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ func Pod(namespace string, step *types.Step, labels, annotations map[string]stri
labels["step"] = podName

var nodeSelector map[string]string
platform, exist := step.Environment["CI_SYSTEM_PLATFORM"]
platform, exist := step.Environment["CI_SYSTEM_ARCH"]
if exist && platform != "" {
arch := strings.Split(platform, "/")[1]
nodeSelector = map[string]string{v1.LabelArchStable: arch}
Expand Down
26 changes: 25 additions & 1 deletion pipeline/frontend/metadata/drone_compatibility_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,48 +24,72 @@ import (

func TestSetDroneEnviron(t *testing.T) {
woodpeckerVars := `CI=woodpecker
CI_BUILD_CREATED=1685749339
CI_BUILD_EVENT=pull_request
CI_BUILD_FINISHED=1685749350
CI_BUILD_LINK=https://codeberg.org/Epsilon_02/todo-checker/pulls/9
CI_BUILD_NUMBER=41
CI_BUILD_STARTED=1685749339
CI_BUILD_STATUS=success
CI_COMMIT_AUTHOR=6543
CI_COMMIT_AUTHOR_AVATAR=https://codeberg.org/avatars/09a234c768cb9bca78f6b2f82d6af173
CI_COMMIT_BRANCH=main
CI_COMMIT_LINK=https://codeberg.org/Epsilon_02/todo-checker/pulls/9
CI_COMMIT_MESSAGE=fix testscript
CI_COMMIT_PULL_REQUEST=9
CI_COMMIT_REF=refs/pull/9/head
CI_COMMIT_REFSPEC=fix_fail-on-err:main
CI_COMMIT_SHA=a778b069d9f5992786d2db9be493b43868cfce76
CI_COMMIT_SOURCE_BRANCH=fix_fail-on-err
CI_COMMIT_TARGET_BRANCH=main
CI_JOB_FINISHED=1685749350
CI_JOB_STARTED=1685749339
CI_JOB_STATUS=success
CI_MACHINE=7939910e431b
CI_PIPELINE_CREATED=1685749339
CI_PIPELINE_EVENT=pull_request
CI_PIPELINE_FINISHED=1685749350
CI_PIPELINE_LINK=https://codeberg.org/Epsilon_02/todo-checker/pulls/9
CI_PIPELINE_NUMBER=41
CI_PIPELINE_STARTED=1685749339
CI_PIPELINE_STATUS=success
CI_PREV_BUILD_CREATED=1685748680
CI_PREV_BUILD_EVENT=pull_request
CI_PREV_BUILD_FINISHED=1685748704
CI_PREV_BUILD_LINK=https://codeberg.org/Epsilon_02/todo-checker/pulls/13
CI_PREV_BUILD_NUMBER=40
CI_PREV_BUILD_STARTED=1685748680
CI_PREV_BUILD_STATUS=success
CI_PREV_COMMIT_AUTHOR=6543
CI_PREV_COMMIT_AUTHOR_AVATAR=https://codeberg.org/avatars/09a234c768cb9bca78f6b2f82d6af173
CI_PREV_COMMIT_BRANCH=main
CI_PREV_COMMIT_LINK=https://codeberg.org/Epsilon_02/todo-checker/pulls/13
CI_PREV_COMMIT_MESSAGE=Print filename and linenuber on fail
CI_PREV_COMMIT_REF=refs/pull/13/head
CI_PREV_COMMIT_REFSPEC=print_file_and_line:main
CI_PREV_COMMIT_SHA=e246aff5a9466df2e522efc9007823a7496d9d41
CI_PREV_PIPELINE_CREATED=1685748680
CI_PREV_PIPELINE_EVENT=pull_request
CI_PREV_PIPELINE_FINISHED=1685748704
CI_PREV_PIPELINE_LINK=https://codeberg.org/Epsilon_02/todo-checker/pulls/13
CI_PREV_PIPELINE_NUMBER=40
CI_PREV_PIPELINE_STARTED=1685748680
CI_PREV_PIPELINE_STATUS=success
CI_REPO=Epsilon_02/todo-checker
CI_REPO_CLONE_URL=https://codeberg.org/Epsilon_02/todo-checker.git
CI_REPO_DEFAULT_BRANCH=main
CI_REPO_LINK=https://codeberg.org/Epsilon_02/todo-checker
CI_REPO_NAME=todo-checker
CI_REPO_OWNER=Epsilon_02
CI_REPO_REMOTE=https://codeberg.org/Epsilon_02/todo-checker.git
CI_REPO_SCM=git
CI_STEP_FINISHED=1685749350
CI_STEP_NAME=wp_01h1z7v5d1tskaqjexw0ng6w7d_0_step_3
CI_STEP_STARTED=1685749339
CI_STEP_STATUS=success
CI_SYSTEM_PLATFORM=linux/amd64
CI_SYSTEM_ARCH=linux/amd64
CI_SYSTEM_HOST=ci.codeberg.org
CI_SYSTEM_LINK=https://ci.codeberg.org
CI_SYSTEM_NAME=woodpecker
CI_SYSTEM_VERSION=next-dd644da3
CI_WORKFLOW_NAME=woodpecker
Expand Down
37 changes: 37 additions & 0 deletions pipeline/frontend/metadata/environment.go
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,43 @@ func (m *Metadata) Environ() map[string]string {

"CI_FORGE_TYPE": m.Forge.Type,
"CI_FORGE_URL": m.Forge.URL,

// DEPRECATED
"CI_SYSTEM_ARCH": m.Sys.Platform, // TODO: remove after v1.0.x version
// use CI_PIPELINE_*
"CI_BUILD_NUMBER": strconv.FormatInt(m.Curr.Number, 10),
"CI_BUILD_PARENT": strconv.FormatInt(m.Curr.Parent, 10),
"CI_BUILD_EVENT": m.Curr.Event,
"CI_BUILD_LINK": m.Curr.Link,
"CI_BUILD_DEPLOY_TARGET": m.Curr.Target,
"CI_BUILD_STATUS": m.Curr.Status,
"CI_BUILD_CREATED": strconv.FormatInt(m.Curr.Created, 10),
"CI_BUILD_STARTED": strconv.FormatInt(m.Curr.Started, 10),
"CI_BUILD_FINISHED": strconv.FormatInt(m.Curr.Finished, 10),
// use CI_PREV_PIPELINE_*
"CI_PREV_BUILD_NUMBER": strconv.FormatInt(m.Prev.Number, 10),
"CI_PREV_BUILD_PARENT": strconv.FormatInt(m.Prev.Parent, 10),
"CI_PREV_BUILD_EVENT": m.Prev.Event,
"CI_PREV_BUILD_LINK": m.Prev.Link,
"CI_PREV_BUILD_DEPLOY_TARGET": m.Prev.Target,
"CI_PREV_BUILD_STATUS": m.Prev.Status,
"CI_PREV_BUILD_CREATED": strconv.FormatInt(m.Prev.Created, 10),
"CI_PREV_BUILD_STARTED": strconv.FormatInt(m.Prev.Started, 10),
"CI_PREV_BUILD_FINISHED": strconv.FormatInt(m.Prev.Finished, 10),
// use CI_STEP_*
"CI_JOB_NUMBER": strconv.Itoa(m.Step.Number),
"CI_JOB_STATUS": "", // will be set by agent
"CI_JOB_STARTED": "", // will be set by agent
"CI_JOB_FINISHED": "", // will be set by agent
// CI_REPO_CLONE_URL
"CI_REPO_REMOTE": m.Repo.CloneURL,
// use *_URL
"CI_REPO_LINK": m.Repo.Link,
"CI_COMMIT_LINK": m.Curr.Link,
"CI_PIPELINE_LINK": m.Curr.Link,
"CI_PREV_COMMIT_LINK": m.Prev.Link,
"CI_PREV_PIPELINE_LINK": m.Prev.Link,
"CI_SYSTEM_LINK": m.Sys.Link,
}
if m.Curr.Event == EventTag {
params["CI_COMMIT_TAG"] = strings.TrimPrefix(m.Curr.Commit.Ref, "refs/tags/")
Expand Down
Loading