From 6de85c6db3d79b4077396373c6a4432d10cb2373 Mon Sep 17 00:00:00 2001 From: Anton Bracke Date: Sat, 9 Oct 2021 21:30:25 +0200 Subject: [PATCH 01/12] Replace DRONE_ pipeline vars with CI_ --- .woodpecker/docs.yml | 2 +- .woodpecker/helm.yml | 2 +- .woodpecker/main.yml | 14 +- Makefile | 6 +- agent/runner.go | 14 +- cli/exec/exec.go | 3 - pipeline/frontend/metadata.go | 125 ++++-------- pipeline/frontend/yaml/compiler/convert.go | 2 - pipeline/frontend/yaml/compiler/option.go | 11 - .../frontend/yaml/compiler/option_test.go | 4 +- .../frontend/yaml/compiler/script_posix.go | 4 - .../yaml/compiler/script_posix_test.go | 2 - pipeline/frontend/yaml/compiler/script_win.go | 2 - pipeline/samples/sample_1/pipeline.json | 59 +----- .../samples/sample_10_windows/pipeline.json | 76 ++----- pipeline/samples/sample_2/pipeline.json | 91 +-------- pipeline/samples/sample_3/pipeline.json | 92 +-------- pipeline/samples/sample_4/pipeline.json | 92 +-------- pipeline/samples/sample_5/pipeline.json | 191 ++---------------- pipeline/samples/sample_6/pipeline.json | 115 +++-------- pipeline/samples/sample_7_redis/pipeline.json | 46 ++--- .../sample_8_network_mode/pipeline.json | 43 ++-- pipeline/samples/sample_9_cache/pipeline.json | 159 ++++----------- server/shared/procBuilder.go | 13 +- server/shared/procBuilder_test.go | 4 +- 25 files changed, 224 insertions(+), 948 deletions(-) diff --git a/.woodpecker/docs.yml b/.woodpecker/docs.yml index 6e3555108c..8db168ee24 100644 --- a/.woodpecker/docs.yml +++ b/.woodpecker/docs.yml @@ -32,7 +32,7 @@ pipeline: - git add . # exit successfully if nothing changed - test -n "$(git status --porcelain)" || exit 0 - - git commit -m "Deploy website - based on ${DRONE_COMMIT_SHA}" + - git commit -m "Deploy website - based on ${CI_COMMIT_SHA}" - git push when: event: push diff --git a/.woodpecker/helm.yml b/.woodpecker/helm.yml index fcc17ba382..e500370fa2 100644 --- a/.woodpecker/helm.yml +++ b/.woodpecker/helm.yml @@ -7,7 +7,7 @@ pipeline: image: alpine/helm:3.5.3 commands: # use tag name or 0.0.0 if not running on a tag - - export CHART_VERSION="${DRONE_TAG##v}" + - export CHART_VERSION="${CI_TAG##v}" - export CHART_VERSION=$${CHART_VERSION:=0.0.0} - echo "Version $CHART_VERSION" - sed -i "s//$CHART_VERSION/g" charts/woodpecker-agent/Chart.yaml diff --git a/.woodpecker/main.yml b/.woodpecker/main.yml index 45ed5531b8..b58bfb0653 100644 --- a/.woodpecker/main.yml +++ b/.woodpecker/main.yml @@ -137,7 +137,7 @@ pipeline: repo: woodpeckerci/woodpecker-server dockerfile: docker/Dockerfile.server secrets: [docker_username, docker_password] - tag: [latest, "${DRONE_TAG}"] + tag: [latest, "${CI_TAG}"] when: event: tag @@ -147,7 +147,7 @@ pipeline: repo: woodpeckerci/woodpecker-server dockerfile: docker/Dockerfile.server.alpine secrets: [ docker_username, docker_password ] - tag: [latest-alpine, "${DRONE_TAG}-alpine"] + tag: [latest-alpine, "${CI_TAG}-alpine"] when: event: tag @@ -157,7 +157,7 @@ pipeline: repo: woodpeckerci/woodpecker-agent dockerfile: docker/Dockerfile.agent secrets: [docker_username, docker_password] - tag: [latest, "${DRONE_TAG}"] + tag: [latest, "${CI_TAG}"] when: event: tag @@ -167,7 +167,7 @@ pipeline: repo: woodpeckerci/woodpecker-agent dockerfile: docker/Dockerfile.agent.alpine secrets: [ docker_username, docker_password ] - tag: [latest-alpine, "${DRONE_TAG}-alpine"] + tag: [latest-alpine, "${CI_TAG}-alpine"] when: event: tag @@ -177,7 +177,7 @@ pipeline: repo: woodpeckerci/woodpecker-cli dockerfile: docker/Dockerfile.cli secrets: [docker_username, docker_password] - tag: [latest, "${DRONE_TAG}"] + tag: [latest, "${CI_TAG}"] when: event: tag @@ -187,7 +187,7 @@ pipeline: repo: woodpeckerci/woodpecker-cli dockerfile: docker/Dockerfile.cli.alpine secrets: [ docker_username, docker_password ] - tag: [latest-alpine, "${DRONE_TAG}-alpine"] + tag: [latest-alpine, "${CI_TAG}-alpine"] when: event: tag @@ -205,7 +205,7 @@ pipeline: files: - dist/*.tar.gz - dist/checksums.txt - title: ${DRONE_TAG##v} + title: ${CI_TAG##v} secrets: - source: github_token target: github_release_api_key diff --git a/Makefile b/Makefile index 510b5ff5b6..f9ce19315b 100644 --- a/Makefile +++ b/Makefile @@ -3,14 +3,14 @@ GOFILES_NOVENDOR = $(shell find . -type f -name '*.go' -not -path "./vendor/*" - GO_PACKAGES ?= $(shell go list ./... | grep -v /vendor/) VERSION ?= next -ifneq ($(DRONE_TAG),) - VERSION := $(DRONE_TAG:v%=%) +ifneq ($(CI_TAG),) + VERSION := $(CI_TAG:v%=%) endif # append commit-sha to next version BUILD_VERSION := $(VERSION) ifeq ($(BUILD_VERSION),next) - BUILD_VERSION := $(shell echo "next-$(shell echo ${DRONE_COMMIT_SHA} | head -c 8)") + BUILD_VERSION := $(shell echo "next-$(shell echo ${CI_COMMIT_SHA} | head -c 8)") endif LDFLAGS := -s -w -extldflags "-static" -X github.com/woodpecker-ci/woodpecker/version.Version=${BUILD_VERSION} diff --git a/agent/runner.go b/agent/runner.go index 76e9f3b552..34280bea16 100644 --- a/agent/runner.go +++ b/agent/runner.go @@ -276,26 +276,18 @@ func (r *Runner) Run(ctx context.Context) error { state.Pipeline.Step.Environment = map[string]string{} } - state.Pipeline.Step.Environment["DRONE_MACHINE"] = r.hostname + state.Pipeline.Step.Environment["CI_MACHINE"] = r.hostname 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["DRONE_BUILD_STATUS"] = "success" - state.Pipeline.Step.Environment["DRONE_BUILD_STARTED"] = strconv.FormatInt(state.Pipeline.Time, 10) - state.Pipeline.Step.Environment["DRONE_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) - state.Pipeline.Step.Environment["DRONE_JOB_STATUS"] = "success" - state.Pipeline.Step.Environment["DRONE_JOB_STARTED"] = strconv.FormatInt(state.Pipeline.Time, 10) - state.Pipeline.Step.Environment["DRONE_JOB_FINISHED"] = strconv.FormatInt(time.Now().Unix(), 10) if state.Pipeline.Error != nil { state.Pipeline.Step.Environment["CI_BUILD_STATUS"] = "failure" state.Pipeline.Step.Environment["CI_JOB_STATUS"] = "failure" - state.Pipeline.Step.Environment["DRONE_BUILD_STATUS"] = "failure" - state.Pipeline.Step.Environment["DRONE_JOB_STATUS"] = "failure" } return nil }) @@ -354,10 +346,10 @@ func (r *Runner) Run(ctx context.Context) error { // extract repository name from the configuration func extractRepositoryName(config *backend.Config) string { - return config.Stages[0].Steps[0].Environment["DRONE_REPO"] + 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["DRONE_BUILD_NUMBER"] + return config.Stages[0].Steps[0].Environment["CI_BUILD_NUMBER"] } diff --git a/cli/exec/exec.go b/cli/exec/exec.go index 2fade5a46b..79fa45d530 100644 --- a/cli/exec/exec.go +++ b/cli/exec/exec.go @@ -76,9 +76,6 @@ func execWithAxis(c *cli.Context, axis matrix.Axis) error { metadata := metadataFromContext(c, axis) environ := metadata.Environ() var secrets []compiler.Secret - for k, v := range metadata.EnvironDrone() { - environ[k] = v - } for key, val := range metadata.Job.Matrix { environ[key] = val secrets = append(secrets, compiler.Secret{ diff --git a/pipeline/frontend/metadata.go b/pipeline/frontend/metadata.go index d5570247f0..95983b8a4c 100644 --- a/pipeline/frontend/metadata.go +++ b/pipeline/frontend/metadata.go @@ -1,7 +1,6 @@ package frontend import ( - "fmt" "regexp" "strconv" "strings" @@ -28,12 +27,12 @@ type ( // Repo defines runtime metadata for a repository. Repo struct { - Name string `json:"name,omitempty"` - Link string `json:"link,omitempty"` - Remote string `json:"remote,omitempty"` - Private bool `json:"private,omitempty"` - Secrets []Secret `json:"secrets,omitempty"` - Branch string `json:"default_branch,omitempty"` + Name string `json:"name,omitempty"` + Link string `json:"link,omitempty"` + Remote string `json:"remote,omitempty"` + Private bool `json:"private,omitempty"` + Secrets []Secret `json:"secrets,omitempty"` + DefaultBranch string `json:"default_branch,omitempty"` } // Build defines runtime metadata for a build. @@ -96,13 +95,39 @@ type ( // Environ returns the metadata as a map of environment variables. func (m *Metadata) Environ() map[string]string { + var ( + repoOwner string + repoName string + sourceBranch string + targetBranch string + + repoParts = strings.Split(m.Repo.Name, "/") + branchParts = strings.Split(m.Curr.Commit.Refspec, ":") + ) + if len(repoParts) == 2 { + repoOwner = repoParts[0] + repoName = repoParts[1] + } else { + repoName = m.Repo.Name + } + + if len(branchParts) == 2 { + sourceBranch = branchParts[0] + targetBranch = branchParts[1] + } + params := map[string]string{ + "CI": m.Sys.Name, "CI_REPO": m.Repo.Name, - "CI_REPO_NAME": m.Repo.Name, + "CI_REPO_SCM": "git", + "CI_REPO_OWNER": repoOwner, + "CI_REPO_NAME": repoName, "CI_REPO_LINK": m.Repo.Link, "CI_REPO_REMOTE": m.Repo.Remote, - "CI_REMOTE_URL": m.Repo.Remote, + "CI_REPO_DEFAULT_BRANCH": m.Repo.DefaultBranch, "CI_REPO_PRIVATE": strconv.FormatBool(m.Repo.Private), + "CI_REPO_TRUSTED": "false", // TODO should this be added? + "CI_REMOTE_URL": m.Repo.Remote, "CI_BUILD_NUMBER": strconv.Itoa(m.Curr.Number), "CI_PARENT_BUILD_NUMBER": strconv.Itoa(m.Curr.Parent), "CI_BUILD_CREATED": strconv.FormatInt(m.Curr.Created, 10), @@ -116,6 +141,8 @@ func (m *Metadata) Environ() map[string]string { "CI_COMMIT_REF": m.Curr.Commit.Ref, "CI_COMMIT_REFSPEC": m.Curr.Commit.Refspec, "CI_COMMIT_BRANCH": m.Curr.Commit.Branch, + "CI_COMMIT_SOURCE_BRANCH": sourceBranch, + "CI_COMMIT_TARGET_BRANCH": targetBranch, "CI_COMMIT_MESSAGE": m.Curr.Commit.Message, "CI_COMMIT_AUTHOR": m.Curr.Commit.Author.Name, "CI_COMMIT_AUTHOR_NAME": m.Curr.Commit.Author.Name, @@ -138,13 +165,13 @@ func (m *Metadata) Environ() map[string]string { "CI_PREV_COMMIT_AUTHOR_EMAIL": m.Prev.Commit.Author.Email, "CI_PREV_COMMIT_AUTHOR_AVATAR": m.Prev.Commit.Author.Avatar, "CI_JOB_NUMBER": strconv.Itoa(m.Job.Number), + "CI_JOB_STARTED": strconv.FormatInt(m.Curr.Started, 10), // ISSUE: no job started "CI_SYSTEM": m.Sys.Name, "CI_SYSTEM_NAME": m.Sys.Name, "CI_SYSTEM_LINK": m.Sys.Link, "CI_SYSTEM_HOST": m.Sys.Host, "CI_SYSTEM_ARCH": m.Sys.Arch, "CI_SYSTEM_VERSION": m.Sys.Version, - "CI": m.Sys.Name, } if m.Curr.Event == EventTag { params["CI_TAG"] = strings.TrimPrefix(m.Curr.Commit.Ref, "refs/tags/") @@ -155,84 +182,6 @@ func (m *Metadata) Environ() map[string]string { return params } -// EnvironDrone returns metadata as a map of DRONE_ environment variables. -// TODO: This is here for backward compatibility and will eventually be removed. -func (m *Metadata) EnvironDrone() map[string]string { - // MISSING PARAMETERS - // * DRONE_REPO_TRUSTED - // * DRONE_YAML_VERIFIED - // * DRONE_YAML_VERIFIED - var ( - owner string - name string - sourceBranch string - targetBranch string - - repoParts = strings.Split(m.Repo.Name, "/") - branchParts = strings.Split(m.Curr.Commit.Refspec, ":") - ) - if len(repoParts) == 2 { - owner = repoParts[0] - name = repoParts[1] - } else { - name = m.Repo.Name - } - - if len(branchParts) == 2 { - sourceBranch = branchParts[0] - targetBranch = branchParts[1] - } - - params := map[string]string{ - "CI": "drone", - "DRONE": "true", - "DRONE_ARCH": m.Sys.Arch, - "DRONE_REPO": m.Repo.Name, - "DRONE_REPO_SCM": "git", - "DRONE_REPO_OWNER": owner, - "DRONE_REPO_NAME": name, - "DRONE_REPO_LINK": m.Repo.Link, - "DRONE_REPO_BRANCH": m.Repo.Branch, - "DRONE_REPO_PRIVATE": fmt.Sprintf("%v", m.Repo.Private), - "DRONE_REPO_TRUSTED": "false", // TODO should this be added? - "DRONE_REMOTE_URL": m.Repo.Remote, - "DRONE_COMMIT_SHA": m.Curr.Commit.Sha, - "DRONE_COMMIT_REF": m.Curr.Commit.Ref, - "DRONE_COMMIT_REFSPEC": m.Curr.Commit.Refspec, - "DRONE_COMMIT_BRANCH": m.Curr.Commit.Branch, - "DRONE_COMMIT_LINK": m.Curr.Link, - "DRONE_COMMIT_MESSAGE": m.Curr.Commit.Message, - "DRONE_COMMIT_AUTHOR": m.Curr.Commit.Author.Name, - "DRONE_COMMIT_AUTHOR_EMAIL": m.Curr.Commit.Author.Email, - "DRONE_COMMIT_AUTHOR_AVATAR": m.Curr.Commit.Author.Avatar, - "DRONE_BUILD_NUMBER": fmt.Sprintf("%d", m.Curr.Number), - "DRONE_PARENT_BUILD_NUMBER": fmt.Sprintf("%d", m.Curr.Parent), - "DRONE_BUILD_EVENT": m.Curr.Event, - "DRONE_BUILD_LINK": fmt.Sprintf("%s/%s/%d", m.Sys.Link, m.Repo.Name, m.Curr.Number), - "DRONE_BUILD_CREATED": fmt.Sprintf("%d", m.Curr.Created), - "DRONE_BUILD_STARTED": fmt.Sprintf("%d", m.Curr.Started), - "DRONE_BUILD_FINISHED": fmt.Sprintf("%d", m.Curr.Finished), - "DRONE_JOB_NUMBER": fmt.Sprintf("%d", m.Job.Number), - "DRONE_JOB_STARTED": fmt.Sprintf("%d", m.Curr.Started), // ISSUE: no job started - "DRONE_BRANCH": m.Curr.Commit.Branch, - "DRONE_SOURCE_BRANCH": sourceBranch, - "DRONE_TARGET_BRANCH": targetBranch, - "DRONE_COMMIT": m.Curr.Commit.Sha, - "DRONE_VERSION": m.Sys.Version, - "DRONE_DEPLOY_TO": m.Curr.Target, - "DRONE_PREV_BUILD_STATUS": m.Prev.Status, - "DRONE_PREV_BUILD_NUMBER": fmt.Sprintf("%v", m.Prev.Number), - "DRONE_PREV_COMMIT_SHA": m.Prev.Commit.Sha, - } - if m.Curr.Event == EventTag || strings.HasPrefix(m.Curr.Commit.Ref, "refs/tags/") { - params["DRONE_TAG"] = strings.TrimPrefix(m.Curr.Commit.Ref, "refs/tags/") - } - if m.Curr.Event == EventPull { - params["DRONE_PULL_REQUEST"] = pullRegexp.FindString(m.Curr.Commit.Ref) - } - return params -} - var pullRegexp = regexp.MustCompile("\\d+") func (m *Metadata) SetPlatform(platform string) { diff --git a/pipeline/frontend/yaml/compiler/convert.go b/pipeline/frontend/yaml/compiler/convert.go index 115eee5f6d..6ca5906524 100644 --- a/pipeline/frontend/yaml/compiler/convert.go +++ b/pipeline/frontend/yaml/compiler/convert.go @@ -60,8 +60,6 @@ func (c *Compiler) createProcess(name string, container *yaml.Container, section } environment["CI_WORKSPACE"] = path.Join(c.base, c.path) - // TODO: This is here for backward compatibility and will eventually be removed. - environment["DRONE_WORKSPACE"] = path.Join(c.base, c.path) if section == "services" || container.Detached { detached = true diff --git a/pipeline/frontend/yaml/compiler/option.go b/pipeline/frontend/yaml/compiler/option.go index 1e7706b2ad..ee20bca162 100644 --- a/pipeline/frontend/yaml/compiler/option.go +++ b/pipeline/frontend/yaml/compiler/option.go @@ -60,11 +60,6 @@ func WithMetadata(metadata frontend.Metadata) Option { for k, v := range metadata.Environ() { compiler.env[k] = v } - // TODO this is present for backward compatibility and should - // be removed in a future version. - for k, v := range metadata.EnvironDrone() { - compiler.env[k] = v - } } } @@ -76,12 +71,6 @@ func WithNetrc(username, password, machine string) Option { "CI_NETRC_USERNAME": username, "CI_NETRC_PASSWORD": password, "CI_NETRC_MACHINE": machine, - - // TODO: This is present for backward compatibility and should - // be removed in a future version. - "DRONE_NETRC_USERNAME": username, - "DRONE_NETRC_PASSWORD": password, - "DRONE_NETRC_MACHINE": machine, }, ) } diff --git a/pipeline/frontend/yaml/compiler/option_test.go b/pipeline/frontend/yaml/compiler/option_test.go index a2f5254e33..629f670b92 100644 --- a/pipeline/frontend/yaml/compiler/option_test.go +++ b/pipeline/frontend/yaml/compiler/option_test.go @@ -111,8 +111,8 @@ func TestWithMetadata(t *testing.T) { if !reflect.DeepEqual(compiler.metadata, metadata) { t.Errorf("WithMetadata must set compiler the metadata") } - if compiler.env["CI_REPO_NAME"] != metadata.Repo.Name { - t.Errorf("WithMetadata must set CI_REPO_NAME") + if compiler.env["CI_REPO"] != metadata.Repo.Name { + t.Errorf("WithMetadata must set CI_REPO") } if compiler.env["CI_REPO_LINK"] != metadata.Repo.Link { t.Errorf("WithMetadata must set CI_REPO_LINK") diff --git a/pipeline/frontend/yaml/compiler/script_posix.go b/pipeline/frontend/yaml/compiler/script_posix.go index 7db43f33b2..a4c6574a12 100644 --- a/pipeline/frontend/yaml/compiler/script_posix.go +++ b/pipeline/frontend/yaml/compiler/script_posix.go @@ -29,8 +29,6 @@ func generateScriptPosix(commands []string) string { // setupScript is a helper script this is added to the build to ensure // a minimum set of environment variables are set correctly. -// TODO: Unsetting DRONE_* is present for backward compatibility and should -// be removed in a future version. const setupScript = ` if [ -n "$CI_NETRC_MACHINE" ]; then cat < $HOME/.netrc @@ -43,8 +41,6 @@ fi unset CI_NETRC_USERNAME unset CI_NETRC_PASSWORD unset CI_SCRIPT -unset DRONE_NETRC_USERNAME -unset DRONE_NETRC_PASSWORD %s ` diff --git a/pipeline/frontend/yaml/compiler/script_posix_test.go b/pipeline/frontend/yaml/compiler/script_posix_test.go index 82753f8787..4e5e7ae045 100644 --- a/pipeline/frontend/yaml/compiler/script_posix_test.go +++ b/pipeline/frontend/yaml/compiler/script_posix_test.go @@ -26,8 +26,6 @@ fi unset CI_NETRC_USERNAME unset CI_NETRC_PASSWORD unset CI_SCRIPT -unset DRONE_NETRC_USERNAME -unset DRONE_NETRC_PASSWORD echo + "echo \${PATH}" echo ${PATH} diff --git a/pipeline/frontend/yaml/compiler/script_win.go b/pipeline/frontend/yaml/compiler/script_win.go index 6d1201001a..b9e021a24a 100644 --- a/pipeline/frontend/yaml/compiler/script_win.go +++ b/pipeline/frontend/yaml/compiler/script_win.go @@ -36,8 +36,6 @@ $netrc=[string]::Format("{0}\_netrc",$Env:HOME); }; [Environment]::SetEnvironmentVariable("CI_NETRC_PASSWORD",$null); [Environment]::SetEnvironmentVariable("CI_SCRIPT",$null); -[Environment]::SetEnvironmentVariable("DRONE_NETRC_USERNAME",$null); -[Environment]::SetEnvironmentVariable("DRONE_NETRC_PASSWORD",$null); %s ` diff --git a/pipeline/samples/sample_1/pipeline.json b/pipeline/samples/sample_1/pipeline.json index 98df7cac06..127b38e1f0 100644 --- a/pipeline/samples/sample_1/pipeline.json +++ b/pipeline/samples/sample_1/pipeline.json @@ -31,31 +31,9 @@ "CI_SYSTEM_LINK": "https://github.com/cncd/pipec", "CI_SYSTEM_NAME": "pipec", "CI_WORKSPACE": "/go/src/github.com/drone/envsubst", - "DRONE_BUILD_CREATED": "1486119586", - "DRONE_BUILD_EVENT": "push", - "DRONE_BUILD_NUMBER": "6", - "DRONE_BUILD_STARTED": "1486119585", - "DRONE_COMMIT_AUTHOR": "bradrydzewski", - "DRONE_COMMIT_AUTHOR_NAME": "bradrydzewski", - "DRONE_COMMIT_BRANCH": "master", - "DRONE_COMMIT_MESSAGE": "added a few more test cases for escaping behavior", - "DRONE_COMMIT_REF": "refs/heads/master", - "DRONE_COMMIT_SHA": "d0876d3176965f9552a611cbd56e24a9264355e6", - "DRONE_REMOTE_URL": "https://github.com/drone/envsubst.git", - "DRONE_REPO": "drone/envsubst", - "DRONE_REPO_LINK": "https://github.com/drone/envsubst", - "DRONE_REPO_NAME": "drone/envsubst", - "DRONE_REPO_REMOTE": "https://github.com/drone/envsubst.git", - "DRONE_SYSTEM": "pipec", - "DRONE_SYSTEM_ARCH": "linux/amd64", - "DRONE_SYSTEM_LINK": "https://github.com/cncd/pipec", - "DRONE_SYSTEM_NAME": "pipec", - "DRONE_WORKSPACE": "/go/src/github.com/drone/envsubst", "PLUGIN_DEPTH": "50" }, - "volumes": [ - "pipeline_default:/go" - ], + "volumes": ["pipeline_default:/go"], "networks": [ { "name": "pipeline_default", @@ -99,39 +77,12 @@ "CI_SYSTEM_LINK": "https://github.com/cncd/pipec", "CI_SYSTEM_NAME": "pipec", "CI_WORKSPACE": "/go/src/github.com/drone/envsubst", - "DRONE_BUILD_CREATED": "1486119586", - "DRONE_BUILD_EVENT": "push", - "DRONE_BUILD_NUMBER": "6", - "DRONE_BUILD_STARTED": "1486119585", - "DRONE_COMMIT_AUTHOR": "bradrydzewski", - "DRONE_COMMIT_AUTHOR_NAME": "bradrydzewski", - "DRONE_COMMIT_BRANCH": "master", - "DRONE_COMMIT_MESSAGE": "added a few more test cases for escaping behavior", - "DRONE_COMMIT_REF": "refs/heads/master", - "DRONE_COMMIT_SHA": "d0876d3176965f9552a611cbd56e24a9264355e6", - "DRONE_REMOTE_URL": "https://github.com/drone/envsubst.git", - "DRONE_REPO": "drone/envsubst", - "DRONE_REPO_LINK": "https://github.com/drone/envsubst", - "DRONE_REPO_NAME": "drone/envsubst", - "DRONE_REPO_REMOTE": "https://github.com/drone/envsubst.git", - "DRONE_SYSTEM": "pipec", - "DRONE_SYSTEM_ARCH": "linux/amd64", - "DRONE_SYSTEM_LINK": "https://github.com/cncd/pipec", - "DRONE_SYSTEM_NAME": "pipec", - "DRONE_WORKSPACE": "/go/src/github.com/drone/envsubst", "HOME": "/root", "SHELL": "/bin/sh" }, - "entrypoint": [ - "/bin/sh", - "-c" - ], - "command": [ - "echo $CI_SCRIPT | base64 -d | /bin/sh -e" - ], - "volumes": [ - "pipeline_default:/go" - ], + "entrypoint": ["/bin/sh", "-c"], + "command": ["echo $CI_SCRIPT | base64 -d | /bin/sh -e"], + "volumes": ["pipeline_default:/go"], "networks": [ { "name": "pipeline_default", @@ -156,4 +107,4 @@ "driver": "local" } ] -} \ No newline at end of file +} diff --git a/pipeline/samples/sample_10_windows/pipeline.json b/pipeline/samples/sample_10_windows/pipeline.json index 7d345169ba..bb0e46d7f2 100644 --- a/pipeline/samples/sample_10_windows/pipeline.json +++ b/pipeline/samples/sample_10_windows/pipeline.json @@ -31,39 +31,20 @@ "CI_SYSTEM_LINK": "https://github.com/cncd/pipec", "CI_SYSTEM_NAME": "pipec", "CI_WORKSPACE": "c:\\gopath/src\\github.com\\drone\\envsubst", - "DRONE": "true", - "DRONE_ARCH": "windows/amd64", - "DRONE_BRANCH": "master", - "DRONE_BUILD_CREATED": "1486119586", - "DRONE_BUILD_EVENT": "push", - "DRONE_BUILD_LINK": "https://github.com/cncd/pipec/drone/envsubst/6", - "DRONE_BUILD_NUMBER": "6", - "DRONE_BUILD_STARTED": "1486119585", - "DRONE_COMMIT": "d0876d3176965f9552a611cbd56e24a9264355e6", - "DRONE_COMMIT_AUTHOR": "bradrydzewski", - "DRONE_COMMIT_BRANCH": "master", - "DRONE_COMMIT_MESSAGE": "added a few more test cases for escaping behavior", - "DRONE_COMMIT_REF": "refs/heads/master", - "DRONE_COMMIT_SHA": "d0876d3176965f9552a611cbd56e24a9264355e6", - "DRONE_JOB_STARTED": "1486119585", - "DRONE_REMOTE_URL": "https://github.com/drone/envsubst.git", - "DRONE_REPO": "drone/envsubst", - "DRONE_REPO_LINK": "https://github.com/drone/envsubst", - "DRONE_REPO_NAME": "envsubst", - "DRONE_REPO_OWNER": "drone", - "DRONE_REPO_SCM": "git", - "DRONE_WORKSPACE": "c:\\gopath/src\\github.com\\drone\\envsubst", + "CI_ARCH": "windows/amd64", + "CI_BRANCH": "master", + "CI_BUILD_LINK": "https://github.com/cncd/pipec/drone/envsubst/6", + "CI_COMMIT": "d0876d3176965f9552a611cbd56e24a9264355e6", + "CI_JOB_STARTED": "1486119585", + "CI_REPO_OWNER": "drone", + "CI_REPO_SCM": "git", "PLUGIN_DEPTH": "50" }, - "volumes": [ - "pipeline_default:c:\\gopath" - ], + "volumes": ["pipeline_default:c:\\gopath"], "networks": [ { "name": "pipeline_default", - "aliases": [ - "git" - ] + "aliases": ["git"] } ], "on_success": true, @@ -103,28 +84,13 @@ "CI_SYSTEM_LINK": "https://github.com/cncd/pipec", "CI_SYSTEM_NAME": "pipec", "CI_WORKSPACE": "c:\\gopath/src\\github.com\\drone\\envsubst", - "DRONE": "true", - "DRONE_ARCH": "windows/amd64", - "DRONE_BRANCH": "master", - "DRONE_BUILD_CREATED": "1486119586", - "DRONE_BUILD_EVENT": "push", - "DRONE_BUILD_LINK": "https://github.com/cncd/pipec/drone/envsubst/6", - "DRONE_BUILD_NUMBER": "6", - "DRONE_BUILD_STARTED": "1486119585", - "DRONE_COMMIT": "d0876d3176965f9552a611cbd56e24a9264355e6", - "DRONE_COMMIT_AUTHOR": "bradrydzewski", - "DRONE_COMMIT_BRANCH": "master", - "DRONE_COMMIT_MESSAGE": "added a few more test cases for escaping behavior", - "DRONE_COMMIT_REF": "refs/heads/master", - "DRONE_COMMIT_SHA": "d0876d3176965f9552a611cbd56e24a9264355e6", - "DRONE_JOB_STARTED": "1486119585", - "DRONE_REMOTE_URL": "https://github.com/drone/envsubst.git", - "DRONE_REPO": "drone/envsubst", - "DRONE_REPO_LINK": "https://github.com/drone/envsubst", - "DRONE_REPO_NAME": "envsubst", - "DRONE_REPO_OWNER": "drone", - "DRONE_REPO_SCM": "git", - "DRONE_WORKSPACE": "c:\\gopath/src\\github.com\\drone\\envsubst", + "CI_ARCH": "windows/amd64", + "CI_BRANCH": "master", + "CI_BUILD_LINK": "https://github.com/cncd/pipec/drone/envsubst/6", + "CI_COMMIT": "d0876d3176965f9552a611cbd56e24a9264355e6", + "CI_JOB_STARTED": "1486119585", + "CI_REPO_OWNER": "drone", + "CI_REPO_SCM": "git", "HOME": "c:\\root", "SHELL": "powershell.exe" }, @@ -137,15 +103,11 @@ "command": [ "[System.Text.Encoding]::UTF8.GetString([System.Convert]::FromBase64String($Env:CI_SCRIPT)) | iex" ], - "volumes": [ - "pipeline_default:c:\\gopath" - ], + "volumes": ["pipeline_default:c:\\gopath"], "networks": [ { "name": "pipeline_default", - "aliases": [ - "build" - ] + "aliases": ["build"] } ], "on_success": true, @@ -167,4 +129,4 @@ } ], "secrets": null -} \ No newline at end of file +} diff --git a/pipeline/samples/sample_2/pipeline.json b/pipeline/samples/sample_2/pipeline.json index af52677ce8..a41c55808c 100644 --- a/pipeline/samples/sample_2/pipeline.json +++ b/pipeline/samples/sample_2/pipeline.json @@ -30,31 +30,9 @@ "CI_SYSTEM_LINK": "https://github.com/cncd/pipec", "CI_SYSTEM_NAME": "pipec", "CI_WORKSPACE": "/go/src/github.com/go-sql-driver/mysql", - "DRONE_BUILD_CREATED": "1486119586", - "DRONE_BUILD_EVENT": "push", - "DRONE_BUILD_NUMBER": "530", - "DRONE_BUILD_STARTED": "1486119585", - "DRONE_COMMIT_AUTHOR": "egorsmkv", - "DRONE_COMMIT_AUTHOR_NAME": "egorsmkv", - "DRONE_COMMIT_BRANCH": "master", - "DRONE_COMMIT_MESSAGE": "Fix many urls", - "DRONE_COMMIT_REF": "refs/heads/master", - "DRONE_COMMIT_SHA": "2e00b5cd70399450106cec6431c2e2ce3cae5034", - "DRONE_REMOTE_URL": "https://github.com/go-sql-driver/mysql.git", - "DRONE_REPO": "go-sql-driver/mysql", - "DRONE_REPO_LINK": "https://github.com/go-sql-driver/mysql", - "DRONE_REPO_NAME": "go-sql-driver/mysql", - "DRONE_REPO_REMOTE": "https://github.com/go-sql-driver/mysql.git", - "DRONE_SYSTEM": "pipec", - "DRONE_SYSTEM_ARCH": "linux/amd64", - "DRONE_SYSTEM_LINK": "https://github.com/cncd/pipec", - "DRONE_SYSTEM_NAME": "pipec", - "DRONE_WORKSPACE": "/go/src/github.com/go-sql-driver/mysql", "PLUGIN_DEPTH": "0" }, - "volumes": [ - "pipeline_default:/go" - ], + "volumes": ["pipeline_default:/go"], "networks": [ { "name": "pipeline_default", @@ -97,38 +75,14 @@ "CI_SYSTEM_LINK": "https://github.com/cncd/pipec", "CI_SYSTEM_NAME": "pipec", "CI_WORKSPACE": "/go/src/github.com/go-sql-driver/mysql", - "DRONE_BUILD_CREATED": "1486119586", - "DRONE_BUILD_EVENT": "push", - "DRONE_BUILD_NUMBER": "530", - "DRONE_BUILD_STARTED": "1486119585", - "DRONE_COMMIT_AUTHOR": "egorsmkv", - "DRONE_COMMIT_AUTHOR_NAME": "egorsmkv", - "DRONE_COMMIT_BRANCH": "master", - "DRONE_COMMIT_MESSAGE": "Fix many urls", - "DRONE_COMMIT_REF": "refs/heads/master", - "DRONE_COMMIT_SHA": "2e00b5cd70399450106cec6431c2e2ce3cae5034", - "DRONE_REMOTE_URL": "https://github.com/go-sql-driver/mysql.git", - "DRONE_REPO": "go-sql-driver/mysql", - "DRONE_REPO_LINK": "https://github.com/go-sql-driver/mysql", - "DRONE_REPO_NAME": "go-sql-driver/mysql", - "DRONE_REPO_REMOTE": "https://github.com/go-sql-driver/mysql.git", - "DRONE_SYSTEM": "pipec", - "DRONE_SYSTEM_ARCH": "linux/amd64", - "DRONE_SYSTEM_LINK": "https://github.com/cncd/pipec", - "DRONE_SYSTEM_NAME": "pipec", - "DRONE_WORKSPACE": "/go/src/github.com/go-sql-driver/mysql", "MYSQL_ALLOW_EMPTY_PASSWORD": "yes", "MYSQL_DATABASE": "gotest" }, - "volumes": [ - "pipeline_default:/go" - ], + "volumes": ["pipeline_default:/go"], "networks": [ { "name": "pipeline_default", - "aliases": [ - "database" - ] + "aliases": ["database"] } ], "on_success": true, @@ -168,46 +122,17 @@ "CI_SYSTEM_LINK": "https://github.com/cncd/pipec", "CI_SYSTEM_NAME": "pipec", "CI_WORKSPACE": "/go/src/github.com/go-sql-driver/mysql", - "DRONE_BUILD_CREATED": "1486119586", - "DRONE_BUILD_EVENT": "push", - "DRONE_BUILD_NUMBER": "530", - "DRONE_BUILD_STARTED": "1486119585", - "DRONE_COMMIT_AUTHOR": "egorsmkv", - "DRONE_COMMIT_AUTHOR_NAME": "egorsmkv", - "DRONE_COMMIT_BRANCH": "master", - "DRONE_COMMIT_MESSAGE": "Fix many urls", - "DRONE_COMMIT_REF": "refs/heads/master", - "DRONE_COMMIT_SHA": "2e00b5cd70399450106cec6431c2e2ce3cae5034", - "DRONE_REMOTE_URL": "https://github.com/go-sql-driver/mysql.git", - "DRONE_REPO": "go-sql-driver/mysql", - "DRONE_REPO_LINK": "https://github.com/go-sql-driver/mysql", - "DRONE_REPO_NAME": "go-sql-driver/mysql", - "DRONE_REPO_REMOTE": "https://github.com/go-sql-driver/mysql.git", - "DRONE_SYSTEM": "pipec", - "DRONE_SYSTEM_ARCH": "linux/amd64", - "DRONE_SYSTEM_LINK": "https://github.com/cncd/pipec", - "DRONE_SYSTEM_NAME": "pipec", - "DRONE_WORKSPACE": "/go/src/github.com/go-sql-driver/mysql", "HOME": "/root", "MYSQL_TEST_ADDR": "database:3306", "SHELL": "/bin/sh" }, - "entrypoint": [ - "/bin/sh", - "-c" - ], - "command": [ - "echo $CI_SCRIPT | base64 -d | /bin/sh -e" - ], - "volumes": [ - "pipeline_default:/go" - ], + "entrypoint": ["/bin/sh", "-c"], + "command": ["echo $CI_SCRIPT | base64 -d | /bin/sh -e"], + "volumes": ["pipeline_default:/go"], "networks": [ { "name": "pipeline_default", - "aliases": [ - "database" - ] + "aliases": ["database"] } ], "on_success": true, @@ -228,4 +153,4 @@ "driver": "local" } ] -} \ No newline at end of file +} diff --git a/pipeline/samples/sample_3/pipeline.json b/pipeline/samples/sample_3/pipeline.json index 23486386b4..c3174e12fd 100644 --- a/pipeline/samples/sample_3/pipeline.json +++ b/pipeline/samples/sample_3/pipeline.json @@ -31,31 +31,9 @@ "CI_SYSTEM_LINK": "https://github.com/cncd/pipec", "CI_SYSTEM_NAME": "pipec", "CI_WORKSPACE": "/go/src/github.com/drone/envsubst", - "DRONE_BUILD_CREATED": "1486119586", - "DRONE_BUILD_EVENT": "push", - "DRONE_BUILD_NUMBER": "6", - "DRONE_BUILD_STARTED": "1486119585", - "DRONE_COMMIT_AUTHOR": "bradrydzewski", - "DRONE_COMMIT_AUTHOR_NAME": "bradrydzewski", - "DRONE_COMMIT_BRANCH": "master", - "DRONE_COMMIT_MESSAGE": "added a few more test cases for escaping behavior", - "DRONE_COMMIT_REF": "refs/heads/master", - "DRONE_COMMIT_SHA": "d0876d3176965f9552a611cbd56e24a9264355e6", - "DRONE_REMOTE_URL": "https://github.com/drone/envsubst.git", - "DRONE_REPO": "drone/envsubst", - "DRONE_REPO_LINK": "https://github.com/drone/envsubst", - "DRONE_REPO_NAME": "drone/envsubst", - "DRONE_REPO_REMOTE": "https://github.com/drone/envsubst.git", - "DRONE_SYSTEM": "pipec", - "DRONE_SYSTEM_ARCH": "linux/amd64", - "DRONE_SYSTEM_LINK": "https://github.com/cncd/pipec", - "DRONE_SYSTEM_NAME": "pipec", - "DRONE_WORKSPACE": "/go/src/github.com/drone/envsubst", "PLUGIN_DEPTH": "50" }, - "volumes": [ - "pipeline_default:/go" - ], + "volumes": ["pipeline_default:/go"], "networks": [ { "name": "pipeline_default", @@ -99,39 +77,12 @@ "CI_SYSTEM_LINK": "https://github.com/cncd/pipec", "CI_SYSTEM_NAME": "pipec", "CI_WORKSPACE": "/go/src/github.com/drone/envsubst", - "DRONE_BUILD_CREATED": "1486119586", - "DRONE_BUILD_EVENT": "push", - "DRONE_BUILD_NUMBER": "6", - "DRONE_BUILD_STARTED": "1486119585", - "DRONE_COMMIT_AUTHOR": "bradrydzewski", - "DRONE_COMMIT_AUTHOR_NAME": "bradrydzewski", - "DRONE_COMMIT_BRANCH": "master", - "DRONE_COMMIT_MESSAGE": "added a few more test cases for escaping behavior", - "DRONE_COMMIT_REF": "refs/heads/master", - "DRONE_COMMIT_SHA": "d0876d3176965f9552a611cbd56e24a9264355e6", - "DRONE_REMOTE_URL": "https://github.com/drone/envsubst.git", - "DRONE_REPO": "drone/envsubst", - "DRONE_REPO_LINK": "https://github.com/drone/envsubst", - "DRONE_REPO_NAME": "drone/envsubst", - "DRONE_REPO_REMOTE": "https://github.com/drone/envsubst.git", - "DRONE_SYSTEM": "pipec", - "DRONE_SYSTEM_ARCH": "linux/amd64", - "DRONE_SYSTEM_LINK": "https://github.com/cncd/pipec", - "DRONE_SYSTEM_NAME": "pipec", - "DRONE_WORKSPACE": "/go/src/github.com/drone/envsubst", "HOME": "/root", "SHELL": "/bin/sh" }, - "entrypoint": [ - "/bin/sh", - "-c" - ], - "command": [ - "echo $CI_SCRIPT | base64 -d | /bin/sh -e" - ], - "volumes": [ - "pipeline_default:/go" - ], + "entrypoint": ["/bin/sh", "-c"], + "command": ["echo $CI_SCRIPT | base64 -d | /bin/sh -e"], + "volumes": ["pipeline_default:/go"], "networks": [ { "name": "pipeline_default", @@ -175,39 +126,12 @@ "CI_SYSTEM_LINK": "https://github.com/cncd/pipec", "CI_SYSTEM_NAME": "pipec", "CI_WORKSPACE": "/go/src/github.com/drone/envsubst", - "DRONE_BUILD_CREATED": "1486119586", - "DRONE_BUILD_EVENT": "push", - "DRONE_BUILD_NUMBER": "6", - "DRONE_BUILD_STARTED": "1486119585", - "DRONE_COMMIT_AUTHOR": "bradrydzewski", - "DRONE_COMMIT_AUTHOR_NAME": "bradrydzewski", - "DRONE_COMMIT_BRANCH": "master", - "DRONE_COMMIT_MESSAGE": "added a few more test cases for escaping behavior", - "DRONE_COMMIT_REF": "refs/heads/master", - "DRONE_COMMIT_SHA": "d0876d3176965f9552a611cbd56e24a9264355e6", - "DRONE_REMOTE_URL": "https://github.com/drone/envsubst.git", - "DRONE_REPO": "drone/envsubst", - "DRONE_REPO_LINK": "https://github.com/drone/envsubst", - "DRONE_REPO_NAME": "drone/envsubst", - "DRONE_REPO_REMOTE": "https://github.com/drone/envsubst.git", - "DRONE_SYSTEM": "pipec", - "DRONE_SYSTEM_ARCH": "linux/amd64", - "DRONE_SYSTEM_LINK": "https://github.com/cncd/pipec", - "DRONE_SYSTEM_NAME": "pipec", - "DRONE_WORKSPACE": "/go/src/github.com/drone/envsubst", "HOME": "/root", "SHELL": "/bin/sh" }, - "entrypoint": [ - "/bin/sh", - "-c" - ], - "command": [ - "echo $CI_SCRIPT | base64 -d | /bin/sh -e" - ], - "volumes": [ - "pipeline_default:/go" - ], + "entrypoint": ["/bin/sh", "-c"], + "command": ["echo $CI_SCRIPT | base64 -d | /bin/sh -e"], + "volumes": ["pipeline_default:/go"], "networks": [ { "name": "pipeline_default", @@ -232,4 +156,4 @@ "driver": "local" } ] -} \ No newline at end of file +} diff --git a/pipeline/samples/sample_4/pipeline.json b/pipeline/samples/sample_4/pipeline.json index 91c09b2c44..d96fdf7a21 100644 --- a/pipeline/samples/sample_4/pipeline.json +++ b/pipeline/samples/sample_4/pipeline.json @@ -31,31 +31,9 @@ "CI_SYSTEM_LINK": "https://github.com/cncd/pipec", "CI_SYSTEM_NAME": "pipec", "CI_WORKSPACE": "/go/src/github.com/drone/envsubst", - "DRONE_BUILD_CREATED": "1486119586", - "DRONE_BUILD_EVENT": "push", - "DRONE_BUILD_NUMBER": "6", - "DRONE_BUILD_STARTED": "1486119585", - "DRONE_COMMIT_AUTHOR": "bradrydzewski", - "DRONE_COMMIT_AUTHOR_NAME": "bradrydzewski", - "DRONE_COMMIT_BRANCH": "master", - "DRONE_COMMIT_MESSAGE": "added a few more test cases for escaping behavior", - "DRONE_COMMIT_REF": "refs/heads/master", - "DRONE_COMMIT_SHA": "d0876d3176965f9552a611cbd56e24a9264355e6", - "DRONE_REMOTE_URL": "https://github.com/drone/envsubst.git", - "DRONE_REPO": "drone/envsubst", - "DRONE_REPO_LINK": "https://github.com/drone/envsubst", - "DRONE_REPO_NAME": "drone/envsubst", - "DRONE_REPO_REMOTE": "https://github.com/drone/envsubst.git", - "DRONE_SYSTEM": "pipec", - "DRONE_SYSTEM_ARCH": "linux/amd64", - "DRONE_SYSTEM_LINK": "https://github.com/cncd/pipec", - "DRONE_SYSTEM_NAME": "pipec", - "DRONE_WORKSPACE": "/go/src/github.com/drone/envsubst", "PLUGIN_DEPTH": "50" }, - "volumes": [ - "pipeline_default:/go" - ], + "volumes": ["pipeline_default:/go"], "networks": [ { "name": "pipeline_default", @@ -99,39 +77,12 @@ "CI_SYSTEM_LINK": "https://github.com/cncd/pipec", "CI_SYSTEM_NAME": "pipec", "CI_WORKSPACE": "/go/src/github.com/drone/envsubst", - "DRONE_BUILD_CREATED": "1486119586", - "DRONE_BUILD_EVENT": "push", - "DRONE_BUILD_NUMBER": "6", - "DRONE_BUILD_STARTED": "1486119585", - "DRONE_COMMIT_AUTHOR": "bradrydzewski", - "DRONE_COMMIT_AUTHOR_NAME": "bradrydzewski", - "DRONE_COMMIT_BRANCH": "master", - "DRONE_COMMIT_MESSAGE": "added a few more test cases for escaping behavior", - "DRONE_COMMIT_REF": "refs/heads/master", - "DRONE_COMMIT_SHA": "d0876d3176965f9552a611cbd56e24a9264355e6", - "DRONE_REMOTE_URL": "https://github.com/drone/envsubst.git", - "DRONE_REPO": "drone/envsubst", - "DRONE_REPO_LINK": "https://github.com/drone/envsubst", - "DRONE_REPO_NAME": "drone/envsubst", - "DRONE_REPO_REMOTE": "https://github.com/drone/envsubst.git", - "DRONE_SYSTEM": "pipec", - "DRONE_SYSTEM_ARCH": "linux/amd64", - "DRONE_SYSTEM_LINK": "https://github.com/cncd/pipec", - "DRONE_SYSTEM_NAME": "pipec", - "DRONE_WORKSPACE": "/go/src/github.com/drone/envsubst", "HOME": "/root", "SHELL": "/bin/sh" }, - "entrypoint": [ - "/bin/sh", - "-c" - ], - "command": [ - "echo $CI_SCRIPT | base64 -d | /bin/sh -e" - ], - "volumes": [ - "pipeline_default:/go" - ], + "entrypoint": ["/bin/sh", "-c"], + "command": ["echo $CI_SCRIPT | base64 -d | /bin/sh -e"], + "volumes": ["pipeline_default:/go"], "networks": [ { "name": "pipeline_default", @@ -175,39 +126,12 @@ "CI_SYSTEM_LINK": "https://github.com/cncd/pipec", "CI_SYSTEM_NAME": "pipec", "CI_WORKSPACE": "/go/src/github.com/drone/envsubst", - "DRONE_BUILD_CREATED": "1486119586", - "DRONE_BUILD_EVENT": "push", - "DRONE_BUILD_NUMBER": "6", - "DRONE_BUILD_STARTED": "1486119585", - "DRONE_COMMIT_AUTHOR": "bradrydzewski", - "DRONE_COMMIT_AUTHOR_NAME": "bradrydzewski", - "DRONE_COMMIT_BRANCH": "master", - "DRONE_COMMIT_MESSAGE": "added a few more test cases for escaping behavior", - "DRONE_COMMIT_REF": "refs/heads/master", - "DRONE_COMMIT_SHA": "d0876d3176965f9552a611cbd56e24a9264355e6", - "DRONE_REMOTE_URL": "https://github.com/drone/envsubst.git", - "DRONE_REPO": "drone/envsubst", - "DRONE_REPO_LINK": "https://github.com/drone/envsubst", - "DRONE_REPO_NAME": "drone/envsubst", - "DRONE_REPO_REMOTE": "https://github.com/drone/envsubst.git", - "DRONE_SYSTEM": "pipec", - "DRONE_SYSTEM_ARCH": "linux/amd64", - "DRONE_SYSTEM_LINK": "https://github.com/cncd/pipec", - "DRONE_SYSTEM_NAME": "pipec", - "DRONE_WORKSPACE": "/go/src/github.com/drone/envsubst", "HOME": "/root", "SHELL": "/bin/sh" }, - "entrypoint": [ - "/bin/sh", - "-c" - ], - "command": [ - "echo $CI_SCRIPT | base64 -d | /bin/sh -e" - ], - "volumes": [ - "pipeline_default:/go" - ], + "entrypoint": ["/bin/sh", "-c"], + "command": ["echo $CI_SCRIPT | base64 -d | /bin/sh -e"], + "volumes": ["pipeline_default:/go"], "networks": [ { "name": "pipeline_default", @@ -232,4 +156,4 @@ "driver": "local" } ] -} \ No newline at end of file +} diff --git a/pipeline/samples/sample_5/pipeline.json b/pipeline/samples/sample_5/pipeline.json index e426c4944e..6406de69f7 100644 --- a/pipeline/samples/sample_5/pipeline.json +++ b/pipeline/samples/sample_5/pipeline.json @@ -31,31 +31,9 @@ "CI_SYSTEM_LINK": "https://github.com/cncd/pipec", "CI_SYSTEM_NAME": "pipec", "CI_WORKSPACE": "/go/src/github.com/drone/envsubst", - "DRONE_BUILD_CREATED": "1486119586", - "DRONE_BUILD_EVENT": "push", - "DRONE_BUILD_NUMBER": "6", - "DRONE_BUILD_STARTED": "1486119585", - "DRONE_COMMIT_AUTHOR": "bradrydzewski", - "DRONE_COMMIT_AUTHOR_NAME": "bradrydzewski", - "DRONE_COMMIT_BRANCH": "master", - "DRONE_COMMIT_MESSAGE": "added a few more test cases for escaping behavior", - "DRONE_COMMIT_REF": "refs/heads/master", - "DRONE_COMMIT_SHA": "d0876d3176965f9552a611cbd56e24a9264355e6", - "DRONE_REMOTE_URL": "https://github.com/drone/envsubst.git", - "DRONE_REPO": "drone/envsubst", - "DRONE_REPO_LINK": "https://github.com/drone/envsubst", - "DRONE_REPO_NAME": "drone/envsubst", - "DRONE_REPO_REMOTE": "https://github.com/drone/envsubst.git", - "DRONE_SYSTEM": "pipec", - "DRONE_SYSTEM_ARCH": "linux/amd64", - "DRONE_SYSTEM_LINK": "https://github.com/cncd/pipec", - "DRONE_SYSTEM_NAME": "pipec", - "DRONE_WORKSPACE": "/go/src/github.com/drone/envsubst", "PLUGIN_DEPTH": "50" }, - "volumes": [ - "pipeline_default:/go" - ], + "volumes": ["pipeline_default:/go"], "networks": [ { "name": "pipeline_default", @@ -99,39 +77,12 @@ "CI_SYSTEM_LINK": "https://github.com/cncd/pipec", "CI_SYSTEM_NAME": "pipec", "CI_WORKSPACE": "/go/src/github.com/drone/envsubst", - "DRONE_BUILD_CREATED": "1486119586", - "DRONE_BUILD_EVENT": "push", - "DRONE_BUILD_NUMBER": "6", - "DRONE_BUILD_STARTED": "1486119585", - "DRONE_COMMIT_AUTHOR": "bradrydzewski", - "DRONE_COMMIT_AUTHOR_NAME": "bradrydzewski", - "DRONE_COMMIT_BRANCH": "master", - "DRONE_COMMIT_MESSAGE": "added a few more test cases for escaping behavior", - "DRONE_COMMIT_REF": "refs/heads/master", - "DRONE_COMMIT_SHA": "d0876d3176965f9552a611cbd56e24a9264355e6", - "DRONE_REMOTE_URL": "https://github.com/drone/envsubst.git", - "DRONE_REPO": "drone/envsubst", - "DRONE_REPO_LINK": "https://github.com/drone/envsubst", - "DRONE_REPO_NAME": "drone/envsubst", - "DRONE_REPO_REMOTE": "https://github.com/drone/envsubst.git", - "DRONE_SYSTEM": "pipec", - "DRONE_SYSTEM_ARCH": "linux/amd64", - "DRONE_SYSTEM_LINK": "https://github.com/cncd/pipec", - "DRONE_SYSTEM_NAME": "pipec", - "DRONE_WORKSPACE": "/go/src/github.com/drone/envsubst", "HOME": "/root", "SHELL": "/bin/sh" }, - "entrypoint": [ - "/bin/sh", - "-c" - ], - "command": [ - "echo $CI_SCRIPT | base64 -d | /bin/sh -e" - ], - "volumes": [ - "pipeline_default:/go" - ], + "entrypoint": ["/bin/sh", "-c"], + "command": ["echo $CI_SCRIPT | base64 -d | /bin/sh -e"], + "volumes": ["pipeline_default:/go"], "networks": [ { "name": "pipeline_default", @@ -169,39 +120,12 @@ "CI_SYSTEM_LINK": "https://github.com/cncd/pipec", "CI_SYSTEM_NAME": "pipec", "CI_WORKSPACE": "/go/src/github.com/drone/envsubst", - "DRONE_BUILD_CREATED": "1486119586", - "DRONE_BUILD_EVENT": "push", - "DRONE_BUILD_NUMBER": "6", - "DRONE_BUILD_STARTED": "1486119585", - "DRONE_COMMIT_AUTHOR": "bradrydzewski", - "DRONE_COMMIT_AUTHOR_NAME": "bradrydzewski", - "DRONE_COMMIT_BRANCH": "master", - "DRONE_COMMIT_MESSAGE": "added a few more test cases for escaping behavior", - "DRONE_COMMIT_REF": "refs/heads/master", - "DRONE_COMMIT_SHA": "d0876d3176965f9552a611cbd56e24a9264355e6", - "DRONE_REMOTE_URL": "https://github.com/drone/envsubst.git", - "DRONE_REPO": "drone/envsubst", - "DRONE_REPO_LINK": "https://github.com/drone/envsubst", - "DRONE_REPO_NAME": "drone/envsubst", - "DRONE_REPO_REMOTE": "https://github.com/drone/envsubst.git", - "DRONE_SYSTEM": "pipec", - "DRONE_SYSTEM_ARCH": "linux/amd64", - "DRONE_SYSTEM_LINK": "https://github.com/cncd/pipec", - "DRONE_SYSTEM_NAME": "pipec", - "DRONE_WORKSPACE": "/go/src/github.com/drone/envsubst", "HOME": "/root", "SHELL": "/bin/sh" }, - "entrypoint": [ - "/bin/sh", - "-c" - ], - "command": [ - "echo $CI_SCRIPT | base64 -d | /bin/sh -e" - ], - "volumes": [ - "pipeline_default:/go" - ], + "entrypoint": ["/bin/sh", "-c"], + "command": ["echo $CI_SCRIPT | base64 -d | /bin/sh -e"], + "volumes": ["pipeline_default:/go"], "networks": [ { "name": "pipeline_default", @@ -245,39 +169,12 @@ "CI_SYSTEM_LINK": "https://github.com/cncd/pipec", "CI_SYSTEM_NAME": "pipec", "CI_WORKSPACE": "/go/src/github.com/drone/envsubst", - "DRONE_BUILD_CREATED": "1486119586", - "DRONE_BUILD_EVENT": "push", - "DRONE_BUILD_NUMBER": "6", - "DRONE_BUILD_STARTED": "1486119585", - "DRONE_COMMIT_AUTHOR": "bradrydzewski", - "DRONE_COMMIT_AUTHOR_NAME": "bradrydzewski", - "DRONE_COMMIT_BRANCH": "master", - "DRONE_COMMIT_MESSAGE": "added a few more test cases for escaping behavior", - "DRONE_COMMIT_REF": "refs/heads/master", - "DRONE_COMMIT_SHA": "d0876d3176965f9552a611cbd56e24a9264355e6", - "DRONE_REMOTE_URL": "https://github.com/drone/envsubst.git", - "DRONE_REPO": "drone/envsubst", - "DRONE_REPO_LINK": "https://github.com/drone/envsubst", - "DRONE_REPO_NAME": "drone/envsubst", - "DRONE_REPO_REMOTE": "https://github.com/drone/envsubst.git", - "DRONE_SYSTEM": "pipec", - "DRONE_SYSTEM_ARCH": "linux/amd64", - "DRONE_SYSTEM_LINK": "https://github.com/cncd/pipec", - "DRONE_SYSTEM_NAME": "pipec", - "DRONE_WORKSPACE": "/go/src/github.com/drone/envsubst", "HOME": "/root", "SHELL": "/bin/sh" }, - "entrypoint": [ - "/bin/sh", - "-c" - ], - "command": [ - "echo $CI_SCRIPT | base64 -d | /bin/sh -e" - ], - "volumes": [ - "pipeline_default:/go" - ], + "entrypoint": ["/bin/sh", "-c"], + "command": ["echo $CI_SCRIPT | base64 -d | /bin/sh -e"], + "volumes": ["pipeline_default:/go"], "networks": [ { "name": "pipeline_default", @@ -321,39 +218,12 @@ "CI_SYSTEM_LINK": "https://github.com/cncd/pipec", "CI_SYSTEM_NAME": "pipec", "CI_WORKSPACE": "/go/src/github.com/drone/envsubst", - "DRONE_BUILD_CREATED": "1486119586", - "DRONE_BUILD_EVENT": "push", - "DRONE_BUILD_NUMBER": "6", - "DRONE_BUILD_STARTED": "1486119585", - "DRONE_COMMIT_AUTHOR": "bradrydzewski", - "DRONE_COMMIT_AUTHOR_NAME": "bradrydzewski", - "DRONE_COMMIT_BRANCH": "master", - "DRONE_COMMIT_MESSAGE": "added a few more test cases for escaping behavior", - "DRONE_COMMIT_REF": "refs/heads/master", - "DRONE_COMMIT_SHA": "d0876d3176965f9552a611cbd56e24a9264355e6", - "DRONE_REMOTE_URL": "https://github.com/drone/envsubst.git", - "DRONE_REPO": "drone/envsubst", - "DRONE_REPO_LINK": "https://github.com/drone/envsubst", - "DRONE_REPO_NAME": "drone/envsubst", - "DRONE_REPO_REMOTE": "https://github.com/drone/envsubst.git", - "DRONE_SYSTEM": "pipec", - "DRONE_SYSTEM_ARCH": "linux/amd64", - "DRONE_SYSTEM_LINK": "https://github.com/cncd/pipec", - "DRONE_SYSTEM_NAME": "pipec", - "DRONE_WORKSPACE": "/go/src/github.com/drone/envsubst", "HOME": "/root", "SHELL": "/bin/sh" }, - "entrypoint": [ - "/bin/sh", - "-c" - ], - "command": [ - "echo $CI_SCRIPT | base64 -d | /bin/sh -e" - ], - "volumes": [ - "pipeline_default:/go" - ], + "entrypoint": ["/bin/sh", "-c"], + "command": ["echo $CI_SCRIPT | base64 -d | /bin/sh -e"], + "volumes": ["pipeline_default:/go"], "networks": [ { "name": "pipeline_default", @@ -391,39 +261,12 @@ "CI_SYSTEM_LINK": "https://github.com/cncd/pipec", "CI_SYSTEM_NAME": "pipec", "CI_WORKSPACE": "/go/src/github.com/drone/envsubst", - "DRONE_BUILD_CREATED": "1486119586", - "DRONE_BUILD_EVENT": "push", - "DRONE_BUILD_NUMBER": "6", - "DRONE_BUILD_STARTED": "1486119585", - "DRONE_COMMIT_AUTHOR": "bradrydzewski", - "DRONE_COMMIT_AUTHOR_NAME": "bradrydzewski", - "DRONE_COMMIT_BRANCH": "master", - "DRONE_COMMIT_MESSAGE": "added a few more test cases for escaping behavior", - "DRONE_COMMIT_REF": "refs/heads/master", - "DRONE_COMMIT_SHA": "d0876d3176965f9552a611cbd56e24a9264355e6", - "DRONE_REMOTE_URL": "https://github.com/drone/envsubst.git", - "DRONE_REPO": "drone/envsubst", - "DRONE_REPO_LINK": "https://github.com/drone/envsubst", - "DRONE_REPO_NAME": "drone/envsubst", - "DRONE_REPO_REMOTE": "https://github.com/drone/envsubst.git", - "DRONE_SYSTEM": "pipec", - "DRONE_SYSTEM_ARCH": "linux/amd64", - "DRONE_SYSTEM_LINK": "https://github.com/cncd/pipec", - "DRONE_SYSTEM_NAME": "pipec", - "DRONE_WORKSPACE": "/go/src/github.com/drone/envsubst", "HOME": "/root", "SHELL": "/bin/sh" }, - "entrypoint": [ - "/bin/sh", - "-c" - ], - "command": [ - "echo $CI_SCRIPT | base64 -d | /bin/sh -e" - ], - "volumes": [ - "pipeline_default:/go" - ], + "entrypoint": ["/bin/sh", "-c"], + "command": ["echo $CI_SCRIPT | base64 -d | /bin/sh -e"], + "volumes": ["pipeline_default:/go"], "networks": [ { "name": "pipeline_default", @@ -448,4 +291,4 @@ "driver": "local" } ] -} \ No newline at end of file +} diff --git a/pipeline/samples/sample_6/pipeline.json b/pipeline/samples/sample_6/pipeline.json index b05c143771..473e701bca 100644 --- a/pipeline/samples/sample_6/pipeline.json +++ b/pipeline/samples/sample_6/pipeline.json @@ -31,34 +31,17 @@ "CI_SYSTEM_LINK": "https://github.com/cncd/pipec", "CI_SYSTEM_NAME": "pipec", "CI_WORKSPACE": "/go/src/github.com/drone/envsubst", - "DRONE": "true", - "DRONE_ARCH": "linux/amd64", - "DRONE_BRANCH": "master", - "DRONE_BUILD_CREATED": "1486119586", - "DRONE_BUILD_EVENT": "push", - "DRONE_BUILD_LINK": "https://github.com/cncd/pipec/drone/envsubst/6", - "DRONE_BUILD_NUMBER": "6", - "DRONE_BUILD_STARTED": "1486119585", - "DRONE_COMMIT": "d0876d3176965f9552a611cbd56e24a9264355e6", - "DRONE_COMMIT_AUTHOR": "bradrydzewski", - "DRONE_COMMIT_BRANCH": "master", - "DRONE_COMMIT_MESSAGE": "added a few more test cases for escaping behavior", - "DRONE_COMMIT_REF": "refs/heads/master", - "DRONE_COMMIT_SHA": "d0876d3176965f9552a611cbd56e24a9264355e6", - "DRONE_JOB_STARTED": "1486119585", - "DRONE_REMOTE_URL": "https://github.com/drone/envsubst.git", - "DRONE_REPO": "drone/envsubst", - "DRONE_REPO_BRANCH": "master", - "DRONE_REPO_LINK": "https://github.com/drone/envsubst", - "DRONE_REPO_NAME": "drone", - "DRONE_REPO_OWNER": "drone", - "DRONE_REPO_SCM": "git", - "DRONE_WORKSPACE": "/go/src/github.com/drone/envsubst", + "CI_ARCH": "linux/amd64", + "CI_BRANCH": "master", + "CI_BUILD_LINK": "https://github.com/cncd/pipec/drone/envsubst/6", + "CI_COMMIT": "d0876d3176965f9552a611cbd56e24a9264355e6", + "CI_JOB_STARTED": "1486119585", + "CI_REPO_BRANCH": "master", + "CI_REPO_OWNER": "drone", + "CI_REPO_SCM": "git", "PLUGIN_DEPTH": "50" }, - "volumes": [ - "pipeline_default:/go" - ], + "volumes": ["pipeline_default:/go"], "networks": [ { "name": "pipeline_default", @@ -105,42 +88,19 @@ "CI_SYSTEM_LINK": "https://github.com/cncd/pipec", "CI_SYSTEM_NAME": "pipec", "CI_WORKSPACE": "/go/src/github.com/drone/envsubst", - "DRONE": "true", - "DRONE_ARCH": "linux/amd64", - "DRONE_BRANCH": "master", - "DRONE_BUILD_CREATED": "1486119586", - "DRONE_BUILD_EVENT": "push", - "DRONE_BUILD_LINK": "https://github.com/cncd/pipec/drone/envsubst/6", - "DRONE_BUILD_NUMBER": "6", - "DRONE_BUILD_STARTED": "1486119585", - "DRONE_COMMIT": "d0876d3176965f9552a611cbd56e24a9264355e6", - "DRONE_COMMIT_AUTHOR": "bradrydzewski", - "DRONE_COMMIT_BRANCH": "master", - "DRONE_COMMIT_MESSAGE": "added a few more test cases for escaping behavior", - "DRONE_COMMIT_REF": "refs/heads/master", - "DRONE_COMMIT_SHA": "d0876d3176965f9552a611cbd56e24a9264355e6", - "DRONE_JOB_STARTED": "1486119585", - "DRONE_REMOTE_URL": "https://github.com/drone/envsubst.git", - "DRONE_REPO": "drone/envsubst", - "DRONE_REPO_BRANCH": "master", - "DRONE_REPO_LINK": "https://github.com/drone/envsubst", - "DRONE_REPO_NAME": "drone", - "DRONE_REPO_OWNER": "drone", - "DRONE_REPO_SCM": "git", - "DRONE_WORKSPACE": "/go/src/github.com/drone/envsubst", + "CI_ARCH": "linux/amd64", + "CI_BRANCH": "master", + "CI_COMMIT": "d0876d3176965f9552a611cbd56e24a9264355e6", + "CI_JOB_STARTED": "1486119585", + "CI_REPO_BRANCH": "master", + "CI_REPO_OWNER": "drone", + "CI_REPO_SCM": "git", "HOME": "/root", "SHELL": "/bin/sh" }, - "entrypoint": [ - "/bin/sh", - "-c" - ], - "command": [ - "echo $CI_SCRIPT | base64 -d | /bin/sh -e" - ], - "volumes": [ - "pipeline_default:/go" - ], + "entrypoint": ["/bin/sh", "-c"], + "command": ["echo $CI_SCRIPT | base64 -d | /bin/sh -e"], + "volumes": ["pipeline_default:/go"], "networks": [ { "name": "pipeline_default", @@ -186,36 +146,19 @@ "CI_SYSTEM_LINK": "https://github.com/cncd/pipec", "CI_SYSTEM_NAME": "pipec", "CI_WORKSPACE": "/go/src/github.com/drone/envsubst", - "DRONE": "true", - "DRONE_ARCH": "linux/amd64", - "DRONE_BRANCH": "master", - "DRONE_BUILD_CREATED": "1486119586", - "DRONE_BUILD_EVENT": "push", - "DRONE_BUILD_LINK": "https://github.com/cncd/pipec/drone/envsubst/6", - "DRONE_BUILD_NUMBER": "6", - "DRONE_BUILD_STARTED": "1486119585", - "DRONE_COMMIT": "d0876d3176965f9552a611cbd56e24a9264355e6", - "DRONE_COMMIT_AUTHOR": "bradrydzewski", - "DRONE_COMMIT_BRANCH": "master", - "DRONE_COMMIT_MESSAGE": "added a few more test cases for escaping behavior", - "DRONE_COMMIT_REF": "refs/heads/master", - "DRONE_COMMIT_SHA": "d0876d3176965f9552a611cbd56e24a9264355e6", - "DRONE_JOB_STARTED": "1486119585", - "DRONE_REMOTE_URL": "https://github.com/drone/envsubst.git", - "DRONE_REPO": "drone/envsubst", - "DRONE_REPO_BRANCH": "master", - "DRONE_REPO_LINK": "https://github.com/drone/envsubst", - "DRONE_REPO_NAME": "drone", - "DRONE_REPO_OWNER": "drone", - "DRONE_REPO_SCM": "git", - "DRONE_WORKSPACE": "/go/src/github.com/drone/envsubst", + "CI_ARCH": "linux/amd64", + "CI_BRANCH": "master", + "CI_BUILD_LINK": "https://github.com/cncd/pipec/drone/envsubst/6", + "CI_COMMIT": "d0876d3176965f9552a611cbd56e24a9264355e6", + "CI_JOB_STARTED": "1486119585", + "CI_REPO_BRANCH": "master", + "CI_REPO_OWNER": "drone", + "CI_REPO_SCM": "git", "PLUGIN_CHANNEL": "builds", "PLUGIN_USERNAME": "drone", "SLACK_WEBHOOK": "https://slack.com/hooks/xxxxxxxx/yyyyyyyyy" }, - "volumes": [ - "pipeline_default:/go" - ], + "volumes": ["pipeline_default:/go"], "networks": [ { "name": "pipeline_default", @@ -244,4 +187,4 @@ } ], "secrets": null -} \ No newline at end of file +} diff --git a/pipeline/samples/sample_7_redis/pipeline.json b/pipeline/samples/sample_7_redis/pipeline.json index 9d948580fb..5be3552d57 100644 --- a/pipeline/samples/sample_7_redis/pipeline.json +++ b/pipeline/samples/sample_7_redis/pipeline.json @@ -16,11 +16,9 @@ "CI_SYSTEM_LINK": "https://github.com/cncd/pipec", "CI_SYSTEM_NAME": "pipec", "CI_WORKSPACE": "/go/src/github.com/drone/envsubst", - "DRONE": "true", - "DRONE_ARCH": "linux/amd64", - "DRONE_BUILD_LINK": "https://github.com/cncd/pipec//0", - "DRONE_REPO_SCM": "git", - "DRONE_WORKSPACE": "/go/src/github.com/drone/envsubst" + "CI_ARCH": "linux/amd64", + "CI_BUILD_LINK": "https://github.com/cncd/pipec//0", + "CI_REPO_SCM": "git" }, "volumes": [ "/Users/bradrydzewski/code/src/github.com/woodpecker-ci/woodpecker/cncd/pipeline/samples/sample_7_redis:/go/src/github.com/drone/envsubst" @@ -28,9 +26,7 @@ "networks": [ { "name": "pipeline_default", - "aliases": [ - "redis1" - ] + "aliases": ["redis1"] } ], "on_success": true, @@ -48,11 +44,9 @@ "CI_SYSTEM_LINK": "https://github.com/cncd/pipec", "CI_SYSTEM_NAME": "pipec", "CI_WORKSPACE": "/go/src/github.com/drone/envsubst", - "DRONE": "true", - "DRONE_ARCH": "linux/amd64", - "DRONE_BUILD_LINK": "https://github.com/cncd/pipec//0", - "DRONE_REPO_SCM": "git", - "DRONE_WORKSPACE": "/go/src/github.com/drone/envsubst" + "CI_ARCH": "linux/amd64", + "CI_BUILD_LINK": "https://github.com/cncd/pipec//0", + "CI_REPO_SCM": "git" }, "volumes": [ "/Users/bradrydzewski/code/src/github.com/woodpecker-ci/woodpecker/cncd/pipeline/samples/sample_7_redis:/go/src/github.com/drone/envsubst" @@ -60,9 +54,7 @@ "networks": [ { "name": "pipeline_default", - "aliases": [ - "redis2" - ] + "aliases": ["redis2"] } ], "on_success": true, @@ -88,29 +80,21 @@ "CI_SYSTEM_NAME": "pipec", "CI_WORKSPACE": "/go/src/github.com/drone/envsubst", "DRONE": "true", - "DRONE_ARCH": "linux/amd64", - "DRONE_BUILD_LINK": "https://github.com/cncd/pipec//0", - "DRONE_REPO_SCM": "git", - "DRONE_WORKSPACE": "/go/src/github.com/drone/envsubst", + "CI_ARCH": "linux/amd64", + "CI_BUILD_LINK": "https://github.com/cncd/pipec//0", + "CI_REPO_SCM": "git", "HOME": "/root", "SHELL": "/bin/sh" }, - "entrypoint": [ - "/bin/sh", - "-c" - ], - "command": [ - "echo $CI_SCRIPT | base64 -d | /bin/sh -e" - ], + "entrypoint": ["/bin/sh", "-c"], + "command": ["echo $CI_SCRIPT | base64 -d | /bin/sh -e"], "volumes": [ "/Users/bradrydzewski/code/src/github.com/woodpecker-ci/woodpecker/cncd/pipeline/samples/sample_7_redis:/go/src/github.com/drone/envsubst" ], "networks": [ { "name": "pipeline_default", - "aliases": [ - "build" - ] + "aliases": ["build"] } ], "on_success": true, @@ -132,4 +116,4 @@ } ], "secrets": null -} \ No newline at end of file +} diff --git a/pipeline/samples/sample_8_network_mode/pipeline.json b/pipeline/samples/sample_8_network_mode/pipeline.json index d6cef1fe45..81db00b061 100644 --- a/pipeline/samples/sample_8_network_mode/pipeline.json +++ b/pipeline/samples/sample_8_network_mode/pipeline.json @@ -16,22 +16,16 @@ "CI_SYSTEM_LINK": "https://github.com/cncd/pipec", "CI_SYSTEM_NAME": "pipec", "CI_WORKSPACE": "/go/src/github.com/drone/envsubst", - "DRONE": "true", - "DRONE_ARCH": "linux/amd64", - "DRONE_BUILD_LINK": "https://github.com/cncd/pipec//0", - "DRONE_REPO_SCM": "git", - "DRONE_WORKSPACE": "/go/src/github.com/drone/envsubst", + "CI_ARCH": "linux/amd64", + "CI_BUILD_LINK": "https://github.com/cncd/pipec//0", + "CI_REPO_SCM": "git", "PLUGIN_DEPTH": "50" }, - "volumes": [ - "pipeline_default:/go" - ], + "volumes": ["pipeline_default:/go"], "networks": [ { "name": "pipeline_default", - "aliases": [ - "git" - ] + "aliases": ["git"] } ], "on_success": true, @@ -56,30 +50,19 @@ "CI_SYSTEM_LINK": "https://github.com/cncd/pipec", "CI_SYSTEM_NAME": "pipec", "CI_WORKSPACE": "/go/src/github.com/drone/envsubst", - "DRONE": "true", - "DRONE_ARCH": "linux/amd64", - "DRONE_BUILD_LINK": "https://github.com/cncd/pipec//0", - "DRONE_REPO_SCM": "git", - "DRONE_WORKSPACE": "/go/src/github.com/drone/envsubst", + "CI_ARCH": "linux/amd64", + "CI_BUILD_LINK": "https://github.com/cncd/pipec//0", + "CI_REPO_SCM": "git", "HOME": "/root", "SHELL": "/bin/sh" }, - "entrypoint": [ - "/bin/sh", - "-c" - ], - "command": [ - "echo $CI_SCRIPT | base64 -d | /bin/sh -e" - ], - "volumes": [ - "pipeline_default:/go" - ], + "entrypoint": ["/bin/sh", "-c"], + "command": ["echo $CI_SCRIPT | base64 -d | /bin/sh -e"], + "volumes": ["pipeline_default:/go"], "networks": [ { "name": "pipeline_default", - "aliases": [ - "build" - ] + "aliases": ["build"] } ], "on_success": true, @@ -102,4 +85,4 @@ } ], "secrets": null -} \ No newline at end of file +} diff --git a/pipeline/samples/sample_9_cache/pipeline.json b/pipeline/samples/sample_9_cache/pipeline.json index dc05f28146..716412cd81 100644 --- a/pipeline/samples/sample_9_cache/pipeline.json +++ b/pipeline/samples/sample_9_cache/pipeline.json @@ -31,40 +31,21 @@ "CI_SYSTEM_LINK": "https://github.com/cncd/pipec", "CI_SYSTEM_NAME": "pipec", "CI_WORKSPACE": "/pipeline/src", - "DRONE": "true", - "DRONE_ARCH": "linux/amd64", - "DRONE_BRANCH": "master", - "DRONE_BUILD_CREATED": "1486119586", - "DRONE_BUILD_EVENT": "push", - "DRONE_BUILD_LINK": "https://github.com/cncd/pipec/drone/envsubst/6", - "DRONE_BUILD_NUMBER": "6", - "DRONE_BUILD_STARTED": "1486119585", - "DRONE_COMMIT": "d0876d3176965f9552a611cbd56e24a9264355e6", - "DRONE_COMMIT_AUTHOR": "bradrydzewski", - "DRONE_COMMIT_BRANCH": "master", - "DRONE_COMMIT_MESSAGE": "added a few more test cases for escaping behavior", - "DRONE_COMMIT_REF": "refs/heads/master", - "DRONE_COMMIT_SHA": "d0876d3176965f9552a611cbd56e24a9264355e6", - "DRONE_JOB_STARTED": "1486119585", - "DRONE_REMOTE_URL": "https://github.com/drone/envsubst.git", - "DRONE_REPO": "drone/envsubst", - "DRONE_REPO_BRANCH": "master", - "DRONE_REPO_LINK": "https://github.com/drone/envsubst", - "DRONE_REPO_NAME": "envsubst", - "DRONE_REPO_OWNER": "drone", - "DRONE_REPO_SCM": "git", - "DRONE_WORKSPACE": "/pipeline/src", + "CI_ARCH": "linux/amd64", + "CI_BRANCH": "master", + "CI_BUILD_LINK": "https://github.com/cncd/pipec/drone/envsubst/6", + "CI_COMMIT": "d0876d3176965f9552a611cbd56e24a9264355e6", + "CI_JOB_STARTED": "1486119585", + "CI_REPO_BRANCH": "master", + "CI_REPO_OWNER": "drone", + "CI_REPO_SCM": "git", "PLUGIN_DEPTH": "0" }, - "volumes": [ - "pipeline_default:/pipeline" - ], + "volumes": ["pipeline_default:/pipeline"], "networks": [ { "name": "pipeline_default", - "aliases": [ - "clone" - ] + "aliases": ["clone"] } ], "on_success": true, @@ -103,29 +84,14 @@ "CI_SYSTEM_LINK": "https://github.com/cncd/pipec", "CI_SYSTEM_NAME": "pipec", "CI_WORKSPACE": "/pipeline/src", - "DRONE": "true", - "DRONE_ARCH": "linux/amd64", - "DRONE_BRANCH": "master", - "DRONE_BUILD_CREATED": "1486119586", - "DRONE_BUILD_EVENT": "push", - "DRONE_BUILD_LINK": "https://github.com/cncd/pipec/drone/envsubst/6", - "DRONE_BUILD_NUMBER": "6", - "DRONE_BUILD_STARTED": "1486119585", - "DRONE_COMMIT": "d0876d3176965f9552a611cbd56e24a9264355e6", - "DRONE_COMMIT_AUTHOR": "bradrydzewski", - "DRONE_COMMIT_BRANCH": "master", - "DRONE_COMMIT_MESSAGE": "added a few more test cases for escaping behavior", - "DRONE_COMMIT_REF": "refs/heads/master", - "DRONE_COMMIT_SHA": "d0876d3176965f9552a611cbd56e24a9264355e6", - "DRONE_JOB_STARTED": "1486119585", - "DRONE_REMOTE_URL": "https://github.com/drone/envsubst.git", - "DRONE_REPO": "drone/envsubst", - "DRONE_REPO_BRANCH": "master", - "DRONE_REPO_LINK": "https://github.com/drone/envsubst", - "DRONE_REPO_NAME": "envsubst", - "DRONE_REPO_OWNER": "drone", - "DRONE_REPO_SCM": "git", - "DRONE_WORKSPACE": "/pipeline/src", + "CI_ARCH": "linux/amd64", + "CI_BRANCH": "master", + "CI_BUILD_LINK": "https://github.com/cncd/pipec/drone/envsubst/6", + "CI_COMMIT": "d0876d3176965f9552a611cbd56e24a9264355e6", + "CI_JOB_STARTED": "1486119585", + "CI_REPO_BRANCH": "master", + "CI_REPO_OWNER": "drone", + "CI_REPO_SCM": "git", "PLUGIN_FALLBACK_TO": "master.tar", "PLUGIN_FILE": "master.tar", "PLUGIN_MOUNT": "node_modules", @@ -139,9 +105,7 @@ "networks": [ { "name": "pipeline_default", - "aliases": [ - "rebuild_cache" - ] + "aliases": ["rebuild_cache"] } ], "on_success": true, @@ -181,48 +145,24 @@ "CI_SYSTEM_LINK": "https://github.com/cncd/pipec", "CI_SYSTEM_NAME": "pipec", "CI_WORKSPACE": "/pipeline/src", - "DRONE": "true", - "DRONE_ARCH": "linux/amd64", - "DRONE_BRANCH": "master", - "DRONE_BUILD_CREATED": "1486119586", - "DRONE_BUILD_EVENT": "push", - "DRONE_BUILD_LINK": "https://github.com/cncd/pipec/drone/envsubst/6", - "DRONE_BUILD_NUMBER": "6", - "DRONE_BUILD_STARTED": "1486119585", - "DRONE_COMMIT": "d0876d3176965f9552a611cbd56e24a9264355e6", - "DRONE_COMMIT_AUTHOR": "bradrydzewski", - "DRONE_COMMIT_BRANCH": "master", - "DRONE_COMMIT_MESSAGE": "added a few more test cases for escaping behavior", - "DRONE_COMMIT_REF": "refs/heads/master", - "DRONE_COMMIT_SHA": "d0876d3176965f9552a611cbd56e24a9264355e6", - "DRONE_JOB_STARTED": "1486119585", - "DRONE_REMOTE_URL": "https://github.com/drone/envsubst.git", - "DRONE_REPO": "drone/envsubst", - "DRONE_REPO_BRANCH": "master", - "DRONE_REPO_LINK": "https://github.com/drone/envsubst", - "DRONE_REPO_NAME": "envsubst", - "DRONE_REPO_OWNER": "drone", - "DRONE_REPO_SCM": "git", - "DRONE_WORKSPACE": "/pipeline/src", + "CI_ARCH": "linux/amd64", + "CI_BRANCH": "master", + "CI_BUILD_LINK": "https://github.com/cncd/pipec/drone/envsubst/6", + "CI_COMMIT": "d0876d3176965f9552a611cbd56e24a9264355e6", + "CI_JOB_STARTED": "1486119585", + "CI_REPO_BRANCH": "master", + "CI_REPO_OWNER": "drone", + "CI_REPO_SCM": "git", "HOME": "/root", "SHELL": "/bin/sh" }, - "entrypoint": [ - "/bin/sh", - "-c" - ], - "command": [ - "echo $CI_SCRIPT | base64 -d | /bin/sh -e" - ], - "volumes": [ - "pipeline_default:/pipeline" - ], + "entrypoint": ["/bin/sh", "-c"], + "command": ["echo $CI_SCRIPT | base64 -d | /bin/sh -e"], + "volumes": ["pipeline_default:/pipeline"], "networks": [ { "name": "pipeline_default", - "aliases": [ - "build" - ] + "aliases": ["build"] } ], "on_success": true, @@ -261,29 +201,14 @@ "CI_SYSTEM_LINK": "https://github.com/cncd/pipec", "CI_SYSTEM_NAME": "pipec", "CI_WORKSPACE": "/pipeline/src", - "DRONE": "true", - "DRONE_ARCH": "linux/amd64", - "DRONE_BRANCH": "master", - "DRONE_BUILD_CREATED": "1486119586", - "DRONE_BUILD_EVENT": "push", - "DRONE_BUILD_LINK": "https://github.com/cncd/pipec/drone/envsubst/6", - "DRONE_BUILD_NUMBER": "6", - "DRONE_BUILD_STARTED": "1486119585", - "DRONE_COMMIT": "d0876d3176965f9552a611cbd56e24a9264355e6", - "DRONE_COMMIT_AUTHOR": "bradrydzewski", - "DRONE_COMMIT_BRANCH": "master", - "DRONE_COMMIT_MESSAGE": "added a few more test cases for escaping behavior", - "DRONE_COMMIT_REF": "refs/heads/master", - "DRONE_COMMIT_SHA": "d0876d3176965f9552a611cbd56e24a9264355e6", - "DRONE_JOB_STARTED": "1486119585", - "DRONE_REMOTE_URL": "https://github.com/drone/envsubst.git", - "DRONE_REPO": "drone/envsubst", - "DRONE_REPO_BRANCH": "master", - "DRONE_REPO_LINK": "https://github.com/drone/envsubst", - "DRONE_REPO_NAME": "envsubst", - "DRONE_REPO_OWNER": "drone", - "DRONE_REPO_SCM": "git", - "DRONE_WORKSPACE": "/pipeline/src", + "CI_ARCH": "linux/amd64", + "CI_BRANCH": "master", + "CI_BUILD_LINK": "https://github.com/cncd/pipec/drone/envsubst/6", + "CI_COMMIT": "d0876d3176965f9552a611cbd56e24a9264355e6", + "CI_JOB_STARTED": "1486119585", + "CI_REPO_BRANCH": "master", + "CI_REPO_OWNER": "drone", + "CI_REPO_SCM": "git", "PLUGIN_FILE": "master.tar", "PLUGIN_FLUSH": "true", "PLUGIN_MOUNT": "node_modules", @@ -297,9 +222,7 @@ "networks": [ { "name": "pipeline_default", - "aliases": [ - "rebuild_cache" - ] + "aliases": ["rebuild_cache"] } ], "on_success": true, @@ -321,4 +244,4 @@ } ], "secrets": null -} \ No newline at end of file +} diff --git a/server/shared/procBuilder.go b/server/shared/procBuilder.go index 09d1dedbdb..1a80421763 100644 --- a/server/shared/procBuilder.go +++ b/server/shared/procBuilder.go @@ -186,9 +186,6 @@ func (b *ProcBuilder) envsubst_(y string, environ map[string]string) (string, er func (b *ProcBuilder) environmentVariables(metadata frontend.Metadata, axis matrix.Axis) map[string]string { environ := metadata.Environ() - for k, v := range metadata.EnvironDrone() { - environ[k] = v - } for k, v := range axis { environ[k] = v } @@ -294,11 +291,11 @@ func metadataFromStruct(repo *model.Repo, build, last *model.Build, proc *model. } return frontend.Metadata{ Repo: frontend.Repo{ - Name: repo.FullName, - Link: repo.Link, - Remote: repo.Clone, - Private: repo.IsPrivate, - Branch: repo.Branch, + Name: repo.FullName, + Link: repo.Link, + Remote: repo.Clone, + Private: repo.IsPrivate, + DefaultBranch: repo.Branch, }, Curr: frontend.Build{ Number: build.Number, diff --git a/server/shared/procBuilder_test.go b/server/shared/procBuilder_test.go index a48a6e3d66..28299df9ea 100644 --- a/server/shared/procBuilder_test.go +++ b/server/shared/procBuilder_test.go @@ -41,13 +41,13 @@ bbb`, pipeline: xxx: image: scratch - yyy: ${DRONE_COMMIT_MESSAGE} + yyy: ${CI_COMMIT_MESSAGE} `)}, {Data: []byte(` pipeline: build: image: scratch - yyy: ${DRONE_COMMIT_MESSAGE} + yyy: ${CI_COMMIT_MESSAGE} `)}, }} From 0765fc7b2f45480b6db4792650d549a38cf68d9d Mon Sep 17 00:00:00 2001 From: Anton Bracke Date: Sun, 10 Oct 2021 09:23:45 +0200 Subject: [PATCH 02/12] update docs and group vars --- docs/docs/20-usage/50-environment.md | 114 ++++++++++++++++----------- docs/docs/91-migrations.md | 2 + pipeline/frontend/metadata.go | 105 ++++++++++++------------ server/shared/procBuilder.go | 9 ++- 4 files changed, 131 insertions(+), 99 deletions(-) diff --git a/docs/docs/20-usage/50-environment.md b/docs/docs/20-usage/50-environment.md index b17bfaed98..93b8c764e9 100644 --- a/docs/docs/20-usage/50-environment.md +++ b/docs/docs/20-usage/50-environment.md @@ -44,52 +44,74 @@ pipeline: ## Built-in environment variables -This is the reference list of all environment variables available to your build environment. These are injected into your build and plugins containers, at runtime. - -| NAME | DESC | -| ---------------------------- | -------------------------------------- | -| `CI=drone` | environment is drone | -| `DRONE=true` | environment is drone | -| `DRONE_ARCH` | environment architecture (linux/amd64) | -| `DRONE_REPO` | repository full name | -| `DRONE_REPO_OWNER` | repository owner | -| `DRONE_REPO_NAME` | repository name | -| `DRONE_REPO_SCM` | repository scm (git) | -| `DRONE_REPO_LINK` | repository link | -| `DRONE_REPO_AVATAR` | repository avatar | -| `DRONE_REPO_BRANCH` | repository default branch (master) | -| `DRONE_REPO_PRIVATE` | repository is private | -| `DRONE_REPO_TRUSTED` | repository is trusted | -| `DRONE_REMOTE_URL` | repository clone url | -| `DRONE_COMMIT_SHA` | commit sha | -| `DRONE_COMMIT_REF` | commit ref | -| `DRONE_COMMIT_BRANCH` | commit branch | -| `DRONE_COMMIT_LINK` | commit link in remote | -| `DRONE_COMMIT_MESSAGE` | commit message | -| `DRONE_COMMIT_AUTHOR` | commit author username | -| `DRONE_COMMIT_AUTHOR_EMAIL` | commit author email address | -| `DRONE_COMMIT_AUTHOR_AVATAR` | commit author avatar | -| `DRONE_BUILD_NUMBER` | build number | -| `DRONE_BUILD_EVENT` | build event (push, pull_request, tag) | -| `DRONE_BUILD_STATUS` | build status (success, failure) | -| `DRONE_BUILD_LINK` | build result link | -| `DRONE_BUILD_CREATED` | build created unix timestamp | -| `DRONE_BUILD_STARTED` | build started unix timestamp | -| `DRONE_BUILD_FINISHED` | build finished unix timestamp | -| `DRONE_PREV_BUILD_STATUS` | prior build status | -| `DRONE_PREV_BUILD_NUMBER` | prior build number | -| `DRONE_PREV_COMMIT_SHA` | prior build commit sha | -| `DRONE_JOB_NUMBER` | job number | -| `DRONE_JOB_STATUS` | job status | -| `DRONE_JOB_STARTED` | job started | -| `DRONE_JOB_FINISHED` | job finished | -| `DRONE_BRANCH` | commit branch | -| `DRONE_TARGET_BRANCH` | The target branch of a Pull Request | -| `DRONE_SOURCE_BRANCH` | The source branch of a Pull Request | -| `DRONE_COMMIT` | commit sha | -| `DRONE_TAG` | commit tag | -| `DRONE_PULL_REQUEST` | pull request number | -| `DRONE_DEPLOY_TO` | deployment target (ie production) | +This is the reference list of all environment variables available to your pipeline containers. These are injected into your pipeline step and plugins containers, at runtime. + +| NAME | Description | +| ------------------------------ | ------------------------------------------------------------------------ | +| `CI=woodpecker` | environment is woodpecker | +| `CI_REPO` | repository full name `/` | +| `CI_REPO_OWNER` | repository owner | +| `CI_REPO_NAME` | repository name | +| `CI_REPO_SCM` | repository scm (git) | +| `CI_REPO_LINK` | repository link | +| `CI_REPO_REMOTE` | repository clone url | +| `CI_REPO_DEFAULT_BRANCH` | repository default branch (master) | +| `CI_REPO_PRIVATE` | repository is private | +| `CI_REPO_TRUSTED` | repository is trusted | +| | **Current Commit** | +| `CI_COMMIT_SHA` | commit sha | +| `CI_COMMIT_REF` | commit ref | +| `CI_COMMIT_REFSPEC` | commit ref spec | +| `CI_COMMIT_BRANCH` | commit branch | +| `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_LINK` | commit link in remote | +| `CI_COMMIT_MESSAGE` | commit message | +| `CI_COMMIT_AUTHOR` | commit author username | +| `CI_COMMIT_AUTHOR_EMAIL` | commit author email address | +| `CI_COMMIT_AUTHOR_AVATAR` | commit author avatar | +| | **Current build** | +| `CI_BUILD_NUMBER` | build number | +| `CI_BUILD_PARENT` | build number of parent build | +| `CI_BUILD_EVENT` | build event (push, pull_request, tag, deployment) | +| `CI_BUILD_LINK` | build link in ci | +| `CI_BUILD_DEPLOY_TARGET` | build deploy target for `deployment` events (ie production) | +| `CI_BUILD_STATUS` | build status (success, failure) | +| `CI_BUILD_CREATED` | build created unix timestamp | +| `CI_BUILD_STARTED` | build started unix timestamp | +| `CI_BUILD_FINISHED` | build finished unix timestamp | +| `CI_BUILD_JOB_NUMBER` | build-job number | +| `CI_BUILD_JOB_STARTED` | build-job started unix timestamp | +| | **Previous commit** | +| `CI_PREV_COMMIT_SHA` | previous commit sha | +| `CI_PREV_COMMIT_REF` | previous commit ref | +| `CI_PREV_COMMIT_REFSPEC` | previous commit ref spec | +| `CI_PREV_COMMIT_BRANCH` | previous commit branch | +| `CI_PREV_COMMIT_SOURCE_BRANCH` | previous commit source branch | +| `CI_PREV_COMMIT_TARGET_BRANCH` | previous commit target branch | +| `CI_PREV_COMMIT_LINK` | previous commit link in remote | +| `CI_PREV_COMMIT_MESSAGE` | previous commit message | +| `CI_PREV_COMMIT_AUTHOR` | previous commit author username | +| `CI_PREV_COMMIT_AUTHOR_EMAIL` | previous commit author email address | +| `CI_PREV_COMMIT_AUTHOR_AVATAR` | previous commit author avatar | +| | **Previous build** | +| `CI_PREV_BUILD_NUMBER` | previous build number | +| `CI_PREV_BUILD_PARENT` | previous build number of parent build | +| `CI_PREV_BUILD_EVENT` | previous build event (push, pull_request, tag, deployment) | +| `CI_PREV_BUILD_LINK` | previous build link in ci | +| `CI_PREV_BUILD_DEPLOY_TARGET` | previous build deploy target for `deployment` events (ie production) | +| `CI_PREV_BUILD_STATUS` | previous build status (success, failure) | +| `CI_PREV_BUILD_CREATED` | previous build created unix timestamp | +| `CI_PREV_BUILD_STARTED` | previous build started unix timestamp | +| `CI_PREV_BUILD_FINISHED` | previous build finished unix timestamp | +| | **System** | +| `CI_SYSTEM_NAME` | name of the ci system (woodpecker) | +| `CI_SYSTEM_LINK` | link to ci system | +| `CI_SYSTEM_HOST` | hostname of ci system server | +| `CI_SYSTEM_ARCH` | architecture of agent (defined in pipeline file, default: `linux/amd64`) | +| `CI_SYSTEM_VERSION` | todo | ## Global environment variables diff --git a/docs/docs/91-migrations.md b/docs/docs/91-migrations.md index 4be61580f2..86895d343f 100644 --- a/docs/docs/91-migrations.md +++ b/docs/docs/91-migrations.md @@ -22,6 +22,8 @@ Some versions need some changes to the server configuration or the pipeline conf - From version `0.15.0` ongoing there will be three types of docker images: `latest`, `next` and `x.x.x` with an alpine variant for each type like `latest-alpine`. If you used `latest` before to try pre-release features you should switch to `next` after this release. +- Dropped support for `DRONE_*` environment variables in pipeline steps. Pipeline meta-data can be accessed with `CI_*` variables. Please have a look at [built-in-environment-variables](/docs/usage/environment#built-in-environment-variables) for all available variables and their descriptions. + - ... ## 0.14.0 diff --git a/pipeline/frontend/metadata.go b/pipeline/frontend/metadata.go index 95983b8a4c..adb361f692 100644 --- a/pipeline/frontend/metadata.go +++ b/pipeline/frontend/metadata.go @@ -117,67 +117,74 @@ func (m *Metadata) Environ() map[string]string { } params := map[string]string{ - "CI": m.Sys.Name, - "CI_REPO": m.Repo.Name, - "CI_REPO_SCM": "git", - "CI_REPO_OWNER": repoOwner, - "CI_REPO_NAME": repoName, - "CI_REPO_LINK": m.Repo.Link, - "CI_REPO_REMOTE": m.Repo.Remote, - "CI_REPO_DEFAULT_BRANCH": m.Repo.DefaultBranch, - "CI_REPO_PRIVATE": strconv.FormatBool(m.Repo.Private), - "CI_REPO_TRUSTED": "false", // TODO should this be added? - "CI_REMOTE_URL": m.Repo.Remote, - "CI_BUILD_NUMBER": strconv.Itoa(m.Curr.Number), - "CI_PARENT_BUILD_NUMBER": strconv.Itoa(m.Curr.Parent), - "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), - "CI_BUILD_STATUS": m.Curr.Status, - "CI_BUILD_EVENT": m.Curr.Event, - "CI_BUILD_LINK": m.Curr.Link, - "CI_BUILD_TARGET": m.Curr.Target, - "CI_COMMIT_SHA": m.Curr.Commit.Sha, - "CI_COMMIT_REF": m.Curr.Commit.Ref, - "CI_COMMIT_REFSPEC": m.Curr.Commit.Refspec, - "CI_COMMIT_BRANCH": m.Curr.Commit.Branch, - "CI_COMMIT_SOURCE_BRANCH": sourceBranch, - "CI_COMMIT_TARGET_BRANCH": targetBranch, - "CI_COMMIT_MESSAGE": m.Curr.Commit.Message, - "CI_COMMIT_AUTHOR": m.Curr.Commit.Author.Name, - "CI_COMMIT_AUTHOR_NAME": m.Curr.Commit.Author.Name, - "CI_COMMIT_AUTHOR_EMAIL": m.Curr.Commit.Author.Email, - "CI_COMMIT_AUTHOR_AVATAR": m.Curr.Commit.Author.Avatar, - "CI_PREV_BUILD_NUMBER": strconv.Itoa(m.Prev.Number), - "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), - "CI_PREV_BUILD_STATUS": m.Prev.Status, - "CI_PREV_BUILD_EVENT": m.Prev.Event, - "CI_PREV_BUILD_LINK": m.Prev.Link, + "CI": m.Sys.Name, + "CI_REPO": m.Repo.Name, + "CI_REPO_OWNER": repoOwner, + "CI_REPO_NAME": repoName, + "CI_REPO_SCM": "git", + "CI_REPO_LINK": m.Repo.Link, + "CI_REPO_REMOTE": m.Repo.Remote, + "CI_REPO_DEFAULT_BRANCH": m.Repo.DefaultBranch, + "CI_REPO_PRIVATE": strconv.FormatBool(m.Repo.Private), + "CI_REPO_TRUSTED": "false", // TODO should this be added? + + "CI_COMMIT_SHA": m.Curr.Commit.Sha, + "CI_COMMIT_REF": m.Curr.Commit.Ref, + "CI_COMMIT_REFSPEC": m.Curr.Commit.Refspec, + "CI_COMMIT_BRANCH": m.Curr.Commit.Branch, + "CI_COMMIT_SOURCE_BRANCH": sourceBranch, + "CI_COMMIT_TARGET_BRANCH": targetBranch, + "CI_COMMIT_LINK": m.Curr.Link, + "CI_COMMIT_MESSAGE": m.Curr.Commit.Message, + "CI_COMMIT_AUTHOR": m.Curr.Commit.Author.Name, + "CI_COMMIT_AUTHOR_EMAIL": m.Curr.Commit.Author.Email, + "CI_COMMIT_AUTHOR_AVATAR": m.Curr.Commit.Author.Avatar, + "CI_COMMIT_TAG": "", // will be set if event is tag + "CI_COMMIT_PULL_REQUEST": "", // will be set if event is pr + + "CI_BUILD_NUMBER": strconv.Itoa(m.Curr.Number), + "CI_BUILD_PARENT": strconv.Itoa(m.Curr.Parent), + "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), + "CI_JOB_NUMBER": strconv.Itoa(m.Job.Number), + "CI_JOB_STARTED": strconv.FormatInt(m.Curr.Started, 10), // ISSUE: no job started + "CI_PREV_COMMIT_SHA": m.Prev.Commit.Sha, "CI_PREV_COMMIT_REF": m.Prev.Commit.Ref, "CI_PREV_COMMIT_REFSPEC": m.Prev.Commit.Refspec, "CI_PREV_COMMIT_BRANCH": m.Prev.Commit.Branch, + "CI_PREV_COMMIT_LINK": m.Prev.Link, "CI_PREV_COMMIT_MESSAGE": m.Prev.Commit.Message, "CI_PREV_COMMIT_AUTHOR": m.Prev.Commit.Author.Name, - "CI_PREV_COMMIT_AUTHOR_NAME": m.Prev.Commit.Author.Name, "CI_PREV_COMMIT_AUTHOR_EMAIL": m.Prev.Commit.Author.Email, "CI_PREV_COMMIT_AUTHOR_AVATAR": m.Prev.Commit.Author.Avatar, - "CI_JOB_NUMBER": strconv.Itoa(m.Job.Number), - "CI_JOB_STARTED": strconv.FormatInt(m.Curr.Started, 10), // ISSUE: no job started - "CI_SYSTEM": m.Sys.Name, - "CI_SYSTEM_NAME": m.Sys.Name, - "CI_SYSTEM_LINK": m.Sys.Link, - "CI_SYSTEM_HOST": m.Sys.Host, - "CI_SYSTEM_ARCH": m.Sys.Arch, - "CI_SYSTEM_VERSION": m.Sys.Version, + + "CI_PREV_BUILD_NUMBER": strconv.Itoa(m.Prev.Number), + "CI_PREV_BUILD_PARENT": strconv.Itoa(m.Prev.Parent), + "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), + + "CI_SYSTEM_NAME": m.Sys.Name, + "CI_SYSTEM_LINK": m.Sys.Link, + "CI_SYSTEM_HOST": m.Sys.Host, + "CI_SYSTEM_ARCH": m.Sys.Arch, + "CI_SYSTEM_VERSION": m.Sys.Version, } if m.Curr.Event == EventTag { - params["CI_TAG"] = strings.TrimPrefix(m.Curr.Commit.Ref, "refs/tags/") + params["CI_COMMIT_TAG"] = strings.TrimPrefix(m.Curr.Commit.Ref, "refs/tags/") } if m.Curr.Event == EventPull { - params["CI_PULL_REQUEST"] = pullRegexp.FindString(m.Curr.Commit.Ref) + params["CI_COMMIT_PULL_REQUEST"] = pullRegexp.FindString(m.Curr.Commit.Ref) } return params } diff --git a/server/shared/procBuilder.go b/server/shared/procBuilder.go index 1a80421763..52ea600cc5 100644 --- a/server/shared/procBuilder.go +++ b/server/shared/procBuilder.go @@ -349,10 +349,11 @@ func metadataFromStruct(repo *model.Repo, build, last *model.Build, proc *model. Matrix: proc.Environ, }, Sys: frontend.System{ - Name: "woodpecker", - Link: link, - Host: host, - Arch: "linux/amd64", + Name: "woodpecker", + Link: link, + Host: host, + Arch: "linux/amd64", // TODO: use current arch + Version: "", // TODO: use current version }, } } From 9aa1dcfb1310bc9c7fc78d4e46e6f4385d944974 Mon Sep 17 00:00:00 2001 From: Anton Bracke Date: Sun, 10 Oct 2021 13:58:06 +0200 Subject: [PATCH 03/12] improve var names and docs --- .woodpecker/helm.yml | 2 +- .woodpecker/main.yml | 14 +- Makefile | 4 +- cli/exec/flags.go | 84 +++++------ docs/docs/20-usage/50-environment.md | 138 +++++++++--------- docs/docs/91-migrations.md | 24 ++- pipeline/frontend/metadata.go | 4 +- pipeline/samples/sample_1/.env | 1 - pipeline/samples/sample_1/pipeline.json | 2 - pipeline/samples/sample_10_windows/.env | 1 - .../samples/sample_10_windows/pipeline.json | 2 - pipeline/samples/sample_2/.env | 1 - pipeline/samples/sample_2/pipeline.json | 3 - pipeline/samples/sample_3/.env | 2 - pipeline/samples/sample_3/pipeline.json | 3 - pipeline/samples/sample_4/.env | 1 - pipeline/samples/sample_4/pipeline.json | 3 - pipeline/samples/sample_5/.env | 1 - pipeline/samples/sample_5/pipeline.json | 6 - pipeline/samples/sample_6/.env | 1 - pipeline/samples/sample_6/pipeline.json | 3 - pipeline/samples/sample_9_cache/.env | 2 - pipeline/samples/sample_9_cache/pipeline.json | 4 - 23 files changed, 146 insertions(+), 160 deletions(-) diff --git a/.woodpecker/helm.yml b/.woodpecker/helm.yml index e500370fa2..8d20a1afda 100644 --- a/.woodpecker/helm.yml +++ b/.woodpecker/helm.yml @@ -7,7 +7,7 @@ pipeline: image: alpine/helm:3.5.3 commands: # use tag name or 0.0.0 if not running on a tag - - export CHART_VERSION="${CI_TAG##v}" + - export CHART_VERSION="${CI_COMMIT_TAG##v}" - export CHART_VERSION=$${CHART_VERSION:=0.0.0} - echo "Version $CHART_VERSION" - sed -i "s//$CHART_VERSION/g" charts/woodpecker-agent/Chart.yaml diff --git a/.woodpecker/main.yml b/.woodpecker/main.yml index b58bfb0653..a7852ce9cd 100644 --- a/.woodpecker/main.yml +++ b/.woodpecker/main.yml @@ -137,7 +137,7 @@ pipeline: repo: woodpeckerci/woodpecker-server dockerfile: docker/Dockerfile.server secrets: [docker_username, docker_password] - tag: [latest, "${CI_TAG}"] + tag: [latest, "${CI_COMMIT_TAG}"] when: event: tag @@ -147,7 +147,7 @@ pipeline: repo: woodpeckerci/woodpecker-server dockerfile: docker/Dockerfile.server.alpine secrets: [ docker_username, docker_password ] - tag: [latest-alpine, "${CI_TAG}-alpine"] + tag: [latest-alpine, "${CI_COMMIT_TAG}-alpine"] when: event: tag @@ -157,7 +157,7 @@ pipeline: repo: woodpeckerci/woodpecker-agent dockerfile: docker/Dockerfile.agent secrets: [docker_username, docker_password] - tag: [latest, "${CI_TAG}"] + tag: [latest, "${CI_COMMIT_TAG}"] when: event: tag @@ -167,7 +167,7 @@ pipeline: repo: woodpeckerci/woodpecker-agent dockerfile: docker/Dockerfile.agent.alpine secrets: [ docker_username, docker_password ] - tag: [latest-alpine, "${CI_TAG}-alpine"] + tag: [latest-alpine, "${CI_COMMIT_TAG}-alpine"] when: event: tag @@ -177,7 +177,7 @@ pipeline: repo: woodpeckerci/woodpecker-cli dockerfile: docker/Dockerfile.cli secrets: [docker_username, docker_password] - tag: [latest, "${CI_TAG}"] + tag: [latest, "${CI_COMMIT_TAG}"] when: event: tag @@ -187,7 +187,7 @@ pipeline: repo: woodpeckerci/woodpecker-cli dockerfile: docker/Dockerfile.cli.alpine secrets: [ docker_username, docker_password ] - tag: [latest-alpine, "${CI_TAG}-alpine"] + tag: [latest-alpine, "${CI_COMMIT_TAG}-alpine"] when: event: tag @@ -205,7 +205,7 @@ pipeline: files: - dist/*.tar.gz - dist/checksums.txt - title: ${CI_TAG##v} + title: ${CI_COMMIT_TAG##v} secrets: - source: github_token target: github_release_api_key diff --git a/Makefile b/Makefile index f9ce19315b..463d57e309 100644 --- a/Makefile +++ b/Makefile @@ -3,8 +3,8 @@ GOFILES_NOVENDOR = $(shell find . -type f -name '*.go' -not -path "./vendor/*" - GO_PACKAGES ?= $(shell go list ./... | grep -v /vendor/) VERSION ?= next -ifneq ($(CI_TAG),) - VERSION := $(CI_TAG:v%=%) +ifneq ($(CI_COMMIT_TAG),) + VERSION := $(CI_COMMIT_TAG:v%=%) endif # append commit-sha to next version diff --git a/cli/exec/flags.go b/cli/exec/flags.go index b8e89fbd96..e860bb6893 100644 --- a/cli/exec/flags.go +++ b/cli/exec/flags.go @@ -96,166 +96,166 @@ var flags = []cli.Flag{ // metadata parameters // cli.StringFlag{ - EnvVar: "WOODPECKER_SYSTEM_ARCH", + EnvVar: "CI_SYSTEM_ARCH", Name: "system-arch", Value: "linux/amd64", }, cli.StringFlag{ - EnvVar: "WOODPECKER_SYSTEM_NAME", + EnvVar: "CI_SYSTEM_NAME", Name: "system-name", - Value: "pipec", + Value: "woodpecker-cli", }, cli.StringFlag{ - EnvVar: "WOODPECKER_SYSTEM_LINK", + EnvVar: "CI_SYSTEM_LINK", Name: "system-link", - Value: "https://github.com/cncd/pipec", + Value: "https://github.com/woodpecker-ci/woodpecker", }, cli.StringFlag{ - EnvVar: "WOODPECKER_REPO_NAME", + EnvVar: "CI_REPO_NAME", Name: "repo-name", }, cli.StringFlag{ - EnvVar: "WOODPECKER_REPO_LINK", + EnvVar: "CI_REPO_LINK", Name: "repo-link", }, cli.StringFlag{ - EnvVar: "WOODPECKER_REPO_REMOTE", + EnvVar: "CI_REPO_REMOTE", Name: "repo-remote-url", }, cli.StringFlag{ - EnvVar: "WOODPECKER_REPO_PRIVATE", + EnvVar: "CI_REPO_PRIVATE", Name: "repo-private", }, cli.IntFlag{ - EnvVar: "WOODPECKER_BUILD_NUMBER", + EnvVar: "CI_BUILD_NUMBER", Name: "build-number", }, cli.IntFlag{ - EnvVar: "WOODPECKER_PARENT_BUILD_NUMBER", + EnvVar: "CI_PARENT_BUILD_NUMBER", Name: "parent-build-number", }, cli.Int64Flag{ - EnvVar: "WOODPECKER_BUILD_CREATED", + EnvVar: "CI_BUILD_CREATED", Name: "build-created", }, cli.Int64Flag{ - EnvVar: "WOODPECKER_BUILD_STARTED", + EnvVar: "CI_BUILD_STARTED", Name: "build-started", }, cli.Int64Flag{ - EnvVar: "WOODPECKER_BUILD_FINISHED", + EnvVar: "CI_BUILD_FINISHED", Name: "build-finished", }, cli.StringFlag{ - EnvVar: "WOODPECKER_BUILD_STATUS", + EnvVar: "CI_BUILD_STATUS", Name: "build-status", }, cli.StringFlag{ - EnvVar: "WOODPECKER_BUILD_EVENT", + EnvVar: "CI_BUILD_EVENT", Name: "build-event", }, cli.StringFlag{ - EnvVar: "WOODPECKER_BUILD_LINK", + EnvVar: "CI_BUILD_LINK", Name: "build-link", }, cli.StringFlag{ - EnvVar: "WOODPECKER_BUILD_TARGET", + EnvVar: "CI_BUILD_TARGET", Name: "build-target", }, cli.StringFlag{ - EnvVar: "WOODPECKER_COMMIT_SHA", + EnvVar: "CI_COMMIT_SHA", Name: "commit-sha", }, cli.StringFlag{ - EnvVar: "WOODPECKER_COMMIT_REF", + EnvVar: "CI_COMMIT_REF", Name: "commit-ref", }, cli.StringFlag{ - EnvVar: "WOODPECKER_COMMIT_REFSPEC", + EnvVar: "CI_COMMIT_REFSPEC", Name: "commit-refspec", }, cli.StringFlag{ - EnvVar: "WOODPECKER_COMMIT_BRANCH", + EnvVar: "CI_COMMIT_BRANCH", Name: "commit-branch", }, cli.StringFlag{ - EnvVar: "WOODPECKER_COMMIT_MESSAGE", + EnvVar: "CI_COMMIT_MESSAGE", Name: "commit-message", }, cli.StringFlag{ - EnvVar: "WOODPECKER_COMMIT_AUTHOR_NAME", + EnvVar: "CI_COMMIT_AUTHOR", Name: "commit-author-name", }, cli.StringFlag{ - EnvVar: "WOODPECKER_COMMIT_AUTHOR_AVATAR", + EnvVar: "CI_COMMIT_AUTHOR_AVATAR", Name: "commit-author-avatar", }, cli.StringFlag{ - EnvVar: "WOODPECKER_COMMIT_AUTHOR_EMAIL", + EnvVar: "CI_COMMIT_AUTHOR_EMAIL", Name: "commit-author-email", }, cli.IntFlag{ - EnvVar: "WOODPECKER_PREV_BUILD_NUMBER", + EnvVar: "CI_PREV_BUILD_NUMBER", Name: "prev-build-number", }, cli.Int64Flag{ - EnvVar: "WOODPECKER_PREV_BUILD_CREATED", + EnvVar: "CI_PREV_BUILD_CREATED", Name: "prev-build-created", }, cli.Int64Flag{ - EnvVar: "WOODPECKER_PREV_BUILD_STARTED", + EnvVar: "CI_PREV_BUILD_STARTED", Name: "prev-build-started", }, cli.Int64Flag{ - EnvVar: "WOODPECKER_PREV_BUILD_FINISHED", + EnvVar: "CI_PREV_BUILD_FINISHED", Name: "prev-build-finished", }, cli.StringFlag{ - EnvVar: "WOODPECKER_PREV_BUILD_STATUS", + EnvVar: "CI_PREV_BUILD_STATUS", Name: "prev-build-status", }, cli.StringFlag{ - EnvVar: "WOODPECKER_PREV_BUILD_EVENT", + EnvVar: "CI_PREV_BUILD_EVENT", Name: "prev-build-event", }, cli.StringFlag{ - EnvVar: "WOODPECKER_PREV_BUILD_LINK", + EnvVar: "CI_PREV_BUILD_LINK", Name: "prev-build-link", }, cli.StringFlag{ - EnvVar: "WOODPECKER_PREV_COMMIT_SHA", + EnvVar: "CI_PREV_COMMIT_SHA", Name: "prev-commit-sha", }, cli.StringFlag{ - EnvVar: "WOODPECKER_PREV_COMMIT_REF", + EnvVar: "CI_PREV_COMMIT_REF", Name: "prev-commit-ref", }, cli.StringFlag{ - EnvVar: "WOODPECKER_PREV_COMMIT_REFSPEC", + EnvVar: "CI_PREV_COMMIT_REFSPEC", Name: "prev-commit-refspec", }, cli.StringFlag{ - EnvVar: "WOODPECKER_PREV_COMMIT_BRANCH", + EnvVar: "CI_PREV_COMMIT_BRANCH", Name: "prev-commit-branch", }, cli.StringFlag{ - EnvVar: "WOODPECKER_PREV_COMMIT_MESSAGE", + EnvVar: "CI_PREV_COMMIT_MESSAGE", Name: "prev-commit-message", }, cli.StringFlag{ - EnvVar: "WOODPECKER_PREV_COMMIT_AUTHOR_NAME", + EnvVar: "CI_PREV_COMMIT_AUTHOR", Name: "prev-commit-author-name", }, cli.StringFlag{ - EnvVar: "WOODPECKER_PREV_COMMIT_AUTHOR_AVATAR", + EnvVar: "CI_PREV_COMMIT_AUTHOR_AVATAR", Name: "prev-commit-author-avatar", }, cli.StringFlag{ - EnvVar: "WOODPECKER_PREV_COMMIT_AUTHOR_EMAIL", + EnvVar: "CI_PREV_COMMIT_AUTHOR_EMAIL", Name: "prev-commit-author-email", }, cli.IntFlag{ - EnvVar: "WOODPECKER_JOB_NUMBER", + EnvVar: "CI_BUILD_JOB_NUMBER", Name: "job-number", }, cli.StringSliceFlag{ diff --git a/docs/docs/20-usage/50-environment.md b/docs/docs/20-usage/50-environment.md index 93b8c764e9..07cb0ab738 100644 --- a/docs/docs/20-usage/50-environment.md +++ b/docs/docs/20-usage/50-environment.md @@ -46,72 +46,78 @@ pipeline: This is the reference list of all environment variables available to your pipeline containers. These are injected into your pipeline step and plugins containers, at runtime. -| NAME | Description | -| ------------------------------ | ------------------------------------------------------------------------ | -| `CI=woodpecker` | environment is woodpecker | -| `CI_REPO` | repository full name `/` | -| `CI_REPO_OWNER` | repository owner | -| `CI_REPO_NAME` | repository name | -| `CI_REPO_SCM` | repository scm (git) | -| `CI_REPO_LINK` | repository link | -| `CI_REPO_REMOTE` | repository clone url | -| `CI_REPO_DEFAULT_BRANCH` | repository default branch (master) | -| `CI_REPO_PRIVATE` | repository is private | -| `CI_REPO_TRUSTED` | repository is trusted | -| | **Current Commit** | -| `CI_COMMIT_SHA` | commit sha | -| `CI_COMMIT_REF` | commit ref | -| `CI_COMMIT_REFSPEC` | commit ref spec | -| `CI_COMMIT_BRANCH` | commit branch | -| `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_LINK` | commit link in remote | -| `CI_COMMIT_MESSAGE` | commit message | -| `CI_COMMIT_AUTHOR` | commit author username | -| `CI_COMMIT_AUTHOR_EMAIL` | commit author email address | -| `CI_COMMIT_AUTHOR_AVATAR` | commit author avatar | -| | **Current build** | -| `CI_BUILD_NUMBER` | build number | -| `CI_BUILD_PARENT` | build number of parent build | -| `CI_BUILD_EVENT` | build event (push, pull_request, tag, deployment) | -| `CI_BUILD_LINK` | build link in ci | -| `CI_BUILD_DEPLOY_TARGET` | build deploy target for `deployment` events (ie production) | -| `CI_BUILD_STATUS` | build status (success, failure) | -| `CI_BUILD_CREATED` | build created unix timestamp | -| `CI_BUILD_STARTED` | build started unix timestamp | -| `CI_BUILD_FINISHED` | build finished unix timestamp | -| `CI_BUILD_JOB_NUMBER` | build-job number | -| `CI_BUILD_JOB_STARTED` | build-job started unix timestamp | -| | **Previous commit** | -| `CI_PREV_COMMIT_SHA` | previous commit sha | -| `CI_PREV_COMMIT_REF` | previous commit ref | -| `CI_PREV_COMMIT_REFSPEC` | previous commit ref spec | -| `CI_PREV_COMMIT_BRANCH` | previous commit branch | -| `CI_PREV_COMMIT_SOURCE_BRANCH` | previous commit source branch | -| `CI_PREV_COMMIT_TARGET_BRANCH` | previous commit target branch | -| `CI_PREV_COMMIT_LINK` | previous commit link in remote | -| `CI_PREV_COMMIT_MESSAGE` | previous commit message | -| `CI_PREV_COMMIT_AUTHOR` | previous commit author username | -| `CI_PREV_COMMIT_AUTHOR_EMAIL` | previous commit author email address | -| `CI_PREV_COMMIT_AUTHOR_AVATAR` | previous commit author avatar | -| | **Previous build** | -| `CI_PREV_BUILD_NUMBER` | previous build number | -| `CI_PREV_BUILD_PARENT` | previous build number of parent build | -| `CI_PREV_BUILD_EVENT` | previous build event (push, pull_request, tag, deployment) | -| `CI_PREV_BUILD_LINK` | previous build link in ci | -| `CI_PREV_BUILD_DEPLOY_TARGET` | previous build deploy target for `deployment` events (ie production) | -| `CI_PREV_BUILD_STATUS` | previous build status (success, failure) | -| `CI_PREV_BUILD_CREATED` | previous build created unix timestamp | -| `CI_PREV_BUILD_STARTED` | previous build started unix timestamp | -| `CI_PREV_BUILD_FINISHED` | previous build finished unix timestamp | -| | **System** | -| `CI_SYSTEM_NAME` | name of the ci system (woodpecker) | -| `CI_SYSTEM_LINK` | link to ci system | -| `CI_SYSTEM_HOST` | hostname of ci system server | -| `CI_SYSTEM_ARCH` | architecture of agent (defined in pipeline file, default: `linux/amd64`) | -| `CI_SYSTEM_VERSION` | todo | +| NAME | Description | +| ------------------------------ | -------------------------------------------------------------------- | +| `CI=woodpecker` | environment is woodpecker | +| | **Repository** | +| `CI_REPO` | repository full name `/` | +| `CI_REPO_OWNER` | repository owner | +| `CI_REPO_NAME` | repository name | +| `CI_REPO_SCM` | repository scm (git) | +| `CI_REPO_LINK` | repository link | +| `CI_REPO_REMOTE` | repository clone url | +| `CI_REPO_DEFAULT_BRANCH` | repository default branch (master) | +| `CI_REPO_PRIVATE` | repository is private | +| `CI_REPO_TRUSTED` | repository is trusted | +| | **Current Commit** | +| `CI_COMMIT_SHA` | commit sha | +| `CI_COMMIT_REF` | commit ref | +| `CI_COMMIT_REFSPEC` | commit ref spec | +| `CI_COMMIT_BRANCH` | commit branch | +| `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_LINK` | commit link in remote | +| `CI_COMMIT_MESSAGE` | commit message | +| `CI_COMMIT_AUTHOR` | commit author username | +| `CI_COMMIT_AUTHOR_EMAIL` | commit author email address | +| `CI_COMMIT_AUTHOR_AVATAR` | commit author avatar | +| | **Current build** | +| `CI_BUILD_NUMBER` | build number | +| `CI_BUILD_PARENT` | build number of parent build | +| `CI_BUILD_EVENT` | build event (push, pull_request, tag, deployment) | +| `CI_BUILD_LINK` | build link in ci | +| `CI_BUILD_DEPLOY_TARGET` | build deploy target for `deployment` events (ie production) | +| `CI_BUILD_STATUS` | build status (success, failure) | +| `CI_BUILD_CREATED` | build created unix timestamp | +| `CI_BUILD_STARTED` | build started unix timestamp | +| `CI_BUILD_FINISHED` | build finished unix timestamp | +| `CI_BUILD_JOB_NUMBER` | build-job number | +| `CI_BUILD_JOB_STARTED` | build-job started unix timestamp (TODO: same as build started atm) | +| | **Previous commit** | +| `CI_PREV_COMMIT_SHA` | previous commit sha | +| `CI_PREV_COMMIT_REF` | previous commit ref | +| `CI_PREV_COMMIT_REFSPEC` | previous commit ref spec | +| `CI_PREV_COMMIT_BRANCH` | previous commit branch | +| `CI_PREV_COMMIT_SOURCE_BRANCH` | previous commit source branch | +| `CI_PREV_COMMIT_TARGET_BRANCH` | previous commit target branch | +| `CI_PREV_COMMIT_LINK` | previous commit link in remote | +| `CI_PREV_COMMIT_MESSAGE` | previous commit message | +| `CI_PREV_COMMIT_AUTHOR` | previous commit author username | +| `CI_PREV_COMMIT_AUTHOR_EMAIL` | previous commit author email address | +| `CI_PREV_COMMIT_AUTHOR_AVATAR` | previous commit author avatar | +| | **Previous build** | +| `CI_PREV_BUILD_NUMBER` | previous build number | +| `CI_PREV_BUILD_PARENT` | previous build number of parent build | +| `CI_PREV_BUILD_EVENT` | previous build event (push, pull_request, tag, deployment) | +| `CI_PREV_BUILD_LINK` | previous build link in ci | +| `CI_PREV_BUILD_DEPLOY_TARGET` | previous build deploy target for `deployment` events (ie production) | +| `CI_PREV_BUILD_STATUS` | previous build status (success, failure) | +| `CI_PREV_BUILD_CREATED` | previous build created unix timestamp | +| `CI_PREV_BUILD_STARTED` | previous build started unix timestamp | +| `CI_PREV_BUILD_FINISHED` | previous build finished unix timestamp | +| | **System** | +| `CI_SYSTEM_NAME` | name of the ci system: `woodpecker` | +| `CI_SYSTEM_LINK` | link to ci system | +| `CI_SYSTEM_HOST` | hostname of ci server | +| `CI_SYSTEM_VERSION` | TODO | +| | **Agent** this pipeline step is running on | +| `CI_AGENT_NAME` | TODO | +| `CI_AGENT_HOST` | TODO | +| `CI_AGENT_OS` | TODO | +| `CI_AGENT_ARCH` | TODO | +| `CI_AGENT_VERSION` | TODO | ## Global environment variables diff --git a/docs/docs/91-migrations.md b/docs/docs/91-migrations.md index 86895d343f..7339445795 100644 --- a/docs/docs/91-migrations.md +++ b/docs/docs/91-migrations.md @@ -12,6 +12,9 @@ Some versions need some changes to the server configuration or the pipeline conf Read more about it at the [Project Settings](/docs/usage/project-settings#pipeline-path) +- From version `0.15.0` ongoing there will be three types of docker images: `latest`, `next` and `x.x.x` with an alpine variant for each type like `latest-alpine`. + If you used `latest` before to try pre-release features you should switch to `next` after this release. + - Dropped support for `DRONE_*` environment variables. The according `WOODPECKER_*` variables must be used instead. Additionally some alternative namings have been removed to simplify maintenance: - `WOODPECKER_AGENT_SECRET` replaces `WOODPECKER_SECRET`, `DRONE_SECRET`, `WOODPECKER_PASSWORD`, `DRONE_PASSWORD` and `DRONE_AGENT_SECRET`. @@ -19,10 +22,23 @@ Some versions need some changes to the server configuration or the pipeline conf - `WOODPECKER_DATABASE_DRIVER` replaces `DRONE_DATABASE_DRIVER` and `DATABASE_DRIVER`. - `WOODPECKER_DATABASE_DATASOURCE` replaces `DRONE_DATABASE_DATASOURCE` and `DATABASE_CONFIG`. -- From version `0.15.0` ongoing there will be three types of docker images: `latest`, `next` and `x.x.x` with an alpine variant for each type like `latest-alpine`. - If you used `latest` before to try pre-release features you should switch to `next` after this release. - -- Dropped support for `DRONE_*` environment variables in pipeline steps. Pipeline meta-data can be accessed with `CI_*` variables. Please have a look at [built-in-environment-variables](/docs/usage/environment#built-in-environment-variables) for all available variables and their descriptions. +- Dropped support for `DRONE_*` environment variables in pipeline steps. Pipeline meta-data can be accessed with `CI_*` variables. + - `CI_*` prefix replaces `DRONE_*` + - `CI` value is now `woodpecker` + - `DRONE=true` has been removed + - Use `CI_REPO_DEFAULT_BRANCH` instead of `*_REPO_BRANCH` + - Use `CI_COMMIT_BRANCH`, `CI_COMMIT_SOURCE_BRANCH` and `CI_COMMIT_TARGET_BRANCH` instead of `DRONE_BRANCH`, `DRONE_TARGET_BRANCH` and `DRONE_SOURCE_BRANCH` variables + - Use `CI_COMMIT_AUTHOR` instead of `*_COMMIT_AUTHOR_NAME` + - Use `CI_BUILD_PARENT` instead of `` + - Use `CI_COMMIT_TAG` instead of `DRONE_TAG` + - Use `CI_COMMIT_PULL_REQUEST` instead of `DRONE_PULL_REQUEST` + - Use `CI_BUILD_DEPLOY_TARGET` instead of `DRONE_DEPLOY_TO` + - Use `CI_REPO_REMOTE` instead of `DRONE_REMOTE_URL` + - Use `CI_SYS_ARCH` instead of `DRONE_ARCH` + - Use `CI_COMMIT_SHA` instead of `DRONE_COMMIT` + - Use `CI_BUILD_JOB_*` instead of `DRONE_JOB_*` + + For all available variables and their descriptions have a look at [built-in-environment-variables](/docs/usage/environment#built-in-environment-variables). - ... diff --git a/pipeline/frontend/metadata.go b/pipeline/frontend/metadata.go index adb361f692..c1fc8137f5 100644 --- a/pipeline/frontend/metadata.go +++ b/pipeline/frontend/metadata.go @@ -151,8 +151,8 @@ func (m *Metadata) Environ() map[string]string { "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), - "CI_JOB_NUMBER": strconv.Itoa(m.Job.Number), - "CI_JOB_STARTED": strconv.FormatInt(m.Curr.Started, 10), // ISSUE: no job started + "CI_BUILD_JOB_NUMBER": strconv.Itoa(m.Job.Number), + "CI_BUILD_JOB_STARTED": strconv.FormatInt(m.Curr.Started, 10), // ISSUE: no job started "CI_PREV_COMMIT_SHA": m.Prev.Commit.Sha, "CI_PREV_COMMIT_REF": m.Prev.Commit.Ref, diff --git a/pipeline/samples/sample_1/.env b/pipeline/samples/sample_1/.env index 50dfaf1b86..c6c64ae693 100644 --- a/pipeline/samples/sample_1/.env +++ b/pipeline/samples/sample_1/.env @@ -14,4 +14,3 @@ CI_COMMIT_REFSPEC= CI_COMMIT_BRANCH=master CI_COMMIT_MESSAGE="added a few more test cases for escaping behavior" CI_COMMIT_AUTHOR=bradrydzewski -CI_COMMIT_AUTHOR_NAME=bradrydzewski diff --git a/pipeline/samples/sample_1/pipeline.json b/pipeline/samples/sample_1/pipeline.json index 127b38e1f0..33400c6aae 100644 --- a/pipeline/samples/sample_1/pipeline.json +++ b/pipeline/samples/sample_1/pipeline.json @@ -16,7 +16,6 @@ "CI_BUILD_NUMBER": "6", "CI_BUILD_STARTED": "1486119585", "CI_COMMIT_AUTHOR": "bradrydzewski", - "CI_COMMIT_AUTHOR_NAME": "bradrydzewski", "CI_COMMIT_BRANCH": "master", "CI_COMMIT_MESSAGE": "added a few more test cases for escaping behavior", "CI_COMMIT_REF": "refs/heads/master", @@ -61,7 +60,6 @@ "CI_BUILD_NUMBER": "6", "CI_BUILD_STARTED": "1486119585", "CI_COMMIT_AUTHOR": "bradrydzewski", - "CI_COMMIT_AUTHOR_NAME": "bradrydzewski", "CI_COMMIT_BRANCH": "master", "CI_COMMIT_MESSAGE": "added a few more test cases for escaping behavior", "CI_COMMIT_REF": "refs/heads/master", diff --git a/pipeline/samples/sample_10_windows/.env b/pipeline/samples/sample_10_windows/.env index 50dfaf1b86..c6c64ae693 100644 --- a/pipeline/samples/sample_10_windows/.env +++ b/pipeline/samples/sample_10_windows/.env @@ -14,4 +14,3 @@ CI_COMMIT_REFSPEC= CI_COMMIT_BRANCH=master CI_COMMIT_MESSAGE="added a few more test cases for escaping behavior" CI_COMMIT_AUTHOR=bradrydzewski -CI_COMMIT_AUTHOR_NAME=bradrydzewski diff --git a/pipeline/samples/sample_10_windows/pipeline.json b/pipeline/samples/sample_10_windows/pipeline.json index bb0e46d7f2..285d9a95d3 100644 --- a/pipeline/samples/sample_10_windows/pipeline.json +++ b/pipeline/samples/sample_10_windows/pipeline.json @@ -16,7 +16,6 @@ "CI_BUILD_NUMBER": "6", "CI_BUILD_STARTED": "1486119585", "CI_COMMIT_AUTHOR": "bradrydzewski", - "CI_COMMIT_AUTHOR_NAME": "bradrydzewski", "CI_COMMIT_BRANCH": "master", "CI_COMMIT_MESSAGE": "added a few more test cases for escaping behavior", "CI_COMMIT_REF": "refs/heads/master", @@ -68,7 +67,6 @@ "CI_BUILD_NUMBER": "6", "CI_BUILD_STARTED": "1486119585", "CI_COMMIT_AUTHOR": "bradrydzewski", - "CI_COMMIT_AUTHOR_NAME": "bradrydzewski", "CI_COMMIT_BRANCH": "master", "CI_COMMIT_MESSAGE": "added a few more test cases for escaping behavior", "CI_COMMIT_REF": "refs/heads/master", diff --git a/pipeline/samples/sample_2/.env b/pipeline/samples/sample_2/.env index b4799f93fe..41db77b718 100644 --- a/pipeline/samples/sample_2/.env +++ b/pipeline/samples/sample_2/.env @@ -14,4 +14,3 @@ CI_COMMIT_REFSPEC= CI_COMMIT_BRANCH=master CI_COMMIT_MESSAGE="Fix many urls" CI_COMMIT_AUTHOR=egorsmkv -CI_COMMIT_AUTHOR_NAME=egorsmkv diff --git a/pipeline/samples/sample_2/pipeline.json b/pipeline/samples/sample_2/pipeline.json index a41c55808c..c4a0bc8dfa 100644 --- a/pipeline/samples/sample_2/pipeline.json +++ b/pipeline/samples/sample_2/pipeline.json @@ -15,7 +15,6 @@ "CI_BUILD_NUMBER": "530", "CI_BUILD_STARTED": "1486119585", "CI_COMMIT_AUTHOR": "egorsmkv", - "CI_COMMIT_AUTHOR_NAME": "egorsmkv", "CI_COMMIT_BRANCH": "master", "CI_COMMIT_MESSAGE": "Fix many urls", "CI_COMMIT_REF": "refs/heads/master", @@ -60,7 +59,6 @@ "CI_BUILD_NUMBER": "530", "CI_BUILD_STARTED": "1486119585", "CI_COMMIT_AUTHOR": "egorsmkv", - "CI_COMMIT_AUTHOR_NAME": "egorsmkv", "CI_COMMIT_BRANCH": "master", "CI_COMMIT_MESSAGE": "Fix many urls", "CI_COMMIT_REF": "refs/heads/master", @@ -106,7 +104,6 @@ "CI_BUILD_NUMBER": "530", "CI_BUILD_STARTED": "1486119585", "CI_COMMIT_AUTHOR": "egorsmkv", - "CI_COMMIT_AUTHOR_NAME": "egorsmkv", "CI_COMMIT_BRANCH": "master", "CI_COMMIT_MESSAGE": "Fix many urls", "CI_COMMIT_REF": "refs/heads/master", diff --git a/pipeline/samples/sample_3/.env b/pipeline/samples/sample_3/.env index 4c1e6ca4b0..c6c64ae693 100644 --- a/pipeline/samples/sample_3/.env +++ b/pipeline/samples/sample_3/.env @@ -14,5 +14,3 @@ CI_COMMIT_REFSPEC= CI_COMMIT_BRANCH=master CI_COMMIT_MESSAGE="added a few more test cases for escaping behavior" CI_COMMIT_AUTHOR=bradrydzewski -CI_COMMIT_AUTHOR_NAME=bradrydzewski - diff --git a/pipeline/samples/sample_3/pipeline.json b/pipeline/samples/sample_3/pipeline.json index c3174e12fd..8c0509a608 100644 --- a/pipeline/samples/sample_3/pipeline.json +++ b/pipeline/samples/sample_3/pipeline.json @@ -16,7 +16,6 @@ "CI_BUILD_NUMBER": "6", "CI_BUILD_STARTED": "1486119585", "CI_COMMIT_AUTHOR": "bradrydzewski", - "CI_COMMIT_AUTHOR_NAME": "bradrydzewski", "CI_COMMIT_BRANCH": "master", "CI_COMMIT_MESSAGE": "added a few more test cases for escaping behavior", "CI_COMMIT_REF": "refs/heads/master", @@ -61,7 +60,6 @@ "CI_BUILD_NUMBER": "6", "CI_BUILD_STARTED": "1486119585", "CI_COMMIT_AUTHOR": "bradrydzewski", - "CI_COMMIT_AUTHOR_NAME": "bradrydzewski", "CI_COMMIT_BRANCH": "master", "CI_COMMIT_MESSAGE": "added a few more test cases for escaping behavior", "CI_COMMIT_REF": "refs/heads/master", @@ -110,7 +108,6 @@ "CI_BUILD_NUMBER": "6", "CI_BUILD_STARTED": "1486119585", "CI_COMMIT_AUTHOR": "bradrydzewski", - "CI_COMMIT_AUTHOR_NAME": "bradrydzewski", "CI_COMMIT_BRANCH": "master", "CI_COMMIT_MESSAGE": "added a few more test cases for escaping behavior", "CI_COMMIT_REF": "refs/heads/master", diff --git a/pipeline/samples/sample_4/.env b/pipeline/samples/sample_4/.env index 50dfaf1b86..c6c64ae693 100644 --- a/pipeline/samples/sample_4/.env +++ b/pipeline/samples/sample_4/.env @@ -14,4 +14,3 @@ CI_COMMIT_REFSPEC= CI_COMMIT_BRANCH=master CI_COMMIT_MESSAGE="added a few more test cases for escaping behavior" CI_COMMIT_AUTHOR=bradrydzewski -CI_COMMIT_AUTHOR_NAME=bradrydzewski diff --git a/pipeline/samples/sample_4/pipeline.json b/pipeline/samples/sample_4/pipeline.json index d96fdf7a21..9429526c46 100644 --- a/pipeline/samples/sample_4/pipeline.json +++ b/pipeline/samples/sample_4/pipeline.json @@ -16,7 +16,6 @@ "CI_BUILD_NUMBER": "6", "CI_BUILD_STARTED": "1486119585", "CI_COMMIT_AUTHOR": "bradrydzewski", - "CI_COMMIT_AUTHOR_NAME": "bradrydzewski", "CI_COMMIT_BRANCH": "master", "CI_COMMIT_MESSAGE": "added a few more test cases for escaping behavior", "CI_COMMIT_REF": "refs/heads/master", @@ -61,7 +60,6 @@ "CI_BUILD_NUMBER": "6", "CI_BUILD_STARTED": "1486119585", "CI_COMMIT_AUTHOR": "bradrydzewski", - "CI_COMMIT_AUTHOR_NAME": "bradrydzewski", "CI_COMMIT_BRANCH": "master", "CI_COMMIT_MESSAGE": "added a few more test cases for escaping behavior", "CI_COMMIT_REF": "refs/heads/master", @@ -110,7 +108,6 @@ "CI_BUILD_NUMBER": "6", "CI_BUILD_STARTED": "1486119585", "CI_COMMIT_AUTHOR": "bradrydzewski", - "CI_COMMIT_AUTHOR_NAME": "bradrydzewski", "CI_COMMIT_BRANCH": "master", "CI_COMMIT_MESSAGE": "added a few more test cases for escaping behavior", "CI_COMMIT_REF": "refs/heads/master", diff --git a/pipeline/samples/sample_5/.env b/pipeline/samples/sample_5/.env index 50dfaf1b86..c6c64ae693 100644 --- a/pipeline/samples/sample_5/.env +++ b/pipeline/samples/sample_5/.env @@ -14,4 +14,3 @@ CI_COMMIT_REFSPEC= CI_COMMIT_BRANCH=master CI_COMMIT_MESSAGE="added a few more test cases for escaping behavior" CI_COMMIT_AUTHOR=bradrydzewski -CI_COMMIT_AUTHOR_NAME=bradrydzewski diff --git a/pipeline/samples/sample_5/pipeline.json b/pipeline/samples/sample_5/pipeline.json index 6406de69f7..5f6a3057c2 100644 --- a/pipeline/samples/sample_5/pipeline.json +++ b/pipeline/samples/sample_5/pipeline.json @@ -16,7 +16,6 @@ "CI_BUILD_NUMBER": "6", "CI_BUILD_STARTED": "1486119585", "CI_COMMIT_AUTHOR": "bradrydzewski", - "CI_COMMIT_AUTHOR_NAME": "bradrydzewski", "CI_COMMIT_BRANCH": "master", "CI_COMMIT_MESSAGE": "added a few more test cases for escaping behavior", "CI_COMMIT_REF": "refs/heads/master", @@ -61,7 +60,6 @@ "CI_BUILD_NUMBER": "6", "CI_BUILD_STARTED": "1486119585", "CI_COMMIT_AUTHOR": "bradrydzewski", - "CI_COMMIT_AUTHOR_NAME": "bradrydzewski", "CI_COMMIT_BRANCH": "master", "CI_COMMIT_MESSAGE": "added a few more test cases for escaping behavior", "CI_COMMIT_REF": "refs/heads/master", @@ -104,7 +102,6 @@ "CI_BUILD_NUMBER": "6", "CI_BUILD_STARTED": "1486119585", "CI_COMMIT_AUTHOR": "bradrydzewski", - "CI_COMMIT_AUTHOR_NAME": "bradrydzewski", "CI_COMMIT_BRANCH": "master", "CI_COMMIT_MESSAGE": "added a few more test cases for escaping behavior", "CI_COMMIT_REF": "refs/heads/master", @@ -153,7 +150,6 @@ "CI_BUILD_NUMBER": "6", "CI_BUILD_STARTED": "1486119585", "CI_COMMIT_AUTHOR": "bradrydzewski", - "CI_COMMIT_AUTHOR_NAME": "bradrydzewski", "CI_COMMIT_BRANCH": "master", "CI_COMMIT_MESSAGE": "added a few more test cases for escaping behavior", "CI_COMMIT_REF": "refs/heads/master", @@ -202,7 +198,6 @@ "CI_BUILD_NUMBER": "6", "CI_BUILD_STARTED": "1486119585", "CI_COMMIT_AUTHOR": "bradrydzewski", - "CI_COMMIT_AUTHOR_NAME": "bradrydzewski", "CI_COMMIT_BRANCH": "master", "CI_COMMIT_MESSAGE": "added a few more test cases for escaping behavior", "CI_COMMIT_REF": "refs/heads/master", @@ -245,7 +240,6 @@ "CI_BUILD_NUMBER": "6", "CI_BUILD_STARTED": "1486119585", "CI_COMMIT_AUTHOR": "bradrydzewski", - "CI_COMMIT_AUTHOR_NAME": "bradrydzewski", "CI_COMMIT_BRANCH": "master", "CI_COMMIT_MESSAGE": "added a few more test cases for escaping behavior", "CI_COMMIT_REF": "refs/heads/master", diff --git a/pipeline/samples/sample_6/.env b/pipeline/samples/sample_6/.env index 0ca9981bb3..24093cb5be 100644 --- a/pipeline/samples/sample_6/.env +++ b/pipeline/samples/sample_6/.env @@ -14,7 +14,6 @@ CI_COMMIT_REFSPEC= CI_COMMIT_BRANCH=master CI_COMMIT_MESSAGE="added a few more test cases for escaping behavior" CI_COMMIT_AUTHOR=bradrydzewski -CI_COMMIT_AUTHOR_NAME=bradrydzewski # custom secrets SLACK_WEBHOOK=https://slack.com/hooks/xxxxxxxx/yyyyyyyyy diff --git a/pipeline/samples/sample_6/pipeline.json b/pipeline/samples/sample_6/pipeline.json index 473e701bca..f713ca95ac 100644 --- a/pipeline/samples/sample_6/pipeline.json +++ b/pipeline/samples/sample_6/pipeline.json @@ -16,7 +16,6 @@ "CI_BUILD_NUMBER": "6", "CI_BUILD_STARTED": "1486119585", "CI_COMMIT_AUTHOR": "bradrydzewski", - "CI_COMMIT_AUTHOR_NAME": "bradrydzewski", "CI_COMMIT_BRANCH": "master", "CI_COMMIT_MESSAGE": "added a few more test cases for escaping behavior", "CI_COMMIT_REF": "refs/heads/master", @@ -72,7 +71,6 @@ "CI_BUILD_NUMBER": "6", "CI_BUILD_STARTED": "1486119585", "CI_COMMIT_AUTHOR": "bradrydzewski", - "CI_COMMIT_AUTHOR_NAME": "bradrydzewski", "CI_COMMIT_BRANCH": "master", "CI_COMMIT_MESSAGE": "added a few more test cases for escaping behavior", "CI_COMMIT_REF": "refs/heads/master", @@ -131,7 +129,6 @@ "CI_BUILD_NUMBER": "6", "CI_BUILD_STARTED": "1486119585", "CI_COMMIT_AUTHOR": "bradrydzewski", - "CI_COMMIT_AUTHOR_NAME": "bradrydzewski", "CI_COMMIT_BRANCH": "master", "CI_COMMIT_MESSAGE": "added a few more test cases for escaping behavior", "CI_COMMIT_REF": "refs/heads/master", diff --git a/pipeline/samples/sample_9_cache/.env b/pipeline/samples/sample_9_cache/.env index 0b18c35592..75b20778ef 100644 --- a/pipeline/samples/sample_9_cache/.env +++ b/pipeline/samples/sample_9_cache/.env @@ -14,8 +14,6 @@ CI_COMMIT_REFSPEC= CI_COMMIT_BRANCH=master CI_COMMIT_MESSAGE="added a few more test cases for escaping behavior" CI_COMMIT_AUTHOR=bradrydzewski -CI_COMMIT_AUTHOR_NAME=bradrydzewski CI_VOLUME_CACHE=true CI_VOLUME_CACHE_BASE=/cache/drone - diff --git a/pipeline/samples/sample_9_cache/pipeline.json b/pipeline/samples/sample_9_cache/pipeline.json index 716412cd81..6564bfbd10 100644 --- a/pipeline/samples/sample_9_cache/pipeline.json +++ b/pipeline/samples/sample_9_cache/pipeline.json @@ -16,7 +16,6 @@ "CI_BUILD_NUMBER": "6", "CI_BUILD_STARTED": "1486119585", "CI_COMMIT_AUTHOR": "bradrydzewski", - "CI_COMMIT_AUTHOR_NAME": "bradrydzewski", "CI_COMMIT_BRANCH": "master", "CI_COMMIT_MESSAGE": "added a few more test cases for escaping behavior", "CI_COMMIT_REF": "refs/heads/master", @@ -69,7 +68,6 @@ "CI_BUILD_NUMBER": "6", "CI_BUILD_STARTED": "1486119585", "CI_COMMIT_AUTHOR": "bradrydzewski", - "CI_COMMIT_AUTHOR_NAME": "bradrydzewski", "CI_COMMIT_BRANCH": "master", "CI_COMMIT_MESSAGE": "added a few more test cases for escaping behavior", "CI_COMMIT_REF": "refs/heads/master", @@ -129,7 +127,6 @@ "CI_BUILD_NUMBER": "6", "CI_BUILD_STARTED": "1486119585", "CI_COMMIT_AUTHOR": "bradrydzewski", - "CI_COMMIT_AUTHOR_NAME": "bradrydzewski", "CI_COMMIT_BRANCH": "master", "CI_COMMIT_MESSAGE": "added a few more test cases for escaping behavior", "CI_COMMIT_REF": "refs/heads/master", @@ -186,7 +183,6 @@ "CI_BUILD_NUMBER": "6", "CI_BUILD_STARTED": "1486119585", "CI_COMMIT_AUTHOR": "bradrydzewski", - "CI_COMMIT_AUTHOR_NAME": "bradrydzewski", "CI_COMMIT_BRANCH": "master", "CI_COMMIT_MESSAGE": "added a few more test cases for escaping behavior", "CI_COMMIT_REF": "refs/heads/master", From fb2287d4fb78406fedd27ccf5e25af779b7dadfc Mon Sep 17 00:00:00 2001 From: Anton Bracke Date: Tue, 12 Oct 2021 09:59:14 +0200 Subject: [PATCH 04/12] improve metadata structure --- agent/runner.go | 8 +++- cli/exec/flags.go | 10 ++--- docs/docs/20-usage/50-environment.md | 33 ++++++++++------ docs/docs/91-migrations.md | 8 ++-- pipeline/frontend/metadata.go | 59 ++++++++++++++++++---------- 5 files changed, 75 insertions(+), 43 deletions(-) diff --git a/agent/runner.go b/agent/runner.go index 34280bea16..3449c8cd4b 100644 --- a/agent/runner.go +++ b/agent/runner.go @@ -17,8 +17,10 @@ package agent import ( "context" "encoding/json" + "fmt" "io" "io/ioutil" + "runtime" "strconv" "sync" "time" @@ -29,6 +31,7 @@ import ( "github.com/woodpecker-ci/woodpecker/pipeline/backend" "github.com/woodpecker-ci/woodpecker/pipeline/multipart" "github.com/woodpecker-ci/woodpecker/pipeline/rpc" + "github.com/woodpecker-ci/woodpecker/version" "github.com/rs/zerolog/log" "github.com/tevino/abool" @@ -276,7 +279,10 @@ func (r *Runner) Run(ctx context.Context) error { state.Pipeline.Step.Environment = map[string]string{} } - state.Pipeline.Step.Environment["CI_MACHINE"] = r.hostname + // TODO(anbraten): move to helper function and update by changing metadata and exporting again + state.Pipeline.Step.Environment["CI_AGENT_HOST"] = r.hostname + state.Pipeline.Step.Environment["CI_AGENT_ARCH"] = fmt.Sprintf("%s/%s", runtime.GOOS, runtime.GOARCH) + state.Pipeline.Step.Environment["CI_AGENT_VERSION"] = version.Version 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) diff --git a/cli/exec/flags.go b/cli/exec/flags.go index e860bb6893..dae842dde0 100644 --- a/cli/exec/flags.go +++ b/cli/exec/flags.go @@ -68,12 +68,12 @@ var flags = []cli.Flag{ // workspace default // cli.StringFlag{ - EnvVar: "WOODPECKER_WORKSPACE_BASE", + EnvVar: "CI_WORKSPACE_BASE", Name: "workspace-base", Value: "/woodpecker", }, cli.StringFlag{ - EnvVar: "WOODPECKER_WORKSPACE_PATH", + EnvVar: "CI_WORKSPACE_PATH", Name: "workspace-path", Value: "src", }, @@ -81,15 +81,15 @@ var flags = []cli.Flag{ // netrc parameters // cli.StringFlag{ - EnvVar: "WOODPECKER_NETRC_USERNAME", + EnvVar: "CI_NETRC_USERNAME", Name: "netrc-username", }, cli.StringFlag{ - EnvVar: "WOODPECKER_NETRC_PASSWORD", + EnvVar: "CI_NETRC_PASSWORD", Name: "netrc-password", }, cli.StringFlag{ - EnvVar: "WOODPECKER_NETRC_MACHINE", + EnvVar: "CI_NETRC_MACHINE", Name: "netrc-machine", }, // diff --git a/docs/docs/20-usage/50-environment.md b/docs/docs/20-usage/50-environment.md index 07cb0ab738..f6a0c24e78 100644 --- a/docs/docs/20-usage/50-environment.md +++ b/docs/docs/20-usage/50-environment.md @@ -83,8 +83,11 @@ This is the reference list of all environment variables available to your pipeli | `CI_BUILD_CREATED` | build created unix timestamp | | `CI_BUILD_STARTED` | build started unix timestamp | | `CI_BUILD_FINISHED` | build finished unix timestamp | -| `CI_BUILD_JOB_NUMBER` | build-job number | -| `CI_BUILD_JOB_STARTED` | build-job started unix timestamp (TODO: same as build started atm) | +| | **Current job** | +| `CI_JOB_NUMBER` | job number | +| `CI_JOB_STATUS` | job status (success, failure) | +| `CI_JOB_STARTED` | job started unix timestamp | +| `CI_JOB_FINISHED` | job finished unix timestamp | | | **Previous commit** | | `CI_PREV_COMMIT_SHA` | previous commit sha | | `CI_PREV_COMMIT_REF` | previous commit ref | @@ -111,13 +114,19 @@ This is the reference list of all environment variables available to your pipeli | `CI_SYSTEM_NAME` | name of the ci system: `woodpecker` | | `CI_SYSTEM_LINK` | link to ci system | | `CI_SYSTEM_HOST` | hostname of ci server | -| `CI_SYSTEM_VERSION` | TODO | +| `CI_SYSTEM_VERSION` | version of the server | | | **Agent** this pipeline step is running on | -| `CI_AGENT_NAME` | TODO | -| `CI_AGENT_HOST` | TODO | -| `CI_AGENT_OS` | TODO | -| `CI_AGENT_ARCH` | TODO | -| `CI_AGENT_VERSION` | TODO | +| `CI_AGENT_HOST` | hostname of agent | +| `CI_AGENT_ARCH` | arch and os of agent (ie `linux/amd64`) | +| `CI_AGENT_VERSION` | version of the agent | + +### TODO +- CI_WORKSPACE +- CI_SCRIPT +- CI_NETRC_USERNAME +- CI_NETRC_PASSWORD +- CI_NETRC_MACHINE + ## Global environment variables @@ -142,7 +151,7 @@ Example commit substitution: pipeline: docker: image: plugins/docker -+ tags: ${DRONE_COMMIT_SHA} ++ tags: ${CI_COMMIT_SHA} ``` Example tag substitution: @@ -151,7 +160,7 @@ Example tag substitution: pipeline: docker: image: plugins/docker -+ tags: ${DRONE_TAG} ++ tags: ${CI_COMMIT_TAG} ``` ## String Operations @@ -178,7 +187,7 @@ Example variable substitution with substring: pipeline: docker: image: plugins/docker -+ tags: ${DRONE_COMMIT_SHA:0:8} ++ tags: ${CI_COMMIT_SHA:0:8} ``` Example variable substitution strips `v` prefix from `v.1.0.0`: @@ -187,5 +196,5 @@ Example variable substitution strips `v` prefix from `v.1.0.0`: pipeline: docker: image: plugins/docker -+ tags: ${DRONE_TAG##v} ++ tags: ${CI_COMMIT_TAG##v} ``` diff --git a/docs/docs/91-migrations.md b/docs/docs/91-migrations.md index 7339445795..9ebbed93f6 100644 --- a/docs/docs/91-migrations.md +++ b/docs/docs/91-migrations.md @@ -26,17 +26,15 @@ Some versions need some changes to the server configuration or the pipeline conf - `CI_*` prefix replaces `DRONE_*` - `CI` value is now `woodpecker` - `DRONE=true` has been removed - - Use `CI_REPO_DEFAULT_BRANCH` instead of `*_REPO_BRANCH` + - Use `CI_REPO_DEFAULT_BRANCH` instead of `DRONE_REPO_BRANCH` - Use `CI_COMMIT_BRANCH`, `CI_COMMIT_SOURCE_BRANCH` and `CI_COMMIT_TARGET_BRANCH` instead of `DRONE_BRANCH`, `DRONE_TARGET_BRANCH` and `DRONE_SOURCE_BRANCH` variables - - Use `CI_COMMIT_AUTHOR` instead of `*_COMMIT_AUTHOR_NAME` - - Use `CI_BUILD_PARENT` instead of `` + - Use `CI_COMMIT_AUTHOR` instead of `DRONE_COMMIT_AUTHOR_NAME` - Use `CI_COMMIT_TAG` instead of `DRONE_TAG` - Use `CI_COMMIT_PULL_REQUEST` instead of `DRONE_PULL_REQUEST` - Use `CI_BUILD_DEPLOY_TARGET` instead of `DRONE_DEPLOY_TO` - Use `CI_REPO_REMOTE` instead of `DRONE_REMOTE_URL` - - Use `CI_SYS_ARCH` instead of `DRONE_ARCH` + - Use `CI_AGENT_ARCH` instead of `DRONE_ARCH` - Use `CI_COMMIT_SHA` instead of `DRONE_COMMIT` - - Use `CI_BUILD_JOB_*` instead of `DRONE_JOB_*` For all available variables and their descriptions have a look at [built-in-environment-variables](/docs/usage/environment#built-in-environment-variables). diff --git a/pipeline/frontend/metadata.go b/pipeline/frontend/metadata.go index c1fc8137f5..cfe784958f 100644 --- a/pipeline/frontend/metadata.go +++ b/pipeline/frontend/metadata.go @@ -4,6 +4,8 @@ import ( "regexp" "strconv" "strings" + + "github.com/woodpecker-ci/woodpecker/version" ) // Event types corresponding to scm hooks. @@ -17,12 +19,13 @@ const ( type ( // Metadata defines runtime m. Metadata struct { - ID string `json:"id,omitempty"` - Repo Repo `json:"repo,omitempty"` - Curr Build `json:"curr,omitempty"` - Prev Build `json:"prev,omitempty"` - Job Job `json:"job,omitempty"` - Sys System `json:"sys,omitempty"` + ID string `json:"id,omitempty"` + Repo Repo `json:"repo,omitempty"` + Curr Build `json:"curr,omitempty"` + Prev Build `json:"prev,omitempty"` + Job Job `json:"job,omitempty"` + Sys System `json:"sys,omitempty"` + Agent Agent `json:"agent,omitempty"` } // Repo defines runtime metadata for a repository. @@ -71,8 +74,12 @@ type ( // Job defines runtime metadata for a job. Job struct { - Number int `json:"number,omitempty"` - Matrix map[string]string `json:"matrix,omitempty"` + Number int `json:"number,omitempty"` + Matrix map[string]string `json:"matrix,omitempty"` + Status string `json:"status,omitempty"` + Created int64 `json:"created,omitempty"` + Started int64 `json:"started,omitempty"` + Finished int64 `json:"finished,omitempty"` } // Secret defines a runtime secret @@ -85,9 +92,15 @@ type ( // System defines runtime metadata for a ci/cd system. System struct { - Name string `json:"name,omitempty"` + Name string `json:"name,omitempty"` + Host string `json:"host,omitempty"` + Link string `json:"link,omitempty"` + // Arch string `json:"arch,omitempty"` + // Version string `json:"version,omitempty"` + } + + Agent struct { Host string `json:"host,omitempty"` - Link string `json:"link,omitempty"` Arch string `json:"arch,omitempty"` Version string `json:"version,omitempty"` } @@ -151,8 +164,11 @@ func (m *Metadata) Environ() map[string]string { "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), - "CI_BUILD_JOB_NUMBER": strconv.Itoa(m.Job.Number), - "CI_BUILD_JOB_STARTED": strconv.FormatInt(m.Curr.Started, 10), // ISSUE: no job started + + "CI_JOB_NUMBER": strconv.Itoa(m.Job.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_PREV_COMMIT_SHA": m.Prev.Commit.Sha, "CI_PREV_COMMIT_REF": m.Prev.Commit.Ref, @@ -177,8 +193,11 @@ func (m *Metadata) Environ() map[string]string { "CI_SYSTEM_NAME": m.Sys.Name, "CI_SYSTEM_LINK": m.Sys.Link, "CI_SYSTEM_HOST": m.Sys.Host, - "CI_SYSTEM_ARCH": m.Sys.Arch, - "CI_SYSTEM_VERSION": m.Sys.Version, + "CI_SYSTEM_VERSION": version.Version, + + "CI_AGENT_HOST": m.Agent.Host, + "CI_AGENT_ARCH": m.Agent.Arch, + "CI_AGENT_VERSION": m.Agent.Version, } if m.Curr.Event == EventTag { params["CI_COMMIT_TAG"] = strings.TrimPrefix(m.Curr.Commit.Ref, "refs/tags/") @@ -191,9 +210,9 @@ func (m *Metadata) Environ() map[string]string { var pullRegexp = regexp.MustCompile("\\d+") -func (m *Metadata) SetPlatform(platform string) { - if platform == "" { - platform = "linux/amd64" - } - m.Sys.Arch = platform -} +// func (m *Metadata) SetPlatform(platform string) { +// if platform == "" { +// platform = "linux/amd64" +// } +// m.Sys.Arch = platform +// } From a181a7b49432c1a1290ce9ab8b29ac2d4dab6834 Mon Sep 17 00:00:00 2001 From: Anton Bracke Date: Sun, 14 Nov 2021 20:19:56 +0100 Subject: [PATCH 05/12] fix after merging --- pipeline/frontend/metadata.go | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/pipeline/frontend/metadata.go b/pipeline/frontend/metadata.go index 629c156bdf..f96a2079d6 100644 --- a/pipeline/frontend/metadata.go +++ b/pipeline/frontend/metadata.go @@ -155,8 +155,8 @@ func (m *Metadata) Environ() map[string]string { "CI_COMMIT_TAG": "", // will be set if event is tag "CI_COMMIT_PULL_REQUEST": "", // will be set if event is pr - "CI_BUILD_NUMBER": strconv.Itoa(m.Curr.Number), - "CI_BUILD_PARENT": strconv.Itoa(m.Curr.Parent), + "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, @@ -180,8 +180,8 @@ func (m *Metadata) Environ() map[string]string { "CI_PREV_COMMIT_AUTHOR_EMAIL": m.Prev.Commit.Author.Email, "CI_PREV_COMMIT_AUTHOR_AVATAR": m.Prev.Commit.Author.Avatar, - "CI_PREV_BUILD_NUMBER": strconv.Itoa(m.Prev.Number), - "CI_PREV_BUILD_PARENT": strconv.Itoa(m.Prev.Parent), + "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, From 89c3d025e673931050f289f9ec00358f4646526c Mon Sep 17 00:00:00 2001 From: Anton Bracke Date: Sun, 14 Nov 2021 21:19:24 +0100 Subject: [PATCH 06/12] undo changes --- pipeline/frontend/metadata.go | 247 ++++++++++-------- .../frontend/yaml/compiler/option_test.go | 4 +- server/shared/procBuilder.go | 22 +- 3 files changed, 150 insertions(+), 123 deletions(-) diff --git a/pipeline/frontend/metadata.go b/pipeline/frontend/metadata.go index f96a2079d6..d7a320d3b7 100644 --- a/pipeline/frontend/metadata.go +++ b/pipeline/frontend/metadata.go @@ -1,11 +1,10 @@ package frontend import ( + "fmt" "regexp" "strconv" "strings" - - "github.com/woodpecker-ci/woodpecker/version" ) // Event types corresponding to scm hooks. @@ -19,23 +18,22 @@ const ( type ( // Metadata defines runtime m. Metadata struct { - ID string `json:"id,omitempty"` - Repo Repo `json:"repo,omitempty"` - Curr Build `json:"curr,omitempty"` - Prev Build `json:"prev,omitempty"` - Job Job `json:"job,omitempty"` - Sys System `json:"sys,omitempty"` - Agent Agent `json:"agent,omitempty"` + ID string `json:"id,omitempty"` + Repo Repo `json:"repo,omitempty"` + Curr Build `json:"curr,omitempty"` + Prev Build `json:"prev,omitempty"` + Job Job `json:"job,omitempty"` + Sys System `json:"sys,omitempty"` } // Repo defines runtime metadata for a repository. Repo struct { - Name string `json:"name,omitempty"` - Link string `json:"link,omitempty"` - Remote string `json:"remote,omitempty"` - Private bool `json:"private,omitempty"` - Secrets []Secret `json:"secrets,omitempty"` - DefaultBranch string `json:"default_branch,omitempty"` + Name string `json:"name,omitempty"` + Link string `json:"link,omitempty"` + Remote string `json:"remote,omitempty"` + Private bool `json:"private,omitempty"` + Secrets []Secret `json:"secrets,omitempty"` + Branch string `json:"default_branch,omitempty"` } // Build defines runtime metadata for a build. @@ -74,12 +72,8 @@ type ( // Job defines runtime metadata for a job. Job struct { - Number int `json:"number,omitempty"` - Matrix map[string]string `json:"matrix,omitempty"` - Status string `json:"status,omitempty"` - Created int64 `json:"created,omitempty"` - Started int64 `json:"started,omitempty"` - Finished int64 `json:"finished,omitempty"` + Number int `json:"number,omitempty"` + Matrix map[string]string `json:"matrix,omitempty"` } // Secret defines a runtime secret @@ -92,15 +86,9 @@ type ( // System defines runtime metadata for a ci/cd system. System struct { - Name string `json:"name,omitempty"` - Host string `json:"host,omitempty"` - Link string `json:"link,omitempty"` - // Arch string `json:"arch,omitempty"` - // Version string `json:"version,omitempty"` - } - - Agent struct { + Name string `json:"name,omitempty"` Host string `json:"host,omitempty"` + Link string `json:"link,omitempty"` Arch string `json:"arch,omitempty"` Version string `json:"version,omitempty"` } @@ -108,9 +96,75 @@ type ( // Environ returns the metadata as a map of environment variables. func (m *Metadata) Environ() map[string]string { + params := map[string]string{ + "CI_REPO": m.Repo.Name, + "CI_REPO_NAME": m.Repo.Name, + "CI_REPO_LINK": m.Repo.Link, + "CI_REPO_REMOTE": m.Repo.Remote, + "CI_REMOTE_URL": m.Repo.Remote, + "CI_REPO_PRIVATE": strconv.FormatBool(m.Repo.Private), + "CI_BUILD_NUMBER": strconv.FormatInt(m.Curr.Number, 10), + "CI_PARENT_BUILD_NUMBER": strconv.FormatInt(m.Curr.Parent, 10), + "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), + "CI_BUILD_STATUS": m.Curr.Status, + "CI_BUILD_EVENT": m.Curr.Event, + "CI_BUILD_LINK": m.Curr.Link, + "CI_BUILD_TARGET": m.Curr.Target, + "CI_COMMIT_SHA": m.Curr.Commit.Sha, + "CI_COMMIT_REF": m.Curr.Commit.Ref, + "CI_COMMIT_REFSPEC": m.Curr.Commit.Refspec, + "CI_COMMIT_BRANCH": m.Curr.Commit.Branch, + "CI_COMMIT_MESSAGE": m.Curr.Commit.Message, + "CI_COMMIT_AUTHOR": m.Curr.Commit.Author.Name, + "CI_COMMIT_AUTHOR_NAME": m.Curr.Commit.Author.Name, + "CI_COMMIT_AUTHOR_EMAIL": m.Curr.Commit.Author.Email, + "CI_COMMIT_AUTHOR_AVATAR": m.Curr.Commit.Author.Avatar, + "CI_PREV_BUILD_NUMBER": strconv.FormatInt(m.Prev.Number, 10), + "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), + "CI_PREV_BUILD_STATUS": m.Prev.Status, + "CI_PREV_BUILD_EVENT": m.Prev.Event, + "CI_PREV_BUILD_LINK": m.Prev.Link, + "CI_PREV_COMMIT_SHA": m.Prev.Commit.Sha, + "CI_PREV_COMMIT_REF": m.Prev.Commit.Ref, + "CI_PREV_COMMIT_REFSPEC": m.Prev.Commit.Refspec, + "CI_PREV_COMMIT_BRANCH": m.Prev.Commit.Branch, + "CI_PREV_COMMIT_MESSAGE": m.Prev.Commit.Message, + "CI_PREV_COMMIT_AUTHOR": m.Prev.Commit.Author.Name, + "CI_PREV_COMMIT_AUTHOR_NAME": m.Prev.Commit.Author.Name, + "CI_PREV_COMMIT_AUTHOR_EMAIL": m.Prev.Commit.Author.Email, + "CI_PREV_COMMIT_AUTHOR_AVATAR": m.Prev.Commit.Author.Avatar, + "CI_JOB_NUMBER": strconv.Itoa(m.Job.Number), + "CI_SYSTEM": m.Sys.Name, + "CI_SYSTEM_NAME": m.Sys.Name, + "CI_SYSTEM_LINK": m.Sys.Link, + "CI_SYSTEM_HOST": m.Sys.Host, + "CI_SYSTEM_ARCH": m.Sys.Arch, + "CI_SYSTEM_VERSION": m.Sys.Version, + "CI": m.Sys.Name, + } + if m.Curr.Event == EventTag { + params["CI_TAG"] = strings.TrimPrefix(m.Curr.Commit.Ref, "refs/tags/") + } + if m.Curr.Event == EventPull { + params["CI_PULL_REQUEST"] = pullRegexp.FindString(m.Curr.Commit.Ref) + } + return params +} + +// EnvironDrone returns metadata as a map of DRONE_ environment variables. +// TODO: This is here for backward compatibility and will eventually be removed. +func (m *Metadata) EnvironDrone() map[string]string { + // MISSING PARAMETERS + // * DRONE_REPO_TRUSTED + // * DRONE_YAML_VERIFIED + // * DRONE_YAML_VERIFIED var ( - repoOwner string - repoName string + owner string + name string sourceBranch string targetBranch string @@ -118,10 +172,10 @@ func (m *Metadata) Environ() map[string]string { branchParts = strings.Split(m.Curr.Commit.Refspec, ":") ) if len(repoParts) == 2 { - repoOwner = repoParts[0] - repoName = repoParts[1] + owner = repoParts[0] + name = repoParts[1] } else { - repoName = m.Repo.Name + name = m.Repo.Name } if len(branchParts) == 2 { @@ -130,89 +184,60 @@ func (m *Metadata) Environ() map[string]string { } params := map[string]string{ - "CI": m.Sys.Name, - "CI_REPO": m.Repo.Name, - "CI_REPO_OWNER": repoOwner, - "CI_REPO_NAME": repoName, - "CI_REPO_SCM": "git", - "CI_REPO_LINK": m.Repo.Link, - "CI_REPO_REMOTE": m.Repo.Remote, - "CI_REPO_DEFAULT_BRANCH": m.Repo.DefaultBranch, - "CI_REPO_PRIVATE": strconv.FormatBool(m.Repo.Private), - "CI_REPO_TRUSTED": "false", // TODO should this be added? - - "CI_COMMIT_SHA": m.Curr.Commit.Sha, - "CI_COMMIT_REF": m.Curr.Commit.Ref, - "CI_COMMIT_REFSPEC": m.Curr.Commit.Refspec, - "CI_COMMIT_BRANCH": m.Curr.Commit.Branch, - "CI_COMMIT_SOURCE_BRANCH": sourceBranch, - "CI_COMMIT_TARGET_BRANCH": targetBranch, - "CI_COMMIT_LINK": m.Curr.Link, - "CI_COMMIT_MESSAGE": m.Curr.Commit.Message, - "CI_COMMIT_AUTHOR": m.Curr.Commit.Author.Name, - "CI_COMMIT_AUTHOR_EMAIL": m.Curr.Commit.Author.Email, - "CI_COMMIT_AUTHOR_AVATAR": m.Curr.Commit.Author.Avatar, - "CI_COMMIT_TAG": "", // will be set if event is tag - "CI_COMMIT_PULL_REQUEST": "", // will be set if event is pr - - "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), - - "CI_JOB_NUMBER": strconv.Itoa(m.Job.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_PREV_COMMIT_SHA": m.Prev.Commit.Sha, - "CI_PREV_COMMIT_REF": m.Prev.Commit.Ref, - "CI_PREV_COMMIT_REFSPEC": m.Prev.Commit.Refspec, - "CI_PREV_COMMIT_BRANCH": m.Prev.Commit.Branch, - "CI_PREV_COMMIT_LINK": m.Prev.Link, - "CI_PREV_COMMIT_MESSAGE": m.Prev.Commit.Message, - "CI_PREV_COMMIT_AUTHOR": m.Prev.Commit.Author.Name, - "CI_PREV_COMMIT_AUTHOR_EMAIL": m.Prev.Commit.Author.Email, - "CI_PREV_COMMIT_AUTHOR_AVATAR": m.Prev.Commit.Author.Avatar, - - "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), - - "CI_SYSTEM_NAME": m.Sys.Name, - "CI_SYSTEM_LINK": m.Sys.Link, - "CI_SYSTEM_HOST": m.Sys.Host, - "CI_SYSTEM_VERSION": version.Version, - - "CI_AGENT_HOST": m.Agent.Host, - "CI_AGENT_ARCH": m.Agent.Arch, - "CI_AGENT_VERSION": m.Agent.Version, + "CI": "drone", + "DRONE": "true", + "DRONE_ARCH": m.Sys.Arch, + "DRONE_REPO": m.Repo.Name, + "DRONE_REPO_SCM": "git", + "DRONE_REPO_OWNER": owner, + "DRONE_REPO_NAME": name, + "DRONE_REPO_LINK": m.Repo.Link, + "DRONE_REPO_BRANCH": m.Repo.Branch, + "DRONE_REPO_PRIVATE": fmt.Sprintf("%v", m.Repo.Private), + "DRONE_REPO_TRUSTED": "false", // TODO should this be added? + "DRONE_REMOTE_URL": m.Repo.Remote, + "DRONE_COMMIT_SHA": m.Curr.Commit.Sha, + "DRONE_COMMIT_REF": m.Curr.Commit.Ref, + "DRONE_COMMIT_REFSPEC": m.Curr.Commit.Refspec, + "DRONE_COMMIT_BRANCH": m.Curr.Commit.Branch, + "DRONE_COMMIT_LINK": m.Curr.Link, + "DRONE_COMMIT_MESSAGE": m.Curr.Commit.Message, + "DRONE_COMMIT_AUTHOR": m.Curr.Commit.Author.Name, + "DRONE_COMMIT_AUTHOR_EMAIL": m.Curr.Commit.Author.Email, + "DRONE_COMMIT_AUTHOR_AVATAR": m.Curr.Commit.Author.Avatar, + "DRONE_BUILD_NUMBER": fmt.Sprintf("%d", m.Curr.Number), + "DRONE_PARENT_BUILD_NUMBER": fmt.Sprintf("%d", m.Curr.Parent), + "DRONE_BUILD_EVENT": m.Curr.Event, + "DRONE_BUILD_LINK": fmt.Sprintf("%s/%s/%d", m.Sys.Link, m.Repo.Name, m.Curr.Number), + "DRONE_BUILD_CREATED": fmt.Sprintf("%d", m.Curr.Created), + "DRONE_BUILD_STARTED": fmt.Sprintf("%d", m.Curr.Started), + "DRONE_BUILD_FINISHED": fmt.Sprintf("%d", m.Curr.Finished), + "DRONE_JOB_NUMBER": fmt.Sprintf("%d", m.Job.Number), + "DRONE_JOB_STARTED": fmt.Sprintf("%d", m.Curr.Started), // ISSUE: no job started + "DRONE_BRANCH": m.Curr.Commit.Branch, + "DRONE_SOURCE_BRANCH": sourceBranch, + "DRONE_TARGET_BRANCH": targetBranch, + "DRONE_COMMIT": m.Curr.Commit.Sha, + "DRONE_VERSION": m.Sys.Version, + "DRONE_DEPLOY_TO": m.Curr.Target, + "DRONE_PREV_BUILD_STATUS": m.Prev.Status, + "DRONE_PREV_BUILD_NUMBER": fmt.Sprintf("%v", m.Prev.Number), + "DRONE_PREV_COMMIT_SHA": m.Prev.Commit.Sha, } - if m.Curr.Event == EventTag { - params["CI_COMMIT_TAG"] = strings.TrimPrefix(m.Curr.Commit.Ref, "refs/tags/") + if m.Curr.Event == EventTag || strings.HasPrefix(m.Curr.Commit.Ref, "refs/tags/") { + params["DRONE_TAG"] = strings.TrimPrefix(m.Curr.Commit.Ref, "refs/tags/") } if m.Curr.Event == EventPull { - params["CI_COMMIT_PULL_REQUEST"] = pullRegexp.FindString(m.Curr.Commit.Ref) + params["DRONE_PULL_REQUEST"] = pullRegexp.FindString(m.Curr.Commit.Ref) } return params } var pullRegexp = regexp.MustCompile("\\d+") -// func (m *Metadata) SetPlatform(platform string) { -// if platform == "" { -// platform = "linux/amd64" -// } -// m.Sys.Arch = platform -// } +func (m *Metadata) SetPlatform(platform string) { + if platform == "" { + platform = "linux/amd64" + } + m.Sys.Arch = platform +} diff --git a/pipeline/frontend/yaml/compiler/option_test.go b/pipeline/frontend/yaml/compiler/option_test.go index 629f670b92..a2f5254e33 100644 --- a/pipeline/frontend/yaml/compiler/option_test.go +++ b/pipeline/frontend/yaml/compiler/option_test.go @@ -111,8 +111,8 @@ func TestWithMetadata(t *testing.T) { if !reflect.DeepEqual(compiler.metadata, metadata) { t.Errorf("WithMetadata must set compiler the metadata") } - if compiler.env["CI_REPO"] != metadata.Repo.Name { - t.Errorf("WithMetadata must set CI_REPO") + if compiler.env["CI_REPO_NAME"] != metadata.Repo.Name { + t.Errorf("WithMetadata must set CI_REPO_NAME") } if compiler.env["CI_REPO_LINK"] != metadata.Repo.Link { t.Errorf("WithMetadata must set CI_REPO_LINK") diff --git a/server/shared/procBuilder.go b/server/shared/procBuilder.go index 4eb076e234..b16fc73374 100644 --- a/server/shared/procBuilder.go +++ b/server/shared/procBuilder.go @@ -187,6 +187,9 @@ func (b *ProcBuilder) envsubst_(y string, environ map[string]string) (string, er func (b *ProcBuilder) environmentVariables(metadata frontend.Metadata, axis matrix.Axis) map[string]string { environ := metadata.Environ() + for k, v := range metadata.EnvironDrone() { + environ[k] = v + } for k, v := range axis { environ[k] = v } @@ -292,11 +295,11 @@ func metadataFromStruct(repo *model.Repo, build, last *model.Build, proc *model. } return frontend.Metadata{ Repo: frontend.Repo{ - Name: repo.FullName, - Link: repo.Link, - Remote: repo.Clone, - Private: repo.IsPrivate, - DefaultBranch: repo.Branch, + Name: repo.FullName, + Link: repo.Link, + Remote: repo.Clone, + Private: repo.IsPrivate, + Branch: repo.Branch, }, Curr: frontend.Build{ Number: build.Number, @@ -350,11 +353,10 @@ func metadataFromStruct(repo *model.Repo, build, last *model.Build, proc *model. Matrix: proc.Environ, }, Sys: frontend.System{ - Name: "woodpecker", - Link: link, - Host: host, - Arch: "linux/amd64", // TODO: use current arch - Version: "", // TODO: use current version + Name: "woodpecker", + Link: link, + Host: host, + Arch: "linux/amd64", }, } } From f2bc25df16d6edf7bfa6e5d14e3868d58c7f108b Mon Sep 17 00:00:00 2001 From: Anton Bracke Date: Sun, 14 Nov 2021 21:35:49 +0100 Subject: [PATCH 07/12] structure ci env vars --- pipeline/frontend/metadata.go | 198 +++++++++++++++------------------- 1 file changed, 84 insertions(+), 114 deletions(-) diff --git a/pipeline/frontend/metadata.go b/pipeline/frontend/metadata.go index d7a320d3b7..9539890d62 100644 --- a/pipeline/frontend/metadata.go +++ b/pipeline/frontend/metadata.go @@ -1,10 +1,11 @@ package frontend import ( - "fmt" "regexp" "strconv" "strings" + + "github.com/woodpecker-ci/woodpecker/version" ) // Event types corresponding to scm hooks. @@ -96,75 +97,9 @@ type ( // Environ returns the metadata as a map of environment variables. func (m *Metadata) Environ() map[string]string { - params := map[string]string{ - "CI_REPO": m.Repo.Name, - "CI_REPO_NAME": m.Repo.Name, - "CI_REPO_LINK": m.Repo.Link, - "CI_REPO_REMOTE": m.Repo.Remote, - "CI_REMOTE_URL": m.Repo.Remote, - "CI_REPO_PRIVATE": strconv.FormatBool(m.Repo.Private), - "CI_BUILD_NUMBER": strconv.FormatInt(m.Curr.Number, 10), - "CI_PARENT_BUILD_NUMBER": strconv.FormatInt(m.Curr.Parent, 10), - "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), - "CI_BUILD_STATUS": m.Curr.Status, - "CI_BUILD_EVENT": m.Curr.Event, - "CI_BUILD_LINK": m.Curr.Link, - "CI_BUILD_TARGET": m.Curr.Target, - "CI_COMMIT_SHA": m.Curr.Commit.Sha, - "CI_COMMIT_REF": m.Curr.Commit.Ref, - "CI_COMMIT_REFSPEC": m.Curr.Commit.Refspec, - "CI_COMMIT_BRANCH": m.Curr.Commit.Branch, - "CI_COMMIT_MESSAGE": m.Curr.Commit.Message, - "CI_COMMIT_AUTHOR": m.Curr.Commit.Author.Name, - "CI_COMMIT_AUTHOR_NAME": m.Curr.Commit.Author.Name, - "CI_COMMIT_AUTHOR_EMAIL": m.Curr.Commit.Author.Email, - "CI_COMMIT_AUTHOR_AVATAR": m.Curr.Commit.Author.Avatar, - "CI_PREV_BUILD_NUMBER": strconv.FormatInt(m.Prev.Number, 10), - "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), - "CI_PREV_BUILD_STATUS": m.Prev.Status, - "CI_PREV_BUILD_EVENT": m.Prev.Event, - "CI_PREV_BUILD_LINK": m.Prev.Link, - "CI_PREV_COMMIT_SHA": m.Prev.Commit.Sha, - "CI_PREV_COMMIT_REF": m.Prev.Commit.Ref, - "CI_PREV_COMMIT_REFSPEC": m.Prev.Commit.Refspec, - "CI_PREV_COMMIT_BRANCH": m.Prev.Commit.Branch, - "CI_PREV_COMMIT_MESSAGE": m.Prev.Commit.Message, - "CI_PREV_COMMIT_AUTHOR": m.Prev.Commit.Author.Name, - "CI_PREV_COMMIT_AUTHOR_NAME": m.Prev.Commit.Author.Name, - "CI_PREV_COMMIT_AUTHOR_EMAIL": m.Prev.Commit.Author.Email, - "CI_PREV_COMMIT_AUTHOR_AVATAR": m.Prev.Commit.Author.Avatar, - "CI_JOB_NUMBER": strconv.Itoa(m.Job.Number), - "CI_SYSTEM": m.Sys.Name, - "CI_SYSTEM_NAME": m.Sys.Name, - "CI_SYSTEM_LINK": m.Sys.Link, - "CI_SYSTEM_HOST": m.Sys.Host, - "CI_SYSTEM_ARCH": m.Sys.Arch, - "CI_SYSTEM_VERSION": m.Sys.Version, - "CI": m.Sys.Name, - } - if m.Curr.Event == EventTag { - params["CI_TAG"] = strings.TrimPrefix(m.Curr.Commit.Ref, "refs/tags/") - } - if m.Curr.Event == EventPull { - params["CI_PULL_REQUEST"] = pullRegexp.FindString(m.Curr.Commit.Ref) - } - return params -} - -// EnvironDrone returns metadata as a map of DRONE_ environment variables. -// TODO: This is here for backward compatibility and will eventually be removed. -func (m *Metadata) EnvironDrone() map[string]string { - // MISSING PARAMETERS - // * DRONE_REPO_TRUSTED - // * DRONE_YAML_VERIFIED - // * DRONE_YAML_VERIFIED var ( - owner string - name string + repoOwner string + repoName string sourceBranch string targetBranch string @@ -172,10 +107,10 @@ func (m *Metadata) EnvironDrone() map[string]string { branchParts = strings.Split(m.Curr.Commit.Refspec, ":") ) if len(repoParts) == 2 { - owner = repoParts[0] - name = repoParts[1] + repoOwner = repoParts[0] + repoName = repoParts[1] } else { - name = m.Repo.Name + repoName = m.Repo.Name } if len(branchParts) == 2 { @@ -184,52 +119,87 @@ func (m *Metadata) EnvironDrone() map[string]string { } params := map[string]string{ - "CI": "drone", - "DRONE": "true", - "DRONE_ARCH": m.Sys.Arch, - "DRONE_REPO": m.Repo.Name, - "DRONE_REPO_SCM": "git", - "DRONE_REPO_OWNER": owner, - "DRONE_REPO_NAME": name, - "DRONE_REPO_LINK": m.Repo.Link, - "DRONE_REPO_BRANCH": m.Repo.Branch, - "DRONE_REPO_PRIVATE": fmt.Sprintf("%v", m.Repo.Private), - "DRONE_REPO_TRUSTED": "false", // TODO should this be added? - "DRONE_REMOTE_URL": m.Repo.Remote, - "DRONE_COMMIT_SHA": m.Curr.Commit.Sha, - "DRONE_COMMIT_REF": m.Curr.Commit.Ref, - "DRONE_COMMIT_REFSPEC": m.Curr.Commit.Refspec, - "DRONE_COMMIT_BRANCH": m.Curr.Commit.Branch, - "DRONE_COMMIT_LINK": m.Curr.Link, - "DRONE_COMMIT_MESSAGE": m.Curr.Commit.Message, - "DRONE_COMMIT_AUTHOR": m.Curr.Commit.Author.Name, - "DRONE_COMMIT_AUTHOR_EMAIL": m.Curr.Commit.Author.Email, - "DRONE_COMMIT_AUTHOR_AVATAR": m.Curr.Commit.Author.Avatar, - "DRONE_BUILD_NUMBER": fmt.Sprintf("%d", m.Curr.Number), - "DRONE_PARENT_BUILD_NUMBER": fmt.Sprintf("%d", m.Curr.Parent), - "DRONE_BUILD_EVENT": m.Curr.Event, - "DRONE_BUILD_LINK": fmt.Sprintf("%s/%s/%d", m.Sys.Link, m.Repo.Name, m.Curr.Number), - "DRONE_BUILD_CREATED": fmt.Sprintf("%d", m.Curr.Created), - "DRONE_BUILD_STARTED": fmt.Sprintf("%d", m.Curr.Started), - "DRONE_BUILD_FINISHED": fmt.Sprintf("%d", m.Curr.Finished), - "DRONE_JOB_NUMBER": fmt.Sprintf("%d", m.Job.Number), - "DRONE_JOB_STARTED": fmt.Sprintf("%d", m.Curr.Started), // ISSUE: no job started - "DRONE_BRANCH": m.Curr.Commit.Branch, - "DRONE_SOURCE_BRANCH": sourceBranch, - "DRONE_TARGET_BRANCH": targetBranch, - "DRONE_COMMIT": m.Curr.Commit.Sha, - "DRONE_VERSION": m.Sys.Version, - "DRONE_DEPLOY_TO": m.Curr.Target, - "DRONE_PREV_BUILD_STATUS": m.Prev.Status, - "DRONE_PREV_BUILD_NUMBER": fmt.Sprintf("%v", m.Prev.Number), - "DRONE_PREV_COMMIT_SHA": m.Prev.Commit.Sha, + "CI": m.Sys.Name, + "CI_REPO": m.Repo.Name, + "CI_REPO_OWNER": repoOwner, + "CI_REPO_NAME": repoName, + "CI_REPO_SCM": "git", + "CI_REPO_LINK": m.Repo.Link, + "CI_REPO_REMOTE": m.Repo.Remote, + "CI_REPO_DEFAULT_BRANCH": m.Repo.Branch, + "CI_REPO_PRIVATE": strconv.FormatBool(m.Repo.Private), + "CI_REPO_TRUSTED": "false", // TODO should this be added? + + "CI_COMMIT_SHA": m.Curr.Commit.Sha, + "CI_COMMIT_REF": m.Curr.Commit.Ref, + "CI_COMMIT_REFSPEC": m.Curr.Commit.Refspec, + "CI_COMMIT_BRANCH": m.Curr.Commit.Branch, + "CI_COMMIT_SOURCE_BRANCH": sourceBranch, + "CI_COMMIT_TARGET_BRANCH": targetBranch, + "CI_COMMIT_LINK": m.Curr.Link, + "CI_COMMIT_MESSAGE": m.Curr.Commit.Message, + "CI_COMMIT_AUTHOR": m.Curr.Commit.Author.Name, + "CI_COMMIT_AUTHOR_EMAIL": m.Curr.Commit.Author.Email, + "CI_COMMIT_AUTHOR_AVATAR": m.Curr.Commit.Author.Avatar, + "CI_TAG": "", // will be set if event is tag + "CI_PULL_REQUEST": "", // will be set if event is pr + + "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), + + "CI_JOB_NUMBER": strconv.Itoa(m.Job.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_PREV_COMMIT_SHA": m.Prev.Commit.Sha, + "CI_PREV_COMMIT_REF": m.Prev.Commit.Ref, + "CI_PREV_COMMIT_REFSPEC": m.Prev.Commit.Refspec, + "CI_PREV_COMMIT_BRANCH": m.Prev.Commit.Branch, + "CI_PREV_COMMIT_LINK": m.Prev.Link, + "CI_PREV_COMMIT_MESSAGE": m.Prev.Commit.Message, + "CI_PREV_COMMIT_AUTHOR": m.Prev.Commit.Author.Name, + "CI_PREV_COMMIT_AUTHOR_EMAIL": m.Prev.Commit.Author.Email, + "CI_PREV_COMMIT_AUTHOR_AVATAR": m.Prev.Commit.Author.Avatar, + + "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), + + "CI_SYSTEM_NAME": m.Sys.Name, + "CI_SYSTEM_LINK": m.Sys.Link, + "CI_SYSTEM_HOST": m.Sys.Host, + "CI_SYSTEM_ARCH": m.Sys.Arch, + "CI_SYSTEM_VERSION": version.Version, + + // DEPRECATED + "CI_REMOTE_URL": m.Repo.Remote, // use CI_REPO_REMOTE + "CI_PARENT_BUILD_NUMBER": strconv.FormatInt(m.Curr.Parent, 10), // use CI_BUILD_PARENT + "CI_BUILD_TARGET": m.Curr.Target, // use CI_BUILD_DEPLOY_TARGET + "CI_COMMIT_AUTHOR_NAME": m.Curr.Commit.Author.Name, // use CI_COMMIT_AUTHOR + "CI_PREV_COMMIT_AUTHOR_NAME": m.Prev.Commit.Author.Name, // use CI_PREV_COMMIT_AUTHOR + "CI_SYSTEM": m.Sys.Name, // use CI_SYSTEM_NAME } - if m.Curr.Event == EventTag || strings.HasPrefix(m.Curr.Commit.Ref, "refs/tags/") { - params["DRONE_TAG"] = strings.TrimPrefix(m.Curr.Commit.Ref, "refs/tags/") + if m.Curr.Event == EventTag { + params["CI_TAG"] = strings.TrimPrefix(m.Curr.Commit.Ref, "refs/tags/") } if m.Curr.Event == EventPull { - params["DRONE_PULL_REQUEST"] = pullRegexp.FindString(m.Curr.Commit.Ref) + params["CI_PULL_REQUEST"] = pullRegexp.FindString(m.Curr.Commit.Ref) } + return params } From f627dea8d4b99f132e1ddd49db3f3b507d6ac3bd Mon Sep 17 00:00:00 2001 From: Anton Bracke Date: Sun, 14 Nov 2021 21:51:54 +0100 Subject: [PATCH 08/12] add DRONE_ fallback --- pipeline/pipeline.go | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/pipeline/pipeline.go b/pipeline/pipeline.go index 11c805e1af..b57d1c3716 100644 --- a/pipeline/pipeline.go +++ b/pipeline/pipeline.go @@ -2,6 +2,7 @@ package pipeline import ( "context" + "strings" "time" "golang.org/x/sync/errgroup" @@ -124,6 +125,13 @@ func (r *Runtime) exec(proc *backend.Step) error { } } + // TODO: using DRONE_ will be deprecated with 0.15.0. remove fallback with following release + for key, value := range proc.Environment { + if strings.HasPrefix(key, "CI_") { + proc.Environment[strings.Replace(key, "CI_", "DRONE_", 1)] = value + } + } + if err := r.engine.Exec(r.ctx, proc); err != nil { return err } From d277f2e90b82baf6cfc418808dd7c128a06b548e Mon Sep 17 00:00:00 2001 From: Anton Bracke Date: Sun, 14 Nov 2021 22:06:09 +0100 Subject: [PATCH 09/12] add deprecated env vars --- pipeline/frontend/metadata.go | 13 ++++++++++--- server/shared/procBuilder.go | 3 --- 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/pipeline/frontend/metadata.go b/pipeline/frontend/metadata.go index 9539890d62..06d7489043 100644 --- a/pipeline/frontend/metadata.go +++ b/pipeline/frontend/metadata.go @@ -102,10 +102,9 @@ func (m *Metadata) Environ() map[string]string { repoName string sourceBranch string targetBranch string - - repoParts = strings.Split(m.Repo.Name, "/") - branchParts = strings.Split(m.Curr.Commit.Refspec, ":") ) + + repoParts := strings.Split(m.Repo.Name, "/") if len(repoParts) == 2 { repoOwner = repoParts[0] repoName = repoParts[1] @@ -113,6 +112,7 @@ func (m *Metadata) Environ() map[string]string { repoName = m.Repo.Name } + branchParts := strings.Split(m.Curr.Commit.Refspec, ":") if len(branchParts) == 2 { sourceBranch = branchParts[0] targetBranch = branchParts[1] @@ -186,12 +186,19 @@ func (m *Metadata) Environ() map[string]string { "CI_SYSTEM_VERSION": version.Version, // DEPRECATED + "CI_ARCH": m.Sys.Arch, // use CI_SYSTEM_ARCH + "CI_COMMIT": m.Curr.Commit.Sha, // use CI_COMMIT_SHA "CI_REMOTE_URL": m.Repo.Remote, // use CI_REPO_REMOTE + "CI_REPO_BRANCH": m.Repo.Branch, // use CI_REPO_DEFAULT_BRANCH "CI_PARENT_BUILD_NUMBER": strconv.FormatInt(m.Curr.Parent, 10), // use CI_BUILD_PARENT "CI_BUILD_TARGET": m.Curr.Target, // use CI_BUILD_DEPLOY_TARGET + "CI_DEPLOY_TO": m.Curr.Target, // use CI_BUILD_DEPLOY_TARGET "CI_COMMIT_AUTHOR_NAME": m.Curr.Commit.Author.Name, // use CI_COMMIT_AUTHOR "CI_PREV_COMMIT_AUTHOR_NAME": m.Prev.Commit.Author.Name, // use CI_PREV_COMMIT_AUTHOR "CI_SYSTEM": m.Sys.Name, // use CI_SYSTEM_NAME + "CI_BRANCH": m.Curr.Commit.Branch, // use CI_COMMIT_BRANCH + "CI_SOURCE_BRANCH": sourceBranch, // use CI_COMMIT_SOURCE_BRANCH + "CI_TARGET_BRANCH": targetBranch, // use CI_COMMIT_TARGET_BRANCH } if m.Curr.Event == EventTag { params["CI_TAG"] = strings.TrimPrefix(m.Curr.Commit.Ref, "refs/tags/") diff --git a/server/shared/procBuilder.go b/server/shared/procBuilder.go index b16fc73374..715043a9cd 100644 --- a/server/shared/procBuilder.go +++ b/server/shared/procBuilder.go @@ -187,9 +187,6 @@ func (b *ProcBuilder) envsubst_(y string, environ map[string]string) (string, er func (b *ProcBuilder) environmentVariables(metadata frontend.Metadata, axis matrix.Axis) map[string]string { environ := metadata.Environ() - for k, v := range metadata.EnvironDrone() { - environ[k] = v - } for k, v := range axis { environ[k] = v } From 0326735b3ad4ec10bda6c80992f46b13d49112a5 Mon Sep 17 00:00:00 2001 From: Anton Bracke Date: Sun, 14 Nov 2021 22:28:02 +0100 Subject: [PATCH 10/12] update docs --- agent/runner.go | 9 +- docs/docs/20-usage/50-environment.md | 157 +++++++++++++-------------- docs/docs/91-migrations.md | 23 ++-- 3 files changed, 92 insertions(+), 97 deletions(-) diff --git a/agent/runner.go b/agent/runner.go index b16bbb2849..fa331a836b 100644 --- a/agent/runner.go +++ b/agent/runner.go @@ -17,10 +17,8 @@ package agent import ( "context" "encoding/json" - "fmt" "io" "io/ioutil" - "runtime" "strconv" "sync" "time" @@ -33,7 +31,6 @@ import ( "github.com/woodpecker-ci/woodpecker/pipeline/backend" "github.com/woodpecker-ci/woodpecker/pipeline/multipart" "github.com/woodpecker-ci/woodpecker/pipeline/rpc" - "github.com/woodpecker-ci/woodpecker/version" ) // TODO: Implement log streaming. @@ -277,10 +274,8 @@ func (r *Runner) Run(ctx context.Context) error { state.Pipeline.Step.Environment = map[string]string{} } - // TODO(anbraten): move to helper function and update by changing metadata and exporting again - state.Pipeline.Step.Environment["CI_AGENT_HOST"] = r.hostname - state.Pipeline.Step.Environment["CI_AGENT_ARCH"] = fmt.Sprintf("%s/%s", runtime.GOOS, runtime.GOARCH) - state.Pipeline.Step.Environment["CI_AGENT_VERSION"] = version.Version + // TODO: find better way to update this state + state.Pipeline.Step.Environment["CI_MACHINE"] = r.hostname 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) diff --git a/docs/docs/20-usage/50-environment.md b/docs/docs/20-usage/50-environment.md index f6a0c24e78..8f40cde2bd 100644 --- a/docs/docs/20-usage/50-environment.md +++ b/docs/docs/20-usage/50-environment.md @@ -46,87 +46,82 @@ pipeline: This is the reference list of all environment variables available to your pipeline containers. These are injected into your pipeline step and plugins containers, at runtime. -| NAME | Description | -| ------------------------------ | -------------------------------------------------------------------- | -| `CI=woodpecker` | environment is woodpecker | -| | **Repository** | -| `CI_REPO` | repository full name `/` | -| `CI_REPO_OWNER` | repository owner | -| `CI_REPO_NAME` | repository name | -| `CI_REPO_SCM` | repository scm (git) | -| `CI_REPO_LINK` | repository link | -| `CI_REPO_REMOTE` | repository clone url | -| `CI_REPO_DEFAULT_BRANCH` | repository default branch (master) | -| `CI_REPO_PRIVATE` | repository is private | -| `CI_REPO_TRUSTED` | repository is trusted | -| | **Current Commit** | -| `CI_COMMIT_SHA` | commit sha | -| `CI_COMMIT_REF` | commit ref | -| `CI_COMMIT_REFSPEC` | commit ref spec | -| `CI_COMMIT_BRANCH` | commit branch | -| `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_LINK` | commit link in remote | -| `CI_COMMIT_MESSAGE` | commit message | -| `CI_COMMIT_AUTHOR` | commit author username | -| `CI_COMMIT_AUTHOR_EMAIL` | commit author email address | -| `CI_COMMIT_AUTHOR_AVATAR` | commit author avatar | -| | **Current build** | -| `CI_BUILD_NUMBER` | build number | -| `CI_BUILD_PARENT` | build number of parent build | -| `CI_BUILD_EVENT` | build event (push, pull_request, tag, deployment) | -| `CI_BUILD_LINK` | build link in ci | -| `CI_BUILD_DEPLOY_TARGET` | build deploy target for `deployment` events (ie production) | -| `CI_BUILD_STATUS` | build status (success, failure) | -| `CI_BUILD_CREATED` | build created unix timestamp | -| `CI_BUILD_STARTED` | build started unix timestamp | -| `CI_BUILD_FINISHED` | build finished unix timestamp | -| | **Current job** | -| `CI_JOB_NUMBER` | job number | -| `CI_JOB_STATUS` | job status (success, failure) | -| `CI_JOB_STARTED` | job started unix timestamp | -| `CI_JOB_FINISHED` | job finished unix timestamp | -| | **Previous commit** | -| `CI_PREV_COMMIT_SHA` | previous commit sha | -| `CI_PREV_COMMIT_REF` | previous commit ref | -| `CI_PREV_COMMIT_REFSPEC` | previous commit ref spec | -| `CI_PREV_COMMIT_BRANCH` | previous commit branch | -| `CI_PREV_COMMIT_SOURCE_BRANCH` | previous commit source branch | -| `CI_PREV_COMMIT_TARGET_BRANCH` | previous commit target branch | -| `CI_PREV_COMMIT_LINK` | previous commit link in remote | -| `CI_PREV_COMMIT_MESSAGE` | previous commit message | -| `CI_PREV_COMMIT_AUTHOR` | previous commit author username | -| `CI_PREV_COMMIT_AUTHOR_EMAIL` | previous commit author email address | -| `CI_PREV_COMMIT_AUTHOR_AVATAR` | previous commit author avatar | -| | **Previous build** | -| `CI_PREV_BUILD_NUMBER` | previous build number | -| `CI_PREV_BUILD_PARENT` | previous build number of parent build | -| `CI_PREV_BUILD_EVENT` | previous build event (push, pull_request, tag, deployment) | -| `CI_PREV_BUILD_LINK` | previous build link in ci | -| `CI_PREV_BUILD_DEPLOY_TARGET` | previous build deploy target for `deployment` events (ie production) | -| `CI_PREV_BUILD_STATUS` | previous build status (success, failure) | -| `CI_PREV_BUILD_CREATED` | previous build created unix timestamp | -| `CI_PREV_BUILD_STARTED` | previous build started unix timestamp | -| `CI_PREV_BUILD_FINISHED` | previous build finished unix timestamp | -| | **System** | -| `CI_SYSTEM_NAME` | name of the ci system: `woodpecker` | -| `CI_SYSTEM_LINK` | link to ci system | -| `CI_SYSTEM_HOST` | hostname of ci server | -| `CI_SYSTEM_VERSION` | version of the server | -| | **Agent** this pipeline step is running on | -| `CI_AGENT_HOST` | hostname of agent | -| `CI_AGENT_ARCH` | arch and os of agent (ie `linux/amd64`) | -| `CI_AGENT_VERSION` | version of the agent | - -### TODO -- CI_WORKSPACE -- CI_SCRIPT -- CI_NETRC_USERNAME -- CI_NETRC_PASSWORD -- CI_NETRC_MACHINE - +| NAME | Description | +| ------------------------------ | -------------------------------------------------------------------------------------------- | +| `CI=woodpecker` | environment is woodpecker | +| | **Repository** | +| `CI_REPO` | repository full name `/` | +| `CI_REPO_OWNER` | repository owner | +| `CI_REPO_NAME` | repository name | +| `CI_REPO_SCM` | repository scm (git) | +| `CI_REPO_LINK` | repository link | +| `CI_REPO_REMOTE` | repository clone url | +| `CI_REPO_DEFAULT_BRANCH` | repository default branch (master) | +| `CI_REPO_PRIVATE` | repository is private | +| `CI_REPO_TRUSTED` | repository is trusted | +| | **Current Commit** | +| `CI_COMMIT_SHA` | commit sha | +| `CI_COMMIT_REF` | commit ref | +| `CI_COMMIT_REFSPEC` | commit ref spec | +| `CI_COMMIT_BRANCH` | commit branch | +| `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_LINK` | commit link in remote | +| `CI_COMMIT_MESSAGE` | commit message | +| `CI_COMMIT_AUTHOR` | commit author username | +| `CI_COMMIT_AUTHOR_EMAIL` | commit author email address | +| `CI_COMMIT_AUTHOR_AVATAR` | commit author avatar | +| | **Current build** | +| `CI_BUILD_NUMBER` | build number | +| `CI_BUILD_PARENT` | build number of parent build | +| `CI_BUILD_EVENT` | build event (push, pull_request, tag, deployment) | +| `CI_BUILD_LINK` | build link in ci | +| `CI_BUILD_DEPLOY_TARGET` | build deploy target for `deployment` events (ie production) | +| `CI_BUILD_STATUS` | build status (success, failure) | +| `CI_BUILD_CREATED` | build created unix timestamp | +| `CI_BUILD_STARTED` | build started unix timestamp | +| `CI_BUILD_FINISHED` | build finished unix timestamp | +| | **Current job** | +| `CI_JOB_NUMBER` | job number | +| `CI_JOB_STATUS` | job status (success, failure) | +| `CI_JOB_STARTED` | job started unix timestamp | +| `CI_JOB_FINISHED` | job finished unix timestamp | +| | **Previous commit** | +| `CI_PREV_COMMIT_SHA` | previous commit sha | +| `CI_PREV_COMMIT_REF` | previous commit ref | +| `CI_PREV_COMMIT_REFSPEC` | previous commit ref spec | +| `CI_PREV_COMMIT_BRANCH` | previous commit branch | +| `CI_PREV_COMMIT_SOURCE_BRANCH` | previous commit source branch | +| `CI_PREV_COMMIT_TARGET_BRANCH` | previous commit target branch | +| `CI_PREV_COMMIT_LINK` | previous commit link in remote | +| `CI_PREV_COMMIT_MESSAGE` | previous commit message | +| `CI_PREV_COMMIT_AUTHOR` | previous commit author username | +| `CI_PREV_COMMIT_AUTHOR_EMAIL` | previous commit author email address | +| `CI_PREV_COMMIT_AUTHOR_AVATAR` | previous commit author avatar | +| | **Previous build** | +| `CI_PREV_BUILD_NUMBER` | previous build number | +| `CI_PREV_BUILD_PARENT` | previous build number of parent build | +| `CI_PREV_BUILD_EVENT` | previous build event (push, pull_request, tag, deployment) | +| `CI_PREV_BUILD_LINK` | previous build link in ci | +| `CI_PREV_BUILD_DEPLOY_TARGET` | previous build deploy target for `deployment` events (ie production) | +| `CI_PREV_BUILD_STATUS` | previous build status (success, failure) | +| `CI_PREV_BUILD_CREATED` | previous build created unix timestamp | +| `CI_PREV_BUILD_STARTED` | previous build started unix timestamp | +| `CI_PREV_BUILD_FINISHED` | previous build finished unix timestamp | +| | | +| `CI_WORKSPACE` | Path of the workspace where source code gets cloned to | +| | **System** | +| `CI_SYSTEM_NAME` | name of the ci system: `woodpecker` | +| `CI_SYSTEM_LINK` | link to ci system | +| `CI_SYSTEM_HOST` | hostname of ci server | +| `CI_SYSTEM_VERSION` | version of the server | +| | **Internal** Please don't use! | +| `CI_SCRIPT` | Internal script path. Used to call pipeline step commands. | +| `CI_NETRC_USERNAME` | Credentials for private repos to be able to clone data. (Only available for specific images) | +| `CI_NETRC_PASSWORD` | Credentials for private repos to be able to clone data. (Only available for specific images) | +| `CI_NETRC_MACHINE` | Credentials for private repos to be able to clone data. (Only available for specific images) | ## Global environment variables diff --git a/docs/docs/91-migrations.md b/docs/docs/91-migrations.md index 4cf9fdf423..783d87b8cd 100644 --- a/docs/docs/91-migrations.md +++ b/docs/docs/91-migrations.md @@ -26,15 +26,20 @@ Some versions need some changes to the server configuration or the pipeline conf - `CI_*` prefix replaces `DRONE_*` - `CI` value is now `woodpecker` - `DRONE=true` has been removed - - Use `CI_REPO_DEFAULT_BRANCH` instead of `DRONE_REPO_BRANCH` - - Use `CI_COMMIT_BRANCH`, `CI_COMMIT_SOURCE_BRANCH` and `CI_COMMIT_TARGET_BRANCH` instead of `DRONE_BRANCH`, `DRONE_TARGET_BRANCH` and `DRONE_SOURCE_BRANCH` variables - - Use `CI_COMMIT_AUTHOR` instead of `DRONE_COMMIT_AUTHOR_NAME` - - Use `CI_COMMIT_TAG` instead of `DRONE_TAG` - - Use `CI_COMMIT_PULL_REQUEST` instead of `DRONE_PULL_REQUEST` - - Use `CI_BUILD_DEPLOY_TARGET` instead of `DRONE_DEPLOY_TO` - - Use `CI_REPO_REMOTE` instead of `DRONE_REMOTE_URL` - - Use `CI_AGENT_ARCH` instead of `DRONE_ARCH` - - Use `CI_COMMIT_SHA` instead of `DRONE_COMMIT` + - Some variables got deprecated and will be removed in future versions. Please migrate to the new names. Same applies for `DRONE_` of them. + - CI_ARCH => use CI_SYSTEM_ARCH + - CI_COMMIT => CI_COMMIT_SHA + - CI_REMOTE_URL => use CI_REPO_REMOTE + - CI_REPO_BRANCH => use CI_REPO_DEFAULT_BRANCH + - CI_PARENT_BUILD_NUMBER => use CI_BUILD_PARENT + - CI_BUILD_TARGET => use CI_BUILD_DEPLOY_TARGET + - CI_DEPLOY_TO => use CI_BUILD_DEPLOY_TARGET + - CI_COMMIT_AUTHOR_NAME => use CI_COMMIT_AUTHOR + - CI_PREV_COMMIT_AUTHOR_NAME => use CI_PREV_COMMIT_AUTHOR + - CI_SYSTEM => use CI_SYSTEM_NAME + - CI_BRANCH => use CI_COMMIT_BRANCH + - CI_SOURCE_BRANCH => use CI_COMMIT_SOURCE_BRANCH + - CI_TARGET_BRANCH => use CI_COMMIT_TARGET_BRANCH For all available variables and their descriptions have a look at [built-in-environment-variables](/docs/usage/environment#built-in-environment-variables). From a50b3e0267f6282083d6e2557f9daae7fd53e72c Mon Sep 17 00:00:00 2001 From: Anton Bracke Date: Sun, 14 Nov 2021 22:36:12 +0100 Subject: [PATCH 11/12] improve docs --- docs/docs/20-usage/50-environment.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/docs/20-usage/50-environment.md b/docs/docs/20-usage/50-environment.md index 8f40cde2bd..8b287e1a2e 100644 --- a/docs/docs/20-usage/50-environment.md +++ b/docs/docs/20-usage/50-environment.md @@ -110,14 +110,14 @@ This is the reference list of all environment variables available to your pipeli | `CI_PREV_BUILD_CREATED` | previous build created unix timestamp | | `CI_PREV_BUILD_STARTED` | previous build started unix timestamp | | `CI_PREV_BUILD_FINISHED` | previous build finished unix timestamp | -| | | +| |   | | `CI_WORKSPACE` | Path of the workspace where source code gets cloned to | | | **System** | | `CI_SYSTEM_NAME` | name of the ci system: `woodpecker` | | `CI_SYSTEM_LINK` | link to ci system | | `CI_SYSTEM_HOST` | hostname of ci server | | `CI_SYSTEM_VERSION` | version of the server | -| | **Internal** Please don't use! | +| | **Internal** - Please don't use! | | `CI_SCRIPT` | Internal script path. Used to call pipeline step commands. | | `CI_NETRC_USERNAME` | Credentials for private repos to be able to clone data. (Only available for specific images) | | `CI_NETRC_PASSWORD` | Credentials for private repos to be able to clone data. (Only available for specific images) | From 3e3e8ad801dd4eed9b0515f64c0ccf3cedc22e00 Mon Sep 17 00:00:00 2001 From: Anton Bracke Date: Sun, 14 Nov 2021 22:42:38 +0100 Subject: [PATCH 12/12] fix test --- pipeline/frontend/yaml/compiler/option_test.go | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/pipeline/frontend/yaml/compiler/option_test.go b/pipeline/frontend/yaml/compiler/option_test.go index a2f5254e33..663312ed46 100644 --- a/pipeline/frontend/yaml/compiler/option_test.go +++ b/pipeline/frontend/yaml/compiler/option_test.go @@ -3,6 +3,7 @@ package compiler import ( "os" "reflect" + "strings" "testing" "github.com/woodpecker-ci/woodpecker/pipeline/frontend" @@ -111,7 +112,8 @@ func TestWithMetadata(t *testing.T) { if !reflect.DeepEqual(compiler.metadata, metadata) { t.Errorf("WithMetadata must set compiler the metadata") } - if compiler.env["CI_REPO_NAME"] != metadata.Repo.Name { + + if compiler.env["CI_REPO_NAME"] != strings.Split(metadata.Repo.Name, "/")[1] { t.Errorf("WithMetadata must set CI_REPO_NAME") } if compiler.env["CI_REPO_LINK"] != metadata.Repo.Link {