mirror of
https://github.com/woodpecker-ci/woodpecker.git
synced 2024-11-22 01:41:02 +00:00
Remove some ci environment variables (#3846)
Co-authored-by: qwerty287 <80460567+qwerty287@users.noreply.github.com>
This commit is contained in:
parent
0fc113364a
commit
38ed7f9efd
9 changed files with 23 additions and 65 deletions
|
@ -72,21 +72,12 @@ func (r *Runner) createTracer(ctxMeta context.Context, uploads *sync.WaitGroup,
|
||||||
// TODO: find better way to update this state and move it to pipeline to have the same env in cli-exec
|
// 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_MACHINE"] = r.hostname
|
||||||
|
|
||||||
state.Pipeline.Step.Environment["CI_PIPELINE_STATUS"] = "success"
|
|
||||||
state.Pipeline.Step.Environment["CI_PIPELINE_STARTED"] = strconv.FormatInt(state.Pipeline.Started, 10)
|
state.Pipeline.Step.Environment["CI_PIPELINE_STARTED"] = strconv.FormatInt(state.Pipeline.Started, 10)
|
||||||
state.Pipeline.Step.Environment["CI_PIPELINE_FINISHED"] = strconv.FormatInt(time.Now().Unix(), 10)
|
|
||||||
|
|
||||||
state.Pipeline.Step.Environment["CI_STEP_STATUS"] = "success"
|
|
||||||
state.Pipeline.Step.Environment["CI_STEP_STARTED"] = strconv.FormatInt(state.Pipeline.Started, 10)
|
state.Pipeline.Step.Environment["CI_STEP_STARTED"] = strconv.FormatInt(state.Pipeline.Started, 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_PLATFORM"] = runtime.GOOS + "/" + runtime.GOARCH
|
||||||
|
|
||||||
if state.Pipeline.Error != nil {
|
|
||||||
state.Pipeline.Step.Environment["CI_PIPELINE_STATUS"] = "failure"
|
|
||||||
state.Pipeline.Step.Environment["CI_STEP_STATUS"] = "failure"
|
|
||||||
}
|
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -181,14 +181,6 @@ var flags = []cli.Flag{
|
||||||
Sources: cli.EnvVars("CI_PIPELINE_STARTED"),
|
Sources: cli.EnvVars("CI_PIPELINE_STARTED"),
|
||||||
Name: "pipeline-started",
|
Name: "pipeline-started",
|
||||||
},
|
},
|
||||||
&cli.IntFlag{
|
|
||||||
Sources: cli.EnvVars("CI_PIPELINE_FINISHED"),
|
|
||||||
Name: "pipeline-finished",
|
|
||||||
},
|
|
||||||
&cli.StringFlag{
|
|
||||||
Sources: cli.EnvVars("CI_PIPELINE_STATUS"),
|
|
||||||
Name: "pipeline-status",
|
|
||||||
},
|
|
||||||
&cli.StringFlag{
|
&cli.StringFlag{
|
||||||
Sources: cli.EnvVars("CI_PIPELINE_EVENT"),
|
Sources: cli.EnvVars("CI_PIPELINE_EVENT"),
|
||||||
Name: "pipeline-event",
|
Name: "pipeline-event",
|
||||||
|
|
|
@ -86,19 +86,15 @@ This is the reference list of all environment variables available to your pipeli
|
||||||
| `CI_PIPELINE_FORGE_URL` | link to the forge's web UI for the commit(s) or tag that triggered the pipeline | `https://git.example.com/john-doe/my-repo/commit/eba09b46064473a1d345da7abf28b477468e8dbd` |
|
| `CI_PIPELINE_FORGE_URL` | link to the forge's web UI for the commit(s) or tag that triggered the pipeline | `https://git.example.com/john-doe/my-repo/commit/eba09b46064473a1d345da7abf28b477468e8dbd` |
|
||||||
| `CI_PIPELINE_DEPLOY_TARGET` | pipeline deploy target for `deployment` events | `production` |
|
| `CI_PIPELINE_DEPLOY_TARGET` | pipeline deploy target for `deployment` events | `production` |
|
||||||
| `CI_PIPELINE_DEPLOY_TASK` | pipeline deploy task for `deployment` events | `migration` |
|
| `CI_PIPELINE_DEPLOY_TASK` | pipeline deploy task for `deployment` events | `migration` |
|
||||||
| `CI_PIPELINE_STATUS` | pipeline status | `success`, `failure` |
|
|
||||||
| `CI_PIPELINE_CREATED` | pipeline created UNIX timestamp | `1722617519` |
|
| `CI_PIPELINE_CREATED` | pipeline created UNIX timestamp | `1722617519` |
|
||||||
| `CI_PIPELINE_STARTED` | pipeline started UNIX timestamp | `1722617519` |
|
| `CI_PIPELINE_STARTED` | pipeline started UNIX timestamp | `1722617519` |
|
||||||
| `CI_PIPELINE_FINISHED` | pipeline finished UNIX timestamp | `1722617522` |
|
|
||||||
| `CI_PIPELINE_FILES` | changed files (empty if event is not `push` or `pull_request`), it is undefined if more than 500 files are touched | `[]`, `[".woodpecker.yml","README.md"]` |
|
| `CI_PIPELINE_FILES` | changed files (empty if event is not `push` or `pull_request`), it is undefined if more than 500 files are touched | `[]`, `[".woodpecker.yml","README.md"]` |
|
||||||
| | **Current workflow** | |
|
| | **Current workflow** | |
|
||||||
| `CI_WORKFLOW_NAME` | workflow name | `release` |
|
| `CI_WORKFLOW_NAME` | workflow name | `release` |
|
||||||
| | **Current step** | |
|
| | **Current step** | |
|
||||||
| `CI_STEP_NAME` | step name | `build package` |
|
| `CI_STEP_NAME` | step name | `build package` |
|
||||||
| `CI_STEP_NUMBER` | step number | `0` |
|
| `CI_STEP_NUMBER` | step number | `0` |
|
||||||
| `CI_STEP_STATUS` | step status | `success`, `failure` |
|
|
||||||
| `CI_STEP_STARTED` | step started UNIX timestamp | `1722617519` |
|
| `CI_STEP_STARTED` | step started UNIX timestamp | `1722617519` |
|
||||||
| `CI_STEP_FINISHED` | step finished UNIX timestamp | `1722617522` |
|
|
||||||
| `CI_STEP_URL` | URL to step in UI | `https://ci.example.com/repos/7/pipeline/8` |
|
| `CI_STEP_URL` | URL to step in UI | `https://ci.example.com/repos/7/pipeline/8` |
|
||||||
| | **Previous commit** | |
|
| | **Previous commit** | |
|
||||||
| `CI_PREV_COMMIT_SHA` | previous commit SHA | `15784117e4e103f36cba75a9e29da48046eb82c4` |
|
| `CI_PREV_COMMIT_SHA` | previous commit SHA | `15784117e4e103f36cba75a9e29da48046eb82c4` |
|
||||||
|
|
|
@ -4,6 +4,12 @@ Some versions need some changes to the server configuration or the pipeline conf
|
||||||
|
|
||||||
## `next`
|
## `next`
|
||||||
|
|
||||||
|
- Removed built-in environment variables:
|
||||||
|
- `CI_COMMIT_URL` use `CI_PIPELINE_FORGE_URL`
|
||||||
|
- `CI_STEP_FINISHED` as empty during execution
|
||||||
|
- `CI_PIPELINE_FINISHED` as empty during execution
|
||||||
|
- `CI_PIPELINE_STATUS` was always `success`
|
||||||
|
- `CI_STEP_STATUS` was always `success`
|
||||||
- Rename server environment variable `WOODPECKER_ESCALATE` to `WOODPECKER_PLUGINS_PRIVILEGED`
|
- Rename server environment variable `WOODPECKER_ESCALATE` to `WOODPECKER_PLUGINS_PRIVILEGED`
|
||||||
- All default privileged plugins (like `woodpeckerci/plugin-docker-buildx`) were removed. Please carefully [re-add those plugins](./30-administration/10-server-config.md#woodpecker_plugins_privileged) you trust and rely on.
|
- All default privileged plugins (like `woodpeckerci/plugin-docker-buildx`) were removed. Please carefully [re-add those plugins](./30-administration/10-server-config.md#woodpecker_plugins_privileged) you trust and rely on.
|
||||||
- `WOODPECKER_DEFAULT_CLONE_IMAGE` got depricated use `WOODPECKER_DEFAULT_CLONE_PLUGIN`
|
- `WOODPECKER_DEFAULT_CLONE_IMAGE` got depricated use `WOODPECKER_DEFAULT_CLONE_PLUGIN`
|
||||||
|
|
|
@ -28,18 +28,16 @@ func SetDroneEnviron(env map[string]string) {
|
||||||
copyEnv("CI_PIPELINE_NUMBER", "DRONE_BUILD_NUMBER", env)
|
copyEnv("CI_PIPELINE_NUMBER", "DRONE_BUILD_NUMBER", env)
|
||||||
copyEnv("CI_PIPELINE_PARENT", "DRONE_BUILD_PARENT", env)
|
copyEnv("CI_PIPELINE_PARENT", "DRONE_BUILD_PARENT", env)
|
||||||
copyEnv("CI_PIPELINE_EVENT", "DRONE_BUILD_EVENT", env)
|
copyEnv("CI_PIPELINE_EVENT", "DRONE_BUILD_EVENT", env)
|
||||||
copyEnv("CI_PIPELINE_STATUS", "DRONE_BUILD_STATUS", env)
|
|
||||||
copyEnv("CI_PIPELINE_URL", "DRONE_BUILD_LINK", env)
|
copyEnv("CI_PIPELINE_URL", "DRONE_BUILD_LINK", env)
|
||||||
copyEnv("CI_PIPELINE_CREATED", "DRONE_BUILD_CREATED", env)
|
copyEnv("CI_PIPELINE_CREATED", "DRONE_BUILD_CREATED", env)
|
||||||
copyEnv("CI_PIPELINE_STARTED", "DRONE_BUILD_STARTED", env)
|
copyEnv("CI_PIPELINE_STARTED", "DRONE_BUILD_STARTED", env)
|
||||||
copyEnv("CI_PIPELINE_FINISHED", "DRONE_BUILD_FINISHED", env)
|
|
||||||
// commit
|
// commit
|
||||||
copyEnv("CI_COMMIT_SHA", "DRONE_COMMIT", env)
|
copyEnv("CI_COMMIT_SHA", "DRONE_COMMIT", env)
|
||||||
copyEnv("CI_COMMIT_SHA", "DRONE_COMMIT_SHA", env)
|
copyEnv("CI_COMMIT_SHA", "DRONE_COMMIT_SHA", env)
|
||||||
copyEnv("CI_PREV_COMMIT_SHA", "DRONE_COMMIT_BEFORE", env)
|
copyEnv("CI_PREV_COMMIT_SHA", "DRONE_COMMIT_BEFORE", env)
|
||||||
copyEnv("CI_COMMIT_REF", "DRONE_COMMIT_REF", env)
|
copyEnv("CI_COMMIT_REF", "DRONE_COMMIT_REF", env)
|
||||||
copyEnv("CI_COMMIT_BRANCH", "DRONE_COMMIT_BRANCH", env)
|
copyEnv("CI_COMMIT_BRANCH", "DRONE_COMMIT_BRANCH", env)
|
||||||
copyEnv("CI_COMMIT_URL", "DRONE_COMMIT_LINK", env)
|
copyEnv("CI_PIPELINE_FORGE_URL", "DRONE_COMMIT_LINK", env)
|
||||||
copyEnv("CI_COMMIT_MESSAGE", "DRONE_COMMIT_MESSAGE", env)
|
copyEnv("CI_COMMIT_MESSAGE", "DRONE_COMMIT_MESSAGE", env)
|
||||||
copyEnv("CI_COMMIT_AUTHOR", "DRONE_COMMIT_AUTHOR", env)
|
copyEnv("CI_COMMIT_AUTHOR", "DRONE_COMMIT_AUTHOR", env)
|
||||||
copyEnv("CI_COMMIT_AUTHOR", "DRONE_COMMIT_AUTHOR_NAME", env)
|
copyEnv("CI_COMMIT_AUTHOR", "DRONE_COMMIT_AUTHOR_NAME", env)
|
||||||
|
@ -60,6 +58,8 @@ func SetDroneEnviron(env map[string]string) {
|
||||||
copyEnv("CI_SYSTEM_HOST", "DRONE_SYSTEM_HOST", env)
|
copyEnv("CI_SYSTEM_HOST", "DRONE_SYSTEM_HOST", env)
|
||||||
copyEnv("CI_STEP_NUMBER", "DRONE_STEP_NUMBER", env)
|
copyEnv("CI_STEP_NUMBER", "DRONE_STEP_NUMBER", env)
|
||||||
|
|
||||||
|
env["DRONE_BUILD_STATUS"] = "success"
|
||||||
|
|
||||||
// some quirks
|
// some quirks
|
||||||
|
|
||||||
// Legacy env var to prevent the plugin from throwing an error
|
// Legacy env var to prevent the plugin from throwing an error
|
||||||
|
|
|
@ -39,10 +39,8 @@ CI_COMMIT_TARGET_BRANCH=main
|
||||||
CI_MACHINE=7939910e431b
|
CI_MACHINE=7939910e431b
|
||||||
CI_PIPELINE_CREATED=1685749339
|
CI_PIPELINE_CREATED=1685749339
|
||||||
CI_PIPELINE_EVENT=pull_request
|
CI_PIPELINE_EVENT=pull_request
|
||||||
CI_PIPELINE_FINISHED=1685749350
|
|
||||||
CI_PIPELINE_NUMBER=41
|
CI_PIPELINE_NUMBER=41
|
||||||
CI_PIPELINE_STARTED=1685749339
|
CI_PIPELINE_STARTED=1685749339
|
||||||
CI_PIPELINE_STATUS=success
|
|
||||||
CI_PREV_COMMIT_AUTHOR=6543
|
CI_PREV_COMMIT_AUTHOR=6543
|
||||||
CI_PREV_COMMIT_AUTHOR_AVATAR=https://codeberg.org/avatars/09a234c768cb9bca78f6b2f82d6af173
|
CI_PREV_COMMIT_AUTHOR_AVATAR=https://codeberg.org/avatars/09a234c768cb9bca78f6b2f82d6af173
|
||||||
CI_PREV_COMMIT_BRANCH=main
|
CI_PREV_COMMIT_BRANCH=main
|
||||||
|
@ -62,10 +60,8 @@ CI_REPO_DEFAULT_BRANCH=main
|
||||||
CI_REPO_NAME=todo-checker
|
CI_REPO_NAME=todo-checker
|
||||||
CI_REPO_OWNER=Epsilon_02
|
CI_REPO_OWNER=Epsilon_02
|
||||||
CI_REPO_SCM=git
|
CI_REPO_SCM=git
|
||||||
CI_STEP_FINISHED=1685749350
|
|
||||||
CI_STEP_NAME=wp_01h1z7v5d1tskaqjexw0ng6w7d_0_step_3
|
CI_STEP_NAME=wp_01h1z7v5d1tskaqjexw0ng6w7d_0_step_3
|
||||||
CI_STEP_STARTED=1685749339
|
CI_STEP_STARTED=1685749339
|
||||||
CI_STEP_STATUS=success
|
|
||||||
CI_SYSTEM_PLATFORM=linux/amd64
|
CI_SYSTEM_PLATFORM=linux/amd64
|
||||||
CI_SYSTEM_HOST=ci.codeberg.org
|
CI_SYSTEM_HOST=ci.codeberg.org
|
||||||
CI_SYSTEM_NAME=woodpecker
|
CI_SYSTEM_NAME=woodpecker
|
||||||
|
@ -77,7 +73,6 @@ CI_WORKSPACE=/woodpecker/src/codeberg.org/Epsilon_02/todo-checker`
|
||||||
droneVars := `DRONE_BRANCH=main
|
droneVars := `DRONE_BRANCH=main
|
||||||
DRONE_BUILD_CREATED=1685749339
|
DRONE_BUILD_CREATED=1685749339
|
||||||
DRONE_BUILD_EVENT=pull_request
|
DRONE_BUILD_EVENT=pull_request
|
||||||
DRONE_BUILD_FINISHED=1685749350
|
|
||||||
DRONE_BUILD_NUMBER=41
|
DRONE_BUILD_NUMBER=41
|
||||||
DRONE_BUILD_STARTED=1685749339
|
DRONE_BUILD_STARTED=1685749339
|
||||||
DRONE_BUILD_STATUS=success
|
DRONE_BUILD_STATUS=success
|
||||||
|
@ -126,7 +121,6 @@ CI_COMMIT_SHA=8826c98181353075bbeee8f99b400496488e3523
|
||||||
CI_COMMIT_SOURCE_BRANCH=
|
CI_COMMIT_SOURCE_BRANCH=
|
||||||
CI_COMMIT_TAG=
|
CI_COMMIT_TAG=
|
||||||
CI_COMMIT_TARGET_BRANCH=
|
CI_COMMIT_TARGET_BRANCH=
|
||||||
CI_COMMIT_URL=http://1.2.3.4:3000/test/woodpecker-test/commit/8826c98181353075bbeee8f99b400496488e3523
|
|
||||||
CI_FORGE_TYPE=gitea
|
CI_FORGE_TYPE=gitea
|
||||||
CI_FORGE_URL=http://1.2.3.4:3000
|
CI_FORGE_URL=http://1.2.3.4:3000
|
||||||
CI_MACHINE=hagalaz
|
CI_MACHINE=hagalaz
|
||||||
|
@ -135,12 +129,10 @@ CI_PIPELINE_DEPLOY_TARGET=
|
||||||
CI_PIPELINE_DEPLOY_TASK=
|
CI_PIPELINE_DEPLOY_TASK=
|
||||||
CI_PIPELINE_EVENT=push
|
CI_PIPELINE_EVENT=push
|
||||||
CI_PIPELINE_FILES=[".woodpecker.yaml"]
|
CI_PIPELINE_FILES=[".woodpecker.yaml"]
|
||||||
CI_PIPELINE_FINISHED=1721328738
|
|
||||||
CI_PIPELINE_FORGE_URL=http://1.2.3.4:3000/test/woodpecker-test/commit/8826c98181353075bbeee8f99b400496488e3523
|
CI_PIPELINE_FORGE_URL=http://1.2.3.4:3000/test/woodpecker-test/commit/8826c98181353075bbeee8f99b400496488e3523
|
||||||
CI_PIPELINE_NUMBER=24
|
CI_PIPELINE_NUMBER=24
|
||||||
CI_PIPELINE_PARENT=23
|
CI_PIPELINE_PARENT=23
|
||||||
CI_PIPELINE_STARTED=1721328737
|
CI_PIPELINE_STARTED=1721328737
|
||||||
CI_PIPELINE_STATUS=success
|
|
||||||
CI_PIPELINE_URL=http://1.2.3.4:8000/repos/2/pipeline/24
|
CI_PIPELINE_URL=http://1.2.3.4:8000/repos/2/pipeline/24
|
||||||
CI_PREV_COMMIT_AUTHOR=test
|
CI_PREV_COMMIT_AUTHOR=test
|
||||||
CI_PREV_COMMIT_AUTHOR_AVATAR=http://1.2.3.4:3000/avatars/dd46a756faad4727fb679320751f6dea
|
CI_PREV_COMMIT_AUTHOR_AVATAR=http://1.2.3.4:3000/avatars/dd46a756faad4727fb679320751f6dea
|
||||||
|
@ -175,11 +167,9 @@ CI_REPO_REMOTE_ID=4
|
||||||
CI_REPO_SCM=git
|
CI_REPO_SCM=git
|
||||||
CI_REPO_TRUSTED=false
|
CI_REPO_TRUSTED=false
|
||||||
CI_REPO_URL=http://1.2.3.4:3000/test/woodpecker-test
|
CI_REPO_URL=http://1.2.3.4:3000/test/woodpecker-test
|
||||||
CI_STEP_FINISHED=1721328738
|
|
||||||
CI_STEP_NAME=
|
CI_STEP_NAME=
|
||||||
CI_STEP_NUMBER=0
|
CI_STEP_NUMBER=0
|
||||||
CI_STEP_STARTED=1721328737
|
CI_STEP_STARTED=1721328737
|
||||||
CI_STEP_STATUS=success
|
|
||||||
CI_STEP_URL=http://1.2.3.4:8000/repos/2/pipeline/24
|
CI_STEP_URL=http://1.2.3.4:8000/repos/2/pipeline/24
|
||||||
CI_SYSTEM_HOST=1.2.3.4:8000
|
CI_SYSTEM_HOST=1.2.3.4:8000
|
||||||
CI_SYSTEM_NAME=woodpecker
|
CI_SYSTEM_NAME=woodpecker
|
||||||
|
@ -193,7 +183,6 @@ CI_WORKSPACE=/usr/local/src/1.2.3.4/test/woodpecker-test`
|
||||||
droneVars := `DRONE_BRANCH=main
|
droneVars := `DRONE_BRANCH=main
|
||||||
DRONE_BUILD_CREATED=1721328737
|
DRONE_BUILD_CREATED=1721328737
|
||||||
DRONE_BUILD_EVENT=push
|
DRONE_BUILD_EVENT=push
|
||||||
DRONE_BUILD_FINISHED=1721328738
|
|
||||||
DRONE_BUILD_LINK=http://1.2.3.4:8000/repos/2/pipeline/24
|
DRONE_BUILD_LINK=http://1.2.3.4:8000/repos/2/pipeline/24
|
||||||
DRONE_BUILD_NUMBER=24
|
DRONE_BUILD_NUMBER=24
|
||||||
DRONE_BUILD_PARENT=23
|
DRONE_BUILD_PARENT=23
|
||||||
|
|
|
@ -85,20 +85,16 @@ func (m *Metadata) Environ() map[string]string {
|
||||||
"CI_PIPELINE_FORGE_URL": m.Curr.ForgeURL,
|
"CI_PIPELINE_FORGE_URL": m.Curr.ForgeURL,
|
||||||
"CI_PIPELINE_DEPLOY_TARGET": m.Curr.DeployTo,
|
"CI_PIPELINE_DEPLOY_TARGET": m.Curr.DeployTo,
|
||||||
"CI_PIPELINE_DEPLOY_TASK": m.Curr.DeployTask,
|
"CI_PIPELINE_DEPLOY_TASK": m.Curr.DeployTask,
|
||||||
"CI_PIPELINE_STATUS": m.Curr.Status,
|
|
||||||
"CI_PIPELINE_CREATED": strconv.FormatInt(m.Curr.Created, 10),
|
"CI_PIPELINE_CREATED": strconv.FormatInt(m.Curr.Created, 10),
|
||||||
"CI_PIPELINE_STARTED": strconv.FormatInt(m.Curr.Started, 10),
|
"CI_PIPELINE_STARTED": strconv.FormatInt(m.Curr.Started, 10),
|
||||||
"CI_PIPELINE_FINISHED": strconv.FormatInt(m.Curr.Finished, 10),
|
|
||||||
|
|
||||||
"CI_WORKFLOW_NAME": m.Workflow.Name,
|
"CI_WORKFLOW_NAME": m.Workflow.Name,
|
||||||
"CI_WORKFLOW_NUMBER": strconv.Itoa(m.Workflow.Number),
|
"CI_WORKFLOW_NUMBER": strconv.Itoa(m.Workflow.Number),
|
||||||
|
|
||||||
"CI_STEP_NAME": m.Step.Name,
|
"CI_STEP_NAME": m.Step.Name,
|
||||||
"CI_STEP_NUMBER": strconv.Itoa(m.Step.Number),
|
"CI_STEP_NUMBER": strconv.Itoa(m.Step.Number),
|
||||||
"CI_STEP_STATUS": "", // will be set by agent
|
"CI_STEP_STARTED": "", // will be set by agent
|
||||||
"CI_STEP_STARTED": "", // will be set by agent
|
"CI_STEP_URL": m.getPipelineWebURL(m.Curr, m.Step.Number),
|
||||||
"CI_STEP_FINISHED": "", // will be set by agent
|
|
||||||
"CI_STEP_URL": m.getPipelineWebURL(m.Curr, m.Step.Number),
|
|
||||||
|
|
||||||
"CI_PREV_COMMIT_SHA": m.Prev.Commit.Sha,
|
"CI_PREV_COMMIT_SHA": m.Prev.Commit.Sha,
|
||||||
"CI_PREV_COMMIT_REF": m.Prev.Commit.Ref,
|
"CI_PREV_COMMIT_REF": m.Prev.Commit.Ref,
|
||||||
|
@ -132,9 +128,6 @@ func (m *Metadata) Environ() map[string]string {
|
||||||
|
|
||||||
"CI_FORGE_TYPE": m.Forge.Type,
|
"CI_FORGE_TYPE": m.Forge.Type,
|
||||||
"CI_FORGE_URL": m.Forge.URL,
|
"CI_FORGE_URL": m.Forge.URL,
|
||||||
|
|
||||||
// TODO: Deprecated, remove in 3.x
|
|
||||||
"CI_COMMIT_URL": m.Curr.ForgeURL,
|
|
||||||
}
|
}
|
||||||
if m.Curr.Event == EventTag || m.Curr.Event == EventRelease || strings.HasPrefix(m.Curr.Commit.Ref, "refs/tags/") {
|
if m.Curr.Event == EventTag || m.Curr.Event == EventRelease || strings.HasPrefix(m.Curr.Commit.Ref, "refs/tags/") {
|
||||||
params["CI_COMMIT_TAG"] = strings.TrimPrefix(m.Curr.Commit.Ref, "refs/tags/")
|
params["CI_COMMIT_TAG"] = strings.TrimPrefix(m.Curr.Commit.Ref, "refs/tags/")
|
||||||
|
|
|
@ -16,7 +16,6 @@ package pipeline
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"strconv"
|
"strconv"
|
||||||
"time"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
// Tracer handles process tracing.
|
// Tracer handles process tracing.
|
||||||
|
@ -43,17 +42,9 @@ var DefaultTracer = TraceFunc(func(state *State) error {
|
||||||
if state.Pipeline.Step.Environment == nil {
|
if state.Pipeline.Step.Environment == nil {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
state.Pipeline.Step.Environment["CI_PIPELINE_STATUS"] = "success"
|
|
||||||
state.Pipeline.Step.Environment["CI_PIPELINE_STARTED"] = strconv.FormatInt(state.Pipeline.Started, 10)
|
state.Pipeline.Step.Environment["CI_PIPELINE_STARTED"] = strconv.FormatInt(state.Pipeline.Started, 10)
|
||||||
state.Pipeline.Step.Environment["CI_PIPELINE_FINISHED"] = strconv.FormatInt(time.Now().Unix(), 10)
|
|
||||||
|
|
||||||
state.Pipeline.Step.Environment["CI_STEP_STATUS"] = "success"
|
|
||||||
state.Pipeline.Step.Environment["CI_STEP_STARTED"] = strconv.FormatInt(state.Pipeline.Started, 10)
|
state.Pipeline.Step.Environment["CI_STEP_STARTED"] = strconv.FormatInt(state.Pipeline.Started, 10)
|
||||||
state.Pipeline.Step.Environment["CI_STEP_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"
|
|
||||||
}
|
|
||||||
return nil
|
return nil
|
||||||
})
|
})
|
||||||
|
|
|
@ -46,15 +46,15 @@ func TestMetadataFromStruct(t *testing.T) {
|
||||||
"CI": "woodpecker",
|
"CI": "woodpecker",
|
||||||
"CI_COMMIT_AUTHOR": "", "CI_COMMIT_AUTHOR_AVATAR": "", "CI_COMMIT_AUTHOR_EMAIL": "", "CI_COMMIT_BRANCH": "",
|
"CI_COMMIT_AUTHOR": "", "CI_COMMIT_AUTHOR_AVATAR": "", "CI_COMMIT_AUTHOR_EMAIL": "", "CI_COMMIT_BRANCH": "",
|
||||||
"CI_COMMIT_MESSAGE": "", "CI_COMMIT_PULL_REQUEST": "", "CI_COMMIT_PULL_REQUEST_LABELS": "", "CI_COMMIT_REF": "", "CI_COMMIT_REFSPEC": "", "CI_COMMIT_SHA": "", "CI_COMMIT_SOURCE_BRANCH": "",
|
"CI_COMMIT_MESSAGE": "", "CI_COMMIT_PULL_REQUEST": "", "CI_COMMIT_PULL_REQUEST_LABELS": "", "CI_COMMIT_REF": "", "CI_COMMIT_REFSPEC": "", "CI_COMMIT_SHA": "", "CI_COMMIT_SOURCE_BRANCH": "",
|
||||||
"CI_COMMIT_TAG": "", "CI_COMMIT_TARGET_BRANCH": "", "CI_COMMIT_URL": "", "CI_FORGE_TYPE": "", "CI_FORGE_URL": "",
|
"CI_COMMIT_TAG": "", "CI_COMMIT_TARGET_BRANCH": "", "CI_FORGE_TYPE": "", "CI_FORGE_URL": "",
|
||||||
"CI_PIPELINE_CREATED": "0", "CI_PIPELINE_DEPLOY_TARGET": "", "CI_PIPELINE_DEPLOY_TASK": "", "CI_PIPELINE_EVENT": "", "CI_PIPELINE_FINISHED": "0", "CI_PIPELINE_FILES": "[]", "CI_PIPELINE_NUMBER": "0",
|
"CI_PIPELINE_CREATED": "0", "CI_PIPELINE_DEPLOY_TARGET": "", "CI_PIPELINE_DEPLOY_TASK": "", "CI_PIPELINE_EVENT": "", "CI_PIPELINE_FILES": "[]", "CI_PIPELINE_NUMBER": "0",
|
||||||
"CI_PIPELINE_PARENT": "0", "CI_PIPELINE_STARTED": "0", "CI_PIPELINE_STATUS": "", "CI_PIPELINE_URL": "/repos/0/pipeline/0", "CI_PIPELINE_FORGE_URL": "",
|
"CI_PIPELINE_PARENT": "0", "CI_PIPELINE_STARTED": "0", "CI_PIPELINE_URL": "/repos/0/pipeline/0", "CI_PIPELINE_FORGE_URL": "",
|
||||||
"CI_PREV_COMMIT_AUTHOR": "", "CI_PREV_COMMIT_AUTHOR_AVATAR": "", "CI_PREV_COMMIT_AUTHOR_EMAIL": "", "CI_PREV_COMMIT_BRANCH": "", "CI_PREV_COMMIT_SOURCE_BRANCH": "", "CI_PREV_COMMIT_TARGET_BRANCH": "",
|
"CI_PREV_COMMIT_AUTHOR": "", "CI_PREV_COMMIT_AUTHOR_AVATAR": "", "CI_PREV_COMMIT_AUTHOR_EMAIL": "", "CI_PREV_COMMIT_BRANCH": "", "CI_PREV_COMMIT_SOURCE_BRANCH": "", "CI_PREV_COMMIT_TARGET_BRANCH": "",
|
||||||
"CI_PREV_COMMIT_MESSAGE": "", "CI_PREV_COMMIT_REF": "", "CI_PREV_COMMIT_REFSPEC": "", "CI_PREV_COMMIT_SHA": "", "CI_PREV_COMMIT_URL": "", "CI_PREV_PIPELINE_CREATED": "0",
|
"CI_PREV_COMMIT_MESSAGE": "", "CI_PREV_COMMIT_REF": "", "CI_PREV_COMMIT_REFSPEC": "", "CI_PREV_COMMIT_SHA": "", "CI_PREV_COMMIT_URL": "", "CI_PREV_PIPELINE_CREATED": "0",
|
||||||
"CI_PREV_PIPELINE_DEPLOY_TARGET": "", "CI_PREV_PIPELINE_DEPLOY_TASK": "", "CI_PREV_PIPELINE_EVENT": "", "CI_PREV_PIPELINE_FINISHED": "0", "CI_PREV_PIPELINE_NUMBER": "0", "CI_PREV_PIPELINE_PARENT": "0",
|
"CI_PREV_PIPELINE_DEPLOY_TARGET": "", "CI_PREV_PIPELINE_DEPLOY_TASK": "", "CI_PREV_PIPELINE_EVENT": "", "CI_PREV_PIPELINE_FINISHED": "0", "CI_PREV_PIPELINE_NUMBER": "0", "CI_PREV_PIPELINE_PARENT": "0",
|
||||||
"CI_PREV_PIPELINE_STARTED": "0", "CI_PREV_PIPELINE_STATUS": "", "CI_PREV_PIPELINE_URL": "/repos/0/pipeline/0", "CI_PREV_PIPELINE_FORGE_URL": "", "CI_REPO": "", "CI_REPO_CLONE_URL": "", "CI_REPO_CLONE_SSH_URL": "", "CI_REPO_DEFAULT_BRANCH": "", "CI_REPO_REMOTE_ID": "",
|
"CI_PREV_PIPELINE_STARTED": "0", "CI_PREV_PIPELINE_STATUS": "", "CI_PREV_PIPELINE_URL": "/repos/0/pipeline/0", "CI_PREV_PIPELINE_FORGE_URL": "", "CI_REPO": "", "CI_REPO_CLONE_URL": "", "CI_REPO_CLONE_SSH_URL": "", "CI_REPO_DEFAULT_BRANCH": "", "CI_REPO_REMOTE_ID": "",
|
||||||
"CI_REPO_NAME": "", "CI_REPO_OWNER": "", "CI_REPO_PRIVATE": "false", "CI_REPO_SCM": "git", "CI_REPO_TRUSTED": "false", "CI_REPO_URL": "", "CI_STEP_FINISHED": "",
|
"CI_REPO_NAME": "", "CI_REPO_OWNER": "", "CI_REPO_PRIVATE": "false", "CI_REPO_SCM": "git", "CI_REPO_TRUSTED": "false", "CI_REPO_URL": "",
|
||||||
"CI_STEP_NAME": "", "CI_STEP_NUMBER": "0", "CI_STEP_STARTED": "", "CI_STEP_STATUS": "", "CI_STEP_URL": "/repos/0/pipeline/0", "CI_SYSTEM_HOST": "", "CI_SYSTEM_NAME": "woodpecker",
|
"CI_STEP_NAME": "", "CI_STEP_NUMBER": "0", "CI_STEP_STARTED": "", "CI_STEP_URL": "/repos/0/pipeline/0", "CI_SYSTEM_HOST": "", "CI_SYSTEM_NAME": "woodpecker",
|
||||||
"CI_SYSTEM_PLATFORM": "", "CI_SYSTEM_URL": "", "CI_SYSTEM_VERSION": "", "CI_WORKFLOW_NAME": "", "CI_WORKFLOW_NUMBER": "0",
|
"CI_SYSTEM_PLATFORM": "", "CI_SYSTEM_URL": "", "CI_SYSTEM_VERSION": "", "CI_WORKFLOW_NAME": "", "CI_WORKFLOW_NUMBER": "0",
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
@ -81,16 +81,16 @@ func TestMetadataFromStruct(t *testing.T) {
|
||||||
"CI": "woodpecker",
|
"CI": "woodpecker",
|
||||||
"CI_COMMIT_AUTHOR": "", "CI_COMMIT_AUTHOR_AVATAR": "", "CI_COMMIT_AUTHOR_EMAIL": "", "CI_COMMIT_BRANCH": "",
|
"CI_COMMIT_AUTHOR": "", "CI_COMMIT_AUTHOR_AVATAR": "", "CI_COMMIT_AUTHOR_EMAIL": "", "CI_COMMIT_BRANCH": "",
|
||||||
"CI_COMMIT_MESSAGE": "", "CI_COMMIT_PULL_REQUEST": "", "CI_COMMIT_PULL_REQUEST_LABELS": "", "CI_COMMIT_REF": "", "CI_COMMIT_REFSPEC": "", "CI_COMMIT_SHA": "", "CI_COMMIT_SOURCE_BRANCH": "",
|
"CI_COMMIT_MESSAGE": "", "CI_COMMIT_PULL_REQUEST": "", "CI_COMMIT_PULL_REQUEST_LABELS": "", "CI_COMMIT_REF": "", "CI_COMMIT_REFSPEC": "", "CI_COMMIT_SHA": "", "CI_COMMIT_SOURCE_BRANCH": "",
|
||||||
"CI_COMMIT_TAG": "", "CI_COMMIT_TARGET_BRANCH": "", "CI_COMMIT_URL": "", "CI_FORGE_TYPE": "gitea", "CI_FORGE_URL": "https://gitea.com",
|
"CI_COMMIT_TAG": "", "CI_COMMIT_TARGET_BRANCH": "", "CI_FORGE_TYPE": "gitea", "CI_FORGE_URL": "https://gitea.com",
|
||||||
"CI_PIPELINE_CREATED": "0", "CI_PIPELINE_DEPLOY_TARGET": "", "CI_PIPELINE_DEPLOY_TASK": "", "CI_PIPELINE_EVENT": "", "CI_PIPELINE_FINISHED": "0", "CI_PIPELINE_FILES": `["test.go","markdown file.md"]`,
|
"CI_PIPELINE_CREATED": "0", "CI_PIPELINE_DEPLOY_TARGET": "", "CI_PIPELINE_DEPLOY_TASK": "", "CI_PIPELINE_EVENT": "", "CI_PIPELINE_FILES": `["test.go","markdown file.md"]`,
|
||||||
"CI_PIPELINE_NUMBER": "3", "CI_PIPELINE_PARENT": "0", "CI_PIPELINE_STARTED": "0", "CI_PIPELINE_STATUS": "", "CI_PIPELINE_URL": "https://example.com/repos/0/pipeline/3", "CI_PIPELINE_FORGE_URL": "",
|
"CI_PIPELINE_NUMBER": "3", "CI_PIPELINE_PARENT": "0", "CI_PIPELINE_STARTED": "0", "CI_PIPELINE_URL": "https://example.com/repos/0/pipeline/3", "CI_PIPELINE_FORGE_URL": "",
|
||||||
"CI_PREV_COMMIT_AUTHOR": "", "CI_PREV_COMMIT_AUTHOR_AVATAR": "", "CI_PREV_COMMIT_AUTHOR_EMAIL": "", "CI_PREV_COMMIT_BRANCH": "", "CI_PREV_COMMIT_SOURCE_BRANCH": "", "CI_PREV_COMMIT_TARGET_BRANCH": "",
|
"CI_PREV_COMMIT_AUTHOR": "", "CI_PREV_COMMIT_AUTHOR_AVATAR": "", "CI_PREV_COMMIT_AUTHOR_EMAIL": "", "CI_PREV_COMMIT_BRANCH": "", "CI_PREV_COMMIT_SOURCE_BRANCH": "", "CI_PREV_COMMIT_TARGET_BRANCH": "",
|
||||||
"CI_PREV_COMMIT_MESSAGE": "", "CI_PREV_COMMIT_REF": "", "CI_PREV_COMMIT_REFSPEC": "", "CI_PREV_COMMIT_SHA": "", "CI_PREV_COMMIT_URL": "", "CI_PREV_PIPELINE_CREATED": "0",
|
"CI_PREV_COMMIT_MESSAGE": "", "CI_PREV_COMMIT_REF": "", "CI_PREV_COMMIT_REFSPEC": "", "CI_PREV_COMMIT_SHA": "", "CI_PREV_COMMIT_URL": "", "CI_PREV_PIPELINE_CREATED": "0",
|
||||||
"CI_PREV_PIPELINE_DEPLOY_TARGET": "", "CI_PREV_PIPELINE_DEPLOY_TASK": "", "CI_PREV_PIPELINE_EVENT": "", "CI_PREV_PIPELINE_FINISHED": "0", "CI_PREV_PIPELINE_NUMBER": "2", "CI_PREV_PIPELINE_PARENT": "0",
|
"CI_PREV_PIPELINE_DEPLOY_TARGET": "", "CI_PREV_PIPELINE_DEPLOY_TASK": "", "CI_PREV_PIPELINE_EVENT": "", "CI_PREV_PIPELINE_FINISHED": "0", "CI_PREV_PIPELINE_NUMBER": "2", "CI_PREV_PIPELINE_PARENT": "0",
|
||||||
"CI_PREV_PIPELINE_STARTED": "0", "CI_PREV_PIPELINE_STATUS": "", "CI_PREV_PIPELINE_URL": "https://example.com/repos/0/pipeline/2", "CI_PREV_PIPELINE_FORGE_URL": "", "CI_REPO": "testUser/testRepo", "CI_REPO_CLONE_URL": "https://gitea.com/testUser/testRepo.git", "CI_REPO_CLONE_SSH_URL": "git@gitea.com:testUser/testRepo.git",
|
"CI_PREV_PIPELINE_STARTED": "0", "CI_PREV_PIPELINE_STATUS": "", "CI_PREV_PIPELINE_URL": "https://example.com/repos/0/pipeline/2", "CI_PREV_PIPELINE_FORGE_URL": "", "CI_REPO": "testUser/testRepo", "CI_REPO_CLONE_URL": "https://gitea.com/testUser/testRepo.git", "CI_REPO_CLONE_SSH_URL": "git@gitea.com:testUser/testRepo.git",
|
||||||
"CI_REPO_DEFAULT_BRANCH": "main", "CI_REPO_NAME": "testRepo", "CI_REPO_OWNER": "testUser", "CI_REPO_PRIVATE": "true", "CI_REPO_REMOTE_ID": "",
|
"CI_REPO_DEFAULT_BRANCH": "main", "CI_REPO_NAME": "testRepo", "CI_REPO_OWNER": "testUser", "CI_REPO_PRIVATE": "true", "CI_REPO_REMOTE_ID": "",
|
||||||
"CI_REPO_SCM": "git", "CI_REPO_TRUSTED": "false", "CI_REPO_URL": "https://gitea.com/testUser/testRepo", "CI_STEP_FINISHED": "",
|
"CI_REPO_SCM": "git", "CI_REPO_TRUSTED": "false", "CI_REPO_URL": "https://gitea.com/testUser/testRepo",
|
||||||
"CI_STEP_NAME": "", "CI_STEP_NUMBER": "0", "CI_STEP_STARTED": "", "CI_STEP_STATUS": "", "CI_STEP_URL": "https://example.com/repos/0/pipeline/3", "CI_SYSTEM_HOST": "example.com",
|
"CI_STEP_NAME": "", "CI_STEP_NUMBER": "0", "CI_STEP_STARTED": "", "CI_STEP_URL": "https://example.com/repos/0/pipeline/3", "CI_SYSTEM_HOST": "example.com",
|
||||||
"CI_SYSTEM_NAME": "woodpecker", "CI_SYSTEM_PLATFORM": "", "CI_SYSTEM_URL": "https://example.com", "CI_SYSTEM_VERSION": "", "CI_WORKFLOW_NAME": "hello", "CI_WORKFLOW_NUMBER": "0",
|
"CI_SYSTEM_NAME": "woodpecker", "CI_SYSTEM_PLATFORM": "", "CI_SYSTEM_URL": "https://example.com", "CI_SYSTEM_VERSION": "", "CI_WORKFLOW_NAME": "hello", "CI_WORKFLOW_NUMBER": "0",
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
|
Loading…
Reference in a new issue