Skip to content

Commit

Permalink
fix(woodpecker): update woodpecker env vars (#322)
Browse files Browse the repository at this point in the history
Co-authored-by: Matt Travi <126441+travi@users.noreply.github.com>

BREAKING CHANGE: users of Woodpecker CI earlier than v1.0.0 will no longer be properly detected. Please upgrade to a modern, supported version of Woodpecker CI
  • Loading branch information
qwerty287 committed Dec 16, 2023
1 parent 483de89 commit a346182
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 11 deletions.
10 changes: 5 additions & 5 deletions services/woodpecker.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,18 +5,18 @@ export default {
return env.CI && env.CI === "woodpecker";
},
configuration({ env }) {
const isPr = env.CI_BUILD_EVENT === "pull_request";
const isPr = env.CI_PIPELINE_EVENT === "pull_request";

return {
name: "Woodpecker CI",
service: "woodpecker",
commit: env.CI_COMMIT_SHA,
tag: env.CI_COMMIT_TAG,
build: env.CI_BUILD_NUMBER,
buildUrl: env.CI_BUILD_LINK,
build: env.CI_PIPELINE_NUMBER,
buildUrl: env.CI_PIPELINE_URL,
branch: isPr ? env.CI_COMMIT_TARGET_BRANCH : env.CI_COMMIT_BRANCH,
job: env.CI_JOB_NUMBER,
jobUrl: env.CI_BUILD_LINK,
job: env.CI_STEP_NUMBER,
jobUrl: env.CI_STEP_URL,
pr: env.CI_COMMIT_PULL_REQUEST,
isPr,
prBranch: isPr ? env.CI_COMMIT_SOURCE_BRANCH : undefined,
Expand Down
13 changes: 7 additions & 6 deletions test/services/woodpecker.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,12 @@ import woodpecker from "../../services/woodpecker.js";

const env = {
CI: "woodpecker",
CI_JOB_NUMBER: "1234",
CI_BUILD_LINK: "https://woodpecker-ci.example.com/owner/repo/91011",
CI_STEP_NUMBER: "1234",
CI_STEP_URL: "https://woodpecker-ci.example.com/owner/repo/91011/1234",
CI_PIPELINE_URL: "https://woodpecker-ci.example.com/owner/repo/91011",
CI_COMMIT_SHA: "5678",
CI_COMMIT_TAG: "tag_name",
CI_BUILD_NUMBER: "91011",
CI_PIPELINE_NUMBER: "91011",
CI_COMMIT_BRANCH: "main",
CI_REPO_OWNER: "owner",
CI_REPO_NAME: "repo",
Expand All @@ -24,7 +25,7 @@ test("Push", (t) => {
buildUrl: "https://woodpecker-ci.example.com/owner/repo/91011",
branch: "main",
job: "1234",
jobUrl: "https://woodpecker-ci.example.com/owner/repo/91011",
jobUrl: "https://woodpecker-ci.example.com/owner/repo/91011/1234",
pr: undefined,
isPr: false,
prBranch: undefined,
Expand All @@ -39,7 +40,7 @@ test("PR", (t) => {
env: {
...env,
CI_COMMIT_PULL_REQUEST: "10",
CI_BUILD_EVENT: "pull_request",
CI_PIPELINE_EVENT: "pull_request",
CI_COMMIT_TARGET_BRANCH: "main",
CI_COMMIT_SOURCE_BRANCH: "pr-branch",
},
Expand All @@ -53,7 +54,7 @@ test("PR", (t) => {
buildUrl: "https://woodpecker-ci.example.com/owner/repo/91011",
branch: "main",
job: "1234",
jobUrl: "https://woodpecker-ci.example.com/owner/repo/91011",
jobUrl: "https://woodpecker-ci.example.com/owner/repo/91011/1234",
pr: "10",
isPr: true,
prBranch: "pr-branch",
Expand Down

0 comments on commit a346182

Please sign in to comment.