mirror of
https://github.com/woodpecker-ci/woodpecker.git
synced 2024-12-24 10:07:21 +02:00
Merge branch 'main' into fix/ci-commit-branch
This commit is contained in:
commit
bfc60e94fe
@ -1,6 +1,6 @@
|
||||
steps:
|
||||
- name: release-helper
|
||||
image: docker.io/woodpeckerci/plugin-ready-release-go:2.1.1
|
||||
image: docker.io/woodpeckerci/plugin-ready-release-go:3.0.0
|
||||
settings:
|
||||
release_branch: ${CI_COMMIT_BRANCH}
|
||||
forge_type: github
|
||||
|
@ -36,8 +36,8 @@ var repoUpdateCmd = &cli.Command{
|
||||
Usage: "repository is trusted",
|
||||
},
|
||||
&cli.BoolFlag{
|
||||
Name: "gated",
|
||||
Usage: "repository is gated",
|
||||
Name: "gated", // TODO: remove in next release
|
||||
Hidden: true,
|
||||
},
|
||||
&cli.StringFlag{
|
||||
Name: "require-approval",
|
||||
@ -82,7 +82,6 @@ func repoUpdate(ctx context.Context, c *cli.Command) error {
|
||||
config = c.String("config")
|
||||
timeout = c.Duration("timeout")
|
||||
trusted = c.Bool("trusted")
|
||||
gated = c.Bool("gated")
|
||||
requireApproval = c.String("require-approval")
|
||||
pipelineCounter = int(c.Int("pipeline-counter"))
|
||||
unsafe = c.Bool("unsafe")
|
||||
@ -92,29 +91,18 @@ func repoUpdate(ctx context.Context, c *cli.Command) error {
|
||||
if c.IsSet("trusted") {
|
||||
patch.IsTrusted = &trusted
|
||||
}
|
||||
// TODO: remove isGated in next major release
|
||||
|
||||
// TODO: remove in next release
|
||||
if c.IsSet("gated") {
|
||||
if gated {
|
||||
patch.RequireApproval = &woodpecker.RequireApprovalAllEvents
|
||||
} else {
|
||||
patch.RequireApproval = &woodpecker.RequireApprovalNone
|
||||
}
|
||||
return fmt.Errorf("'gated' option has been set in version 2.8, use 'require-approval' in >= 3.0")
|
||||
}
|
||||
|
||||
if c.IsSet("require-approval") {
|
||||
if mode := woodpecker.ApprovalMode(requireApproval); mode.Valid() {
|
||||
patch.RequireApproval = &mode
|
||||
} else {
|
||||
return fmt.Errorf("update approval mode failed: '%s' is no valid mode", mode)
|
||||
}
|
||||
|
||||
// TODO: remove isGated in next major release
|
||||
if requireApproval == string(woodpecker.RequireApprovalAllEvents) {
|
||||
trueBool := true
|
||||
patch.IsGated = &trueBool
|
||||
} else if requireApproval == string(woodpecker.RequireApprovalNone) {
|
||||
falseBool := false
|
||||
patch.IsGated = &falseBool
|
||||
}
|
||||
}
|
||||
if c.IsSet("timeout") {
|
||||
v := int64(timeout / time.Minute)
|
||||
|
@ -70,11 +70,11 @@ This is the reference list of all environment variables available to your pipeli
|
||||
| `CI_COMMIT_REF` | commit ref | `refs/heads/main` |
|
||||
| `CI_COMMIT_REFSPEC` | commit ref spec | `issue-branch:main` |
|
||||
| `CI_COMMIT_BRANCH` | commit branch (equals target branch for pull requests) | `main` |
|
||||
| `CI_COMMIT_SOURCE_BRANCH` | commit source branch (empty if event is not `pull_request` or `pull_request_closed`) | `issue-branch` |
|
||||
| `CI_COMMIT_TARGET_BRANCH` | commit target branch (empty if event is not `pull_request` or `pull_request_closed`) | `main` |
|
||||
| `CI_COMMIT_SOURCE_BRANCH` | commit source branch (set only for `pull_request` and `pull_request_closed` events) | `issue-branch` |
|
||||
| `CI_COMMIT_TARGET_BRANCH` | commit target branch (set only for `pull_request` and `pull_request_closed` events) | `main` |
|
||||
| `CI_COMMIT_TAG` | commit tag name (empty if event is not `tag`) | `v1.10.3` |
|
||||
| `CI_COMMIT_PULL_REQUEST` | commit pull request number (empty if event is not `pull_request` or `pull_request_closed`) | `1` |
|
||||
| `CI_COMMIT_PULL_REQUEST_LABELS` | labels assigned to pull request (empty if event is not `pull_request` or `pull_request_closed`) | `server` |
|
||||
| `CI_COMMIT_PULL_REQUEST` | commit pull request number (set only for `pull_request` and `pull_request_closed` events) | `1` |
|
||||
| `CI_COMMIT_PULL_REQUEST_LABELS` | labels assigned to pull request (set only for `pull_request` and `pull_request_closed` events) | `server` |
|
||||
| `CI_COMMIT_MESSAGE` | commit message | `Initial commit` |
|
||||
| `CI_COMMIT_AUTHOR` | commit author username | `john-doe` |
|
||||
| `CI_COMMIT_AUTHOR_EMAIL` | commit author email address | `john-doe@example.com` |
|
||||
@ -103,8 +103,8 @@ This is the reference list of all environment variables available to your pipeli
|
||||
| `CI_PREV_COMMIT_REF` | previous commit ref | `refs/heads/main` |
|
||||
| `CI_PREV_COMMIT_REFSPEC` | previous commit ref spec | `issue-branch:main` |
|
||||
| `CI_PREV_COMMIT_BRANCH` | previous commit branch | `main` |
|
||||
| `CI_PREV_COMMIT_SOURCE_BRANCH` | previous commit source branch | `issue-branch` |
|
||||
| `CI_PREV_COMMIT_TARGET_BRANCH` | previous commit target branch | `main` |
|
||||
| `CI_PREV_COMMIT_SOURCE_BRANCH` | previous commit source branch (set only for `pull_request` and `pull_request_closed` events) | `issue-branch` |
|
||||
| `CI_PREV_COMMIT_TARGET_BRANCH` | previous commit target branch (set only for `pull_request` and `pull_request_closed` events) | `main` |
|
||||
| `CI_PREV_COMMIT_URL` | previous commit link in forge | `https://git.example.com/john-doe/my-repo/commit/15784117e4e103f36cba75a9e29da48046eb82c4` |
|
||||
| `CI_PREV_COMMIT_MESSAGE` | previous commit message | `test` |
|
||||
| `CI_PREV_COMMIT_AUTHOR` | previous commit author username | `john-doe` |
|
||||
|
@ -38,7 +38,7 @@ Addons use RPC to communicate to the server and are implemented using the [`go-p
|
||||
|
||||
This example will use the Go language.
|
||||
|
||||
Directly import Woodpecker's Go packages (`go.woodpecker-ci.org/woodpecker/woodpecker/v2`) and use the interfaces and types defined there.
|
||||
Directly import Woodpecker's Go packages (`go.woodpecker-ci.org/woodpecker/v2`) and use the interfaces and types defined there.
|
||||
|
||||
In the `main` function, just call `"go.woodpecker-ci.org/woodpecker/v2/server/forge/addon".Serve` with a `"go.woodpecker-ci.org/woodpecker/v2/server/forge".Forge` as argument.
|
||||
This will take care of connecting the addon forge to the server.
|
||||
|
142
docs/pnpm-lock.yaml
generated
142
docs/pnpm-lock.yaml
generated
@ -2778,8 +2778,8 @@ packages:
|
||||
ee-first@1.1.1:
|
||||
resolution: {integrity: sha512-WMwm9LhRUo+WUaRN+vRuETqG89IgZphVSNkdFgeb6sS/E4OrDIN7t48CAewSHXc6C8lefD8KKfr5vY61brQlow==}
|
||||
|
||||
electron-to-chromium@1.5.64:
|
||||
resolution: {integrity: sha512-IXEuxU+5ClW2IGEYFC2T7szbyVgehupCWQe5GNh+H065CD6U6IFN0s4KeAMFGNmQolRU4IV7zGBWSYMmZ8uuqQ==}
|
||||
electron-to-chromium@1.5.67:
|
||||
resolution: {integrity: sha512-nz88NNBsD7kQSAGGJyp8hS6xSPtWwqNogA0mjtc2nUYeEf3nURK9qpV18TuBdDmEDgVWotS8Wkzf+V52dSQ/LQ==}
|
||||
|
||||
emoji-regex@8.0.0:
|
||||
resolution: {integrity: sha512-MSjYzcWNOA0ewAHpz0MxpYFvwg6yjy1NG3xteoqz644VCo/RPgnr1/GGt+ic3iJTzQ8Eu3TdM14SawnVUmGE6A==}
|
||||
@ -2857,8 +2857,8 @@ packages:
|
||||
es-shim-unscopables@1.0.2:
|
||||
resolution: {integrity: sha512-J3yBRXCzDu4ULnQwxyToo/OjdMx6akgVC7K6few0a7F/0wLtmKKN7I73AH5T2836UuXRqN7Qg+IIUw/+YJksRw==}
|
||||
|
||||
es-to-primitive@1.2.1:
|
||||
resolution: {integrity: sha512-QCOllgZJtaUo9miYBcLChTUaHNjJF3PYs1VidD7AwiEj1kYxKeQTctLAezAOH5ZKRH0g2IgPn6KwB4IT8iRpvA==}
|
||||
es-to-primitive@1.3.0:
|
||||
resolution: {integrity: sha512-w+5mJ3GuFL+NjVtJlvydShqE1eN3h3PbI7/5LAsYJP/2qtuMXjfL2LpHSRqo4b4eSF5K/DH1JXKUAHSB2UW50g==}
|
||||
engines: {node: '>= 0.4'}
|
||||
|
||||
es6-promise@3.3.1:
|
||||
@ -3230,9 +3230,6 @@ packages:
|
||||
resolution: {integrity: sha512-Y1zNGV+pzQdh7H39l9zgB4PJqjRNqydvdYCDG4HFXM4XuvSaQQlEc91IU1yALL8gUTDomgBAfz3XJdmUS+oo0w==}
|
||||
engines: {node: ^12.20.0 || ^14.13.1 || >=16.0.0}
|
||||
|
||||
gopd@1.0.1:
|
||||
resolution: {integrity: sha512-d65bNlIadxvpb/A2abVdlqKqV563juRnZ1Wtk6s1sIR8uNsXR70xqIzVqxVf1eTqDunwT2MkczEeaezCKTZhwA==}
|
||||
|
||||
gopd@1.1.0:
|
||||
resolution: {integrity: sha512-FQoVQnqcdk4hVM4JN1eromaun4iuS34oStkdlLENLdpULsuQcTyXj8w7ayhuUfPwEYZ1ZOooOTT6fdA9Vmx/RA==}
|
||||
engines: {node: '>= 0.4'}
|
||||
@ -3268,8 +3265,8 @@ packages:
|
||||
has-property-descriptors@1.0.2:
|
||||
resolution: {integrity: sha512-55JNKuIW+vq4Ke1BjOTjM2YctQIvCT7GFzHwmfZPGo5wnrgkid0YQtnAleFSqumZm4az3n2BS+erby5ipJdgrg==}
|
||||
|
||||
has-proto@1.0.3:
|
||||
resolution: {integrity: sha512-SJ1amZAJUiZS+PhsVLf5tGydlaVB8EdFpaSO4gmiUKUOxk8qzn5AIy4ZeJUmh22znIdk/uMAUT2pl3FxzVUH+Q==}
|
||||
has-proto@1.1.0:
|
||||
resolution: {integrity: sha512-QLdzI9IIO1Jg7f9GT1gXpPpXArAn6cS31R1eEZqz08Gc+uQ8/XiqHWt17Fiw+2p6oTTIq5GXEpQkAlA88YRl/Q==}
|
||||
engines: {node: '>= 0.4'}
|
||||
|
||||
has-symbols@1.0.3:
|
||||
@ -3619,8 +3616,8 @@ packages:
|
||||
resolution: {integrity: sha512-JEjxbSmtPSt1c8XTkVrlujcXdKV1/tvuQ7GwKcAlyiVLeYFQ2VHat8xfrDJsIkhCdF/tZ7CiIR3sy141c6+gPQ==}
|
||||
engines: {node: ^12.20.0 || ^14.13.1 || >=16.0.0}
|
||||
|
||||
is-number-object@1.0.7:
|
||||
resolution: {integrity: sha512-k1U0IRzLMo7ZlYIfzRu23Oh6MiIFasgpb9X76eqfFZAqwH44UI4KTBvBYIZ1dSL9ZzChTB9ShHfLkR4pdW5krQ==}
|
||||
is-number-object@1.1.0:
|
||||
resolution: {integrity: sha512-KVSZV0Dunv9DTPkhXwcZ3Q+tUc9TsaE1ZwX5J2WMvsSGS6Md8TFPun5uwh0yRdrNerI6vf/tbJxqSx4c1ZI1Lw==}
|
||||
engines: {node: '>= 0.4'}
|
||||
|
||||
is-number@7.0.0:
|
||||
@ -3658,10 +3655,6 @@ packages:
|
||||
is-potential-custom-element-name@1.0.1:
|
||||
resolution: {integrity: sha512-bCYeRA2rVibKZd+s2625gGnGF/t7DSqDs4dP7CrLA1m7jKWz6pps0LpYLJN8Q64HtmPKJ1hrN3nzPNKFEKOUiQ==}
|
||||
|
||||
is-regex@1.1.4:
|
||||
resolution: {integrity: sha512-kvRdxDsxZjhzUX07ZnLydzS1TU/TJlTUHHY4YLL87e37oUA49DfkLqgy+VjFocowy29cKvcSiu+kIv728jTTVg==}
|
||||
engines: {node: '>= 0.4'}
|
||||
|
||||
is-regex@1.2.0:
|
||||
resolution: {integrity: sha512-B6ohK4ZmoftlUe+uvenXSbPJFo6U37BH7oO1B3nQH8f/7h27N56s85MhUtbFJAziz5dcmuR3i8ovUl35zp8pFA==}
|
||||
engines: {node: '>= 0.4'}
|
||||
@ -4249,8 +4242,8 @@ packages:
|
||||
resolution: {integrity: sha512-2eznPJP8z2BFLX50tf0LuODrpINqP1RVIm/CObbTcBRITQgmC/TjcREF1NeTBzIcR5XO/ukWo+YHOjBbFwIupg==}
|
||||
hasBin: true
|
||||
|
||||
nanoid@3.3.7:
|
||||
resolution: {integrity: sha512-eSRppjcPIatRIMC1U6UngP8XFcz8MQWGQdt1MTBQ7NaAmvXDfvNxbvWV3x2y6CdEUciCSsDHDQZbhYaB8QEo2g==}
|
||||
nanoid@3.3.8:
|
||||
resolution: {integrity: sha512-WNLf5Sd8oZxOm+TzppcYk8gVOgP+l58xNy58D0nbUnOxOWRWvlcCV4kUF7ltmI6PsrLl/BgKEyS4mqsGChFN0w==}
|
||||
engines: {node: ^10 || ^12 || ^13.7 || ^14 || >=15.0.1}
|
||||
hasBin: true
|
||||
|
||||
@ -4396,8 +4389,8 @@ packages:
|
||||
resolution: {integrity: sha512-7x81NCL719oNbsq/3mh+hVrAWmFuEYUqrq/Iw3kUzH8ReypT9QQ0BLoJS7/G9k6N81XjW4qHWtjWwe/9eLy1EQ==}
|
||||
engines: {node: '>=12'}
|
||||
|
||||
openapi-sampler@1.6.0:
|
||||
resolution: {integrity: sha512-0PKhql1Ms38xSngEztcNQ7EXgssR2jAyVX7RckEln4reynIr/HHwuwM29cDEpiNkk4OkrHoc+7Li9V7WTAPYmw==}
|
||||
openapi-sampler@1.6.1:
|
||||
resolution: {integrity: sha512-s1cIatOqrrhSj2tmJ4abFYZQK6l5v+V4toO5q1Pa0DyN8mtyqy2I+Qrj5W9vOELEtybIMQs/TBZGVO/DtTFK8w==}
|
||||
|
||||
opener@1.5.2:
|
||||
resolution: {integrity: sha512-ur5UIdyw5Y7yEj9wLzhqXiy6GZ3Mwx0yGI+5sMn2r0N0v3cKJvUmFH5yPP+WXh9e0xfyzyJX95D8l088DNFj7A==}
|
||||
@ -5199,8 +5192,8 @@ packages:
|
||||
resolution: {integrity: sha512-H66BPQMrv+V16t8xtmq+UC0CBpiTBA60V8ibS1QVReIp8T1z8hwFxqcGzm9K6lgsN7sB5edVH8a+ze6Fqm4weA==}
|
||||
engines: {node: '>=4'}
|
||||
|
||||
registry-auth-token@5.0.2:
|
||||
resolution: {integrity: sha512-o/3ikDxtXaA59BmZuZrJZDJv8NMDGSj+6j6XaeBmHw8eY1i1qd9+6H+LjVvQXx3HN6aRCGa1cUdJ9RaJZUugnQ==}
|
||||
registry-auth-token@5.0.3:
|
||||
resolution: {integrity: sha512-1bpc9IyC+e+CNFRaWyn77tk4xGG4PPUyfakSmA6F6cvUDjrm58dfyJ3II+9yb10EDkHoy1LaPSmHaWLOH3m6HA==}
|
||||
engines: {node: '>=14'}
|
||||
|
||||
registry-url@6.0.1:
|
||||
@ -5441,8 +5434,9 @@ packages:
|
||||
resolution: {integrity: sha512-7++dFhtcx3353uBaq8DDR4NuxBetBzC7ZQOhmTQInHEd6bSrXdiEyzCvG07Z44UYdLShWUyXt5M/yhz8ekcb1A==}
|
||||
engines: {node: '>=8'}
|
||||
|
||||
shell-quote@1.8.1:
|
||||
resolution: {integrity: sha512-6j1W9l1iAs/4xYBI1SYOVZyFcCis9b4KCLQ8fgAGG07QvzaRLVVRQvAy85yNmmZSjYjg4MWh4gNvlPujU/5LpA==}
|
||||
shell-quote@1.8.2:
|
||||
resolution: {integrity: sha512-AzqKpGKjrj7EM6rKVQEPpB288oCfnrEIuyoT9cyF4nmGa7V8Zk6f7RRqYisX8X9m+Q7bd632aZW4ky7EhbQztA==}
|
||||
engines: {node: '>= 0.4'}
|
||||
|
||||
shelljs@0.8.5:
|
||||
resolution: {integrity: sha512-TiwcRcrkhHvbrZbnRcFYMLl30Dfov3HKqzp5tO5b4pt6G/SezKcYhmDg15zXVBswHmctSAQKznqNW2LO5tTDow==}
|
||||
@ -5768,8 +5762,8 @@ packages:
|
||||
resolution: {integrity: sha512-RAH822pAdBgcNMAfWnCBU3CFZcfZ/i1eZjwFU/dsLKumyuuP3niueg2UAukXYF0E2AAoc82ZSSf9J0WQBinzHA==}
|
||||
engines: {node: '>=12.20'}
|
||||
|
||||
type-fest@4.28.0:
|
||||
resolution: {integrity: sha512-jXMwges/FVbFRe5lTMJZVEZCrO9kI9c8k0PA/z7nF3bo0JSCCLysvokFjNPIUK/itEMas10MQM+AiHoHt/T/XA==}
|
||||
type-fest@4.29.1:
|
||||
resolution: {integrity: sha512-Y1zUveI92UYM/vo1EFlQSsNf74+hfKH+7saZJslF0Fw92FRaiTAnHPIvo9d7SLxXt/gAYqA4RXyDTioMQCCp0A==}
|
||||
engines: {node: '>=16'}
|
||||
|
||||
type-is@1.6.18:
|
||||
@ -6041,8 +6035,8 @@ packages:
|
||||
resolution: {integrity: sha512-K4jVyjnBdgvc86Y6BkaLZEN933SwYOuBFkdmBu9ZfkcAbdVbpITnDmjvZ/aQjRXQrv5EPkTnD1s39GiiqbngCw==}
|
||||
engines: {node: '>= 0.4'}
|
||||
|
||||
which-typed-array@1.1.15:
|
||||
resolution: {integrity: sha512-oV0jmFtUky6CXfkqehVvBP/LSWJ2sy4vWMioiENyJLePrBO/yKyV9OyJySfAKosh+RYkIl5zJCNZ8/4JncrpdA==}
|
||||
which-typed-array@1.1.16:
|
||||
resolution: {integrity: sha512-g+N+GAWiRj66DngFwHvISJd+ITsyphZvD1vChfVg6cEdnzy53GzB3oy0fUNlvhz7H7+MiqhYr26qxQShCpKTTQ==}
|
||||
engines: {node: '>= 0.4'}
|
||||
|
||||
which@1.3.1:
|
||||
@ -9170,7 +9164,7 @@ snapshots:
|
||||
browserslist@4.24.2:
|
||||
dependencies:
|
||||
caniuse-lite: 1.0.30001684
|
||||
electron-to-chromium: 1.5.64
|
||||
electron-to-chromium: 1.5.67
|
||||
node-releases: 2.0.18
|
||||
update-browserslist-db: 1.1.1(browserslist@4.24.2)
|
||||
|
||||
@ -9383,7 +9377,7 @@ snapshots:
|
||||
chalk: 4.1.2
|
||||
lodash: 4.17.21
|
||||
rxjs: 7.8.1
|
||||
shell-quote: 1.8.1
|
||||
shell-quote: 1.8.2
|
||||
supports-color: 8.1.1
|
||||
tree-kill: 1.2.2
|
||||
yargs: 17.7.2
|
||||
@ -9677,7 +9671,7 @@ snapshots:
|
||||
dependencies:
|
||||
es-define-property: 1.0.0
|
||||
es-errors: 1.3.0
|
||||
gopd: 1.0.1
|
||||
gopd: 1.1.0
|
||||
|
||||
define-lazy-prop@2.0.0: {}
|
||||
|
||||
@ -9832,7 +9826,7 @@ snapshots:
|
||||
|
||||
ee-first@1.1.1: {}
|
||||
|
||||
electron-to-chromium@1.5.64: {}
|
||||
electron-to-chromium@1.5.67: {}
|
||||
|
||||
emoji-regex@8.0.0: {}
|
||||
|
||||
@ -9877,7 +9871,7 @@ snapshots:
|
||||
html-element-map: 1.3.1
|
||||
is-boolean-object: 1.1.2
|
||||
is-callable: 1.2.7
|
||||
is-number-object: 1.0.7
|
||||
is-number-object: 1.1.0
|
||||
is-regex: 1.2.0
|
||||
is-string: 1.0.7
|
||||
is-subset: 0.1.1
|
||||
@ -9909,14 +9903,14 @@ snapshots:
|
||||
es-errors: 1.3.0
|
||||
es-object-atoms: 1.0.0
|
||||
es-set-tostringtag: 2.0.3
|
||||
es-to-primitive: 1.2.1
|
||||
es-to-primitive: 1.3.0
|
||||
function.prototype.name: 1.1.6
|
||||
get-intrinsic: 1.2.4
|
||||
get-symbol-description: 1.0.2
|
||||
globalthis: 1.0.4
|
||||
gopd: 1.0.1
|
||||
gopd: 1.1.0
|
||||
has-property-descriptors: 1.0.2
|
||||
has-proto: 1.0.3
|
||||
has-proto: 1.1.0
|
||||
has-symbols: 1.0.3
|
||||
hasown: 2.0.2
|
||||
internal-slot: 1.0.7
|
||||
@ -9924,7 +9918,7 @@ snapshots:
|
||||
is-callable: 1.2.7
|
||||
is-data-view: 1.0.1
|
||||
is-negative-zero: 2.0.3
|
||||
is-regex: 1.1.4
|
||||
is-regex: 1.2.0
|
||||
is-shared-array-buffer: 1.0.3
|
||||
is-string: 1.0.7
|
||||
is-typed-array: 1.1.13
|
||||
@ -9943,7 +9937,7 @@ snapshots:
|
||||
typed-array-byte-offset: 1.0.3
|
||||
typed-array-length: 1.0.7
|
||||
unbox-primitive: 1.0.2
|
||||
which-typed-array: 1.1.15
|
||||
which-typed-array: 1.1.16
|
||||
|
||||
es-array-method-boxes-properly@1.0.0: {}
|
||||
|
||||
@ -9969,7 +9963,7 @@ snapshots:
|
||||
dependencies:
|
||||
hasown: 2.0.2
|
||||
|
||||
es-to-primitive@1.2.1:
|
||||
es-to-primitive@1.3.0:
|
||||
dependencies:
|
||||
is-callable: 1.2.7
|
||||
is-date-object: 1.0.5
|
||||
@ -10336,7 +10330,7 @@ snapshots:
|
||||
dependencies:
|
||||
es-errors: 1.3.0
|
||||
function-bind: 1.1.2
|
||||
has-proto: 1.0.3
|
||||
has-proto: 1.1.0
|
||||
has-symbols: 1.0.3
|
||||
hasown: 2.0.2
|
||||
|
||||
@ -10399,7 +10393,7 @@ snapshots:
|
||||
globalthis@1.0.4:
|
||||
dependencies:
|
||||
define-properties: 1.2.1
|
||||
gopd: 1.0.1
|
||||
gopd: 1.1.0
|
||||
|
||||
globby@11.1.0:
|
||||
dependencies:
|
||||
@ -10418,10 +10412,6 @@ snapshots:
|
||||
merge2: 1.4.1
|
||||
slash: 4.0.0
|
||||
|
||||
gopd@1.0.1:
|
||||
dependencies:
|
||||
get-intrinsic: 1.2.4
|
||||
|
||||
gopd@1.1.0:
|
||||
dependencies:
|
||||
get-intrinsic: 1.2.4
|
||||
@ -10438,7 +10428,7 @@ snapshots:
|
||||
lowercase-keys: 3.0.0
|
||||
p-cancelable: 4.0.1
|
||||
responselike: 3.0.0
|
||||
type-fest: 4.28.0
|
||||
type-fest: 4.29.1
|
||||
|
||||
graceful-fs@4.2.10: {}
|
||||
|
||||
@ -10465,7 +10455,9 @@ snapshots:
|
||||
dependencies:
|
||||
es-define-property: 1.0.0
|
||||
|
||||
has-proto@1.0.3: {}
|
||||
has-proto@1.1.0:
|
||||
dependencies:
|
||||
call-bind: 1.0.7
|
||||
|
||||
has-symbols@1.0.3: {}
|
||||
|
||||
@ -10881,8 +10873,9 @@ snapshots:
|
||||
|
||||
is-npm@6.0.0: {}
|
||||
|
||||
is-number-object@1.0.7:
|
||||
is-number-object@1.1.0:
|
||||
dependencies:
|
||||
call-bind: 1.0.7
|
||||
has-tostringtag: 1.0.2
|
||||
|
||||
is-number@7.0.0: {}
|
||||
@ -10905,11 +10898,6 @@ snapshots:
|
||||
|
||||
is-potential-custom-element-name@1.0.1: {}
|
||||
|
||||
is-regex@1.1.4:
|
||||
dependencies:
|
||||
call-bind: 1.0.7
|
||||
has-tostringtag: 1.0.2
|
||||
|
||||
is-regex@1.2.0:
|
||||
dependencies:
|
||||
call-bind: 1.0.7
|
||||
@ -10943,7 +10931,7 @@ snapshots:
|
||||
|
||||
is-typed-array@1.1.13:
|
||||
dependencies:
|
||||
which-typed-array: 1.1.15
|
||||
which-typed-array: 1.1.16
|
||||
|
||||
is-typedarray@1.0.0: {}
|
||||
|
||||
@ -11096,7 +11084,7 @@ snapshots:
|
||||
launch-editor@2.9.1:
|
||||
dependencies:
|
||||
picocolors: 1.1.1
|
||||
shell-quote: 1.8.1
|
||||
shell-quote: 1.8.2
|
||||
|
||||
leven@3.1.0: {}
|
||||
|
||||
@ -11753,7 +11741,7 @@ snapshots:
|
||||
dns-packet: 5.6.1
|
||||
thunky: 1.1.0
|
||||
|
||||
nanoid@3.3.7: {}
|
||||
nanoid@3.3.8: {}
|
||||
|
||||
nearley@2.20.1:
|
||||
dependencies:
|
||||
@ -11903,7 +11891,7 @@ snapshots:
|
||||
is-docker: 2.2.1
|
||||
is-wsl: 2.2.0
|
||||
|
||||
openapi-sampler@1.6.0:
|
||||
openapi-sampler@1.6.1:
|
||||
dependencies:
|
||||
'@types/json-schema': 7.0.15
|
||||
fast-xml-parser: 4.5.0
|
||||
@ -11951,7 +11939,7 @@ snapshots:
|
||||
package-json@8.1.1:
|
||||
dependencies:
|
||||
got: 14.4.5
|
||||
registry-auth-token: 5.0.2
|
||||
registry-auth-token: 5.0.3
|
||||
registry-url: 6.0.1
|
||||
semver: 7.6.3
|
||||
|
||||
@ -12481,13 +12469,13 @@ snapshots:
|
||||
|
||||
postcss@8.4.38:
|
||||
dependencies:
|
||||
nanoid: 3.3.7
|
||||
nanoid: 3.3.8
|
||||
picocolors: 1.1.1
|
||||
source-map-js: 1.2.1
|
||||
|
||||
postcss@8.4.49:
|
||||
dependencies:
|
||||
nanoid: 3.3.7
|
||||
nanoid: 3.3.8
|
||||
picocolors: 1.1.1
|
||||
source-map-js: 1.2.1
|
||||
|
||||
@ -12604,7 +12592,7 @@ snapshots:
|
||||
prompts: 2.4.2
|
||||
react-error-overlay: 6.0.11
|
||||
recursive-readdir: 2.2.3
|
||||
shell-quote: 1.8.1
|
||||
shell-quote: 1.8.2
|
||||
strip-ansi: 6.0.1
|
||||
text-table: 0.2.0
|
||||
webpack: 5.96.1
|
||||
@ -12777,7 +12765,7 @@ snapshots:
|
||||
marked: 4.3.0
|
||||
mobx: 6.13.5
|
||||
mobx-react: 9.1.1(mobx@6.13.5)(react-dom@18.3.1(react@18.3.1))(react@18.3.1)
|
||||
openapi-sampler: 1.6.0
|
||||
openapi-sampler: 1.6.1
|
||||
path-browserify: 1.0.1
|
||||
perfect-scrollbar: 1.5.6
|
||||
polished: 4.3.1
|
||||
@ -12822,7 +12810,7 @@ snapshots:
|
||||
es-abstract: 1.23.5
|
||||
es-errors: 1.3.0
|
||||
get-intrinsic: 1.2.4
|
||||
gopd: 1.0.1
|
||||
gopd: 1.1.0
|
||||
which-builtin-type: 1.2.0
|
||||
|
||||
reftools@1.1.9: {}
|
||||
@ -12855,7 +12843,7 @@ snapshots:
|
||||
unicode-match-property-ecmascript: 2.0.0
|
||||
unicode-match-property-value-ecmascript: 2.2.0
|
||||
|
||||
registry-auth-token@5.0.2:
|
||||
registry-auth-token@5.0.3:
|
||||
dependencies:
|
||||
'@pnpm/npm-conf': 2.3.1
|
||||
|
||||
@ -13037,7 +13025,7 @@ snapshots:
|
||||
dependencies:
|
||||
call-bind: 1.0.7
|
||||
es-errors: 1.3.0
|
||||
is-regex: 1.1.4
|
||||
is-regex: 1.2.0
|
||||
|
||||
safer-buffer@2.1.2: {}
|
||||
|
||||
@ -13151,7 +13139,7 @@ snapshots:
|
||||
es-errors: 1.3.0
|
||||
function-bind: 1.1.2
|
||||
get-intrinsic: 1.2.4
|
||||
gopd: 1.0.1
|
||||
gopd: 1.1.0
|
||||
has-property-descriptors: 1.0.2
|
||||
|
||||
set-function-name@2.0.2:
|
||||
@ -13177,7 +13165,7 @@ snapshots:
|
||||
|
||||
shebang-regex@3.0.0: {}
|
||||
|
||||
shell-quote@1.8.1: {}
|
||||
shell-quote@1.8.2: {}
|
||||
|
||||
shelljs@0.8.5:
|
||||
dependencies:
|
||||
@ -13512,7 +13500,7 @@ snapshots:
|
||||
|
||||
type-fest@2.19.0: {}
|
||||
|
||||
type-fest@4.28.0: {}
|
||||
type-fest@4.29.1: {}
|
||||
|
||||
type-is@1.6.18:
|
||||
dependencies:
|
||||
@ -13529,8 +13517,8 @@ snapshots:
|
||||
dependencies:
|
||||
call-bind: 1.0.7
|
||||
for-each: 0.3.3
|
||||
gopd: 1.0.1
|
||||
has-proto: 1.0.3
|
||||
gopd: 1.1.0
|
||||
has-proto: 1.1.0
|
||||
is-typed-array: 1.1.13
|
||||
|
||||
typed-array-byte-offset@1.0.3:
|
||||
@ -13538,8 +13526,8 @@ snapshots:
|
||||
available-typed-arrays: 1.0.7
|
||||
call-bind: 1.0.7
|
||||
for-each: 0.3.3
|
||||
gopd: 1.0.1
|
||||
has-proto: 1.0.3
|
||||
gopd: 1.1.0
|
||||
has-proto: 1.1.0
|
||||
is-typed-array: 1.1.13
|
||||
reflect.getprototypeof: 1.0.7
|
||||
|
||||
@ -13547,7 +13535,7 @@ snapshots:
|
||||
dependencies:
|
||||
call-bind: 1.0.7
|
||||
for-each: 0.3.3
|
||||
gopd: 1.0.1
|
||||
gopd: 1.1.0
|
||||
is-typed-array: 1.1.13
|
||||
possible-typed-array-names: 1.0.0
|
||||
reflect.getprototypeof: 1.0.7
|
||||
@ -13875,7 +13863,7 @@ snapshots:
|
||||
dependencies:
|
||||
is-bigint: 1.0.4
|
||||
is-boolean-object: 1.1.2
|
||||
is-number-object: 1.0.7
|
||||
is-number-object: 1.1.0
|
||||
is-string: 1.0.7
|
||||
is-symbol: 1.0.4
|
||||
|
||||
@ -13888,12 +13876,12 @@ snapshots:
|
||||
is-date-object: 1.0.5
|
||||
is-finalizationregistry: 1.1.0
|
||||
is-generator-function: 1.0.10
|
||||
is-regex: 1.1.4
|
||||
is-regex: 1.2.0
|
||||
is-weakref: 1.0.2
|
||||
isarray: 2.0.5
|
||||
which-boxed-primitive: 1.0.2
|
||||
which-collection: 1.0.2
|
||||
which-typed-array: 1.1.15
|
||||
which-typed-array: 1.1.16
|
||||
|
||||
which-collection@1.0.2:
|
||||
dependencies:
|
||||
@ -13902,12 +13890,12 @@ snapshots:
|
||||
is-weakmap: 2.0.2
|
||||
is-weakset: 2.0.3
|
||||
|
||||
which-typed-array@1.1.15:
|
||||
which-typed-array@1.1.16:
|
||||
dependencies:
|
||||
available-typed-arrays: 1.0.7
|
||||
call-bind: 1.0.7
|
||||
for-each: 0.3.3
|
||||
gopd: 1.0.1
|
||||
gopd: 1.1.0
|
||||
has-tostringtag: 1.0.2
|
||||
|
||||
which@1.3.1:
|
||||
|
@ -10,6 +10,7 @@ This will be the next version of Woodpecker.
|
||||
|
||||
## User migrations
|
||||
|
||||
- `gated` has been replaced by `require-approval`
|
||||
- Removed built-in environment variables:
|
||||
- `CI_COMMIT_URL` use `CI_PIPELINE_FORGE_URL`
|
||||
- `CI_STEP_FINISHED` as empty during execution
|
||||
@ -34,6 +35,7 @@ This will be the next version of Woodpecker.
|
||||
- Removed old API routes: `registry/` -> `registries`, `/authorize/token`
|
||||
- Replaced `registry` command with `repo registry` in cli
|
||||
- Deprecated `secrets`, use `environment` with `from_secret`
|
||||
- Empty string environment variables are not set
|
||||
- CLI commands got restructured to provide a simplified structure:
|
||||
- `woodpecker-cli secret [add|rm|...] --global` is now `woodpecker-cli admin secret [add|rm|...]`
|
||||
- `woodpecker-cli user` is now `woodpecker-cli admin user`
|
||||
|
@ -437,7 +437,7 @@ func podSecurityContext(sc *SecurityContext, secCtxConf SecurityContextConfig, s
|
||||
apparmor = apparmorProfile(sc.ApparmorProfile)
|
||||
}
|
||||
|
||||
if nonRoot == nil && user == nil && group == nil && fsGroup == nil && seccomp == nil {
|
||||
if nonRoot == nil && user == nil && group == nil && fsGroup == nil && seccomp == nil && apparmor == nil {
|
||||
return nil
|
||||
}
|
||||
|
||||
|
@ -25,11 +25,143 @@ import (
|
||||
"github.com/rs/zerolog/log"
|
||||
)
|
||||
|
||||
var (
|
||||
pullRegexp = regexp.MustCompile(`\d+`)
|
||||
const (
|
||||
initialEnvMapSize = 100
|
||||
maxChangedFiles = 500
|
||||
)
|
||||
|
||||
var pullRegexp = regexp.MustCompile(`\d+`)
|
||||
|
||||
// Environ returns the metadata as a map of environment variables.
|
||||
func (m *Metadata) Environ() map[string]string {
|
||||
params := make(map[string]string, initialEnvMapSize)
|
||||
|
||||
system := m.Sys
|
||||
setNonEmptyEnvVar(params, "CI", system.Name)
|
||||
setNonEmptyEnvVar(params, "CI_SYSTEM_NAME", system.Name)
|
||||
setNonEmptyEnvVar(params, "CI_SYSTEM_URL", system.URL)
|
||||
setNonEmptyEnvVar(params, "CI_SYSTEM_HOST", system.Host)
|
||||
setNonEmptyEnvVar(params, "CI_SYSTEM_PLATFORM", system.Platform) // will be set by pipeline platform option or by agent
|
||||
setNonEmptyEnvVar(params, "CI_SYSTEM_VERSION", system.Version)
|
||||
|
||||
forge := m.Forge
|
||||
setNonEmptyEnvVar(params, "CI_FORGE_TYPE", forge.Type)
|
||||
setNonEmptyEnvVar(params, "CI_FORGE_URL", forge.URL)
|
||||
|
||||
repo := m.Repo
|
||||
setNonEmptyEnvVar(params, "CI_REPO", path.Join(repo.Owner, repo.Name))
|
||||
setNonEmptyEnvVar(params, "CI_REPO_NAME", repo.Name)
|
||||
setNonEmptyEnvVar(params, "CI_REPO_OWNER", repo.Owner)
|
||||
setNonEmptyEnvVar(params, "CI_REPO_REMOTE_ID", repo.RemoteID)
|
||||
setNonEmptyEnvVar(params, "CI_REPO_SCM", repo.SCM)
|
||||
setNonEmptyEnvVar(params, "CI_REPO_URL", repo.ForgeURL)
|
||||
setNonEmptyEnvVar(params, "CI_REPO_CLONE_URL", repo.CloneURL)
|
||||
setNonEmptyEnvVar(params, "CI_REPO_CLONE_SSH_URL", repo.CloneSSHURL)
|
||||
setNonEmptyEnvVar(params, "CI_REPO_DEFAULT_BRANCH", repo.Branch)
|
||||
setNonEmptyEnvVar(params, "CI_REPO_PRIVATE", strconv.FormatBool(repo.Private))
|
||||
setNonEmptyEnvVar(params, "CI_REPO_TRUSTED_NETWORK", strconv.FormatBool(repo.Trusted.Network))
|
||||
setNonEmptyEnvVar(params, "CI_REPO_TRUSTED_VOLUMES", strconv.FormatBool(repo.Trusted.Volumes))
|
||||
setNonEmptyEnvVar(params, "CI_REPO_TRUSTED_SECURITY", strconv.FormatBool(repo.Trusted.Security))
|
||||
// Deprecated remove in 4.x
|
||||
setNonEmptyEnvVar(params, "CI_REPO_TRUSTED", strconv.FormatBool(m.Repo.Trusted.Security && m.Repo.Trusted.Network && m.Repo.Trusted.Volumes))
|
||||
|
||||
pipeline := m.Curr
|
||||
setNonEmptyEnvVar(params, "CI_PIPELINE_NUMBER", strconv.FormatInt(pipeline.Number, 10))
|
||||
setNonEmptyEnvVar(params, "CI_PIPELINE_PARENT", strconv.FormatInt(pipeline.Parent, 10))
|
||||
setNonEmptyEnvVar(params, "CI_PIPELINE_EVENT", pipeline.Event)
|
||||
setNonEmptyEnvVar(params, "CI_PIPELINE_URL", m.getPipelineWebURL(pipeline, 0))
|
||||
setNonEmptyEnvVar(params, "CI_PIPELINE_FORGE_URL", pipeline.ForgeURL)
|
||||
setNonEmptyEnvVar(params, "CI_PIPELINE_DEPLOY_TARGET", pipeline.DeployTo)
|
||||
setNonEmptyEnvVar(params, "CI_PIPELINE_DEPLOY_TASK", pipeline.DeployTask)
|
||||
setNonEmptyEnvVar(params, "CI_PIPELINE_CREATED", strconv.FormatInt(pipeline.Created, 10))
|
||||
setNonEmptyEnvVar(params, "CI_PIPELINE_STARTED", strconv.FormatInt(pipeline.Started, 10))
|
||||
|
||||
workflow := m.Workflow
|
||||
setNonEmptyEnvVar(params, "CI_WORKFLOW_NAME", workflow.Name)
|
||||
setNonEmptyEnvVar(params, "CI_WORKFLOW_NUMBER", strconv.Itoa(workflow.Number))
|
||||
|
||||
step := m.Step
|
||||
setNonEmptyEnvVar(params, "CI_STEP_NAME", step.Name)
|
||||
setNonEmptyEnvVar(params, "CI_STEP_NUMBER", strconv.Itoa(step.Number))
|
||||
setNonEmptyEnvVar(params, "CI_STEP_URL", m.getPipelineWebURL(pipeline, step.Number))
|
||||
// CI_STEP_STARTED will be set by agent
|
||||
|
||||
commit := pipeline.Commit
|
||||
setNonEmptyEnvVar(params, "CI_COMMIT_SHA", commit.Sha)
|
||||
setNonEmptyEnvVar(params, "CI_COMMIT_REF", commit.Ref)
|
||||
setNonEmptyEnvVar(params, "CI_COMMIT_REFSPEC", commit.Refspec)
|
||||
setNonEmptyEnvVar(params, "CI_COMMIT_MESSAGE", commit.Message)
|
||||
setNonEmptyEnvVar(params, "CI_COMMIT_BRANCH", sourceBranch)
|
||||
setNonEmptyEnvVar(params, "CI_COMMIT_AUTHOR", commit.Author.Name)
|
||||
setNonEmptyEnvVar(params, "CI_COMMIT_AUTHOR_EMAIL", commit.Author.Email)
|
||||
setNonEmptyEnvVar(params, "CI_COMMIT_AUTHOR_AVATAR", commit.Author.Avatar)
|
||||
if pipeline.Event == EventTag || pipeline.Event == EventRelease || strings.HasPrefix(pipeline.Commit.Ref, "refs/tags/") {
|
||||
setNonEmptyEnvVar(params, "CI_COMMIT_TAG", strings.TrimPrefix(pipeline.Commit.Ref, "refs/tags/"))
|
||||
}
|
||||
if pipeline.Event == EventRelease {
|
||||
setNonEmptyEnvVar(params, "CI_COMMIT_PRERELEASE", strconv.FormatBool(pipeline.Commit.IsPrerelease))
|
||||
}
|
||||
if pipeline.Event == EventPull || pipeline.Event == EventPullClosed {
|
||||
sourceBranch, targetBranch := getSourceTargetBranches(commit.Refspec)
|
||||
setNonEmptyEnvVar(params, "CI_COMMIT_SOURCE_BRANCH", sourceBranch)
|
||||
setNonEmptyEnvVar(params, "CI_COMMIT_TARGET_BRANCH", targetBranch)
|
||||
setNonEmptyEnvVar(params, "CI_COMMIT_PULL_REQUEST", pullRegexp.FindString(pipeline.Commit.Ref))
|
||||
setNonEmptyEnvVar(params, "CI_COMMIT_PULL_REQUEST_LABELS", strings.Join(pipeline.Commit.PullRequestLabels, ","))
|
||||
}
|
||||
|
||||
// Only export changed files if maxChangedFiles is not exceeded
|
||||
changedFiles := commit.ChangedFiles
|
||||
if len(changedFiles) == 0 {
|
||||
params["CI_PIPELINE_FILES"] = "[]"
|
||||
} else if len(changedFiles) <= maxChangedFiles {
|
||||
// we have to use json, as other separators like ;, or space are valid filename chars
|
||||
changedFiles, err := json.Marshal(changedFiles)
|
||||
if err != nil {
|
||||
log.Error().Err(err).Msg("marshal changed files")
|
||||
}
|
||||
params["CI_PIPELINE_FILES"] = string(changedFiles)
|
||||
}
|
||||
|
||||
prevPipeline := m.Prev
|
||||
setNonEmptyEnvVar(params, "CI_PREV_PIPELINE_NUMBER", strconv.FormatInt(prevPipeline.Number, 10))
|
||||
setNonEmptyEnvVar(params, "CI_PREV_PIPELINE_PARENT", strconv.FormatInt(prevPipeline.Parent, 10))
|
||||
setNonEmptyEnvVar(params, "CI_PREV_PIPELINE_EVENT", prevPipeline.Event)
|
||||
setNonEmptyEnvVar(params, "CI_PREV_PIPELINE_URL", m.getPipelineWebURL(prevPipeline, 0))
|
||||
setNonEmptyEnvVar(params, "CI_PREV_PIPELINE_FORGE_URL", prevPipeline.ForgeURL)
|
||||
setNonEmptyEnvVar(params, "CI_PREV_COMMIT_URL", prevPipeline.ForgeURL) // why commit url?
|
||||
setNonEmptyEnvVar(params, "CI_PREV_PIPELINE_DEPLOY_TARGET", prevPipeline.DeployTo)
|
||||
setNonEmptyEnvVar(params, "CI_PREV_PIPELINE_DEPLOY_TASK", prevPipeline.DeployTask)
|
||||
setNonEmptyEnvVar(params, "CI_PREV_PIPELINE_STATUS", prevPipeline.Status)
|
||||
setNonEmptyEnvVar(params, "CI_PREV_PIPELINE_CREATED", strconv.FormatInt(prevPipeline.Created, 10))
|
||||
setNonEmptyEnvVar(params, "CI_PREV_PIPELINE_STARTED", strconv.FormatInt(prevPipeline.Started, 10))
|
||||
setNonEmptyEnvVar(params, "CI_PREV_PIPELINE_FINISHED", strconv.FormatInt(prevPipeline.Finished, 10))
|
||||
|
||||
prevCommit := prevPipeline.Commit
|
||||
setNonEmptyEnvVar(params, "CI_PREV_COMMIT_SHA", prevCommit.Sha)
|
||||
setNonEmptyEnvVar(params, "CI_PREV_COMMIT_REF", prevCommit.Ref)
|
||||
setNonEmptyEnvVar(params, "CI_PREV_COMMIT_REFSPEC", prevCommit.Refspec)
|
||||
setNonEmptyEnvVar(params, "CI_PREV_COMMIT_MESSAGE", prevCommit.Message)
|
||||
setNonEmptyEnvVar(params, "CI_PREV_COMMIT_BRANCH", prevsourceBranch)
|
||||
setNonEmptyEnvVar(params, "CI_PREV_COMMIT_AUTHOR", prevCommit.Author.Name)
|
||||
setNonEmptyEnvVar(params, "CI_PREV_COMMIT_AUTHOR_EMAIL", prevCommit.Author.Email)
|
||||
setNonEmptyEnvVar(params, "CI_PREV_COMMIT_AUTHOR_AVATAR", prevCommit.Author.Avatar)
|
||||
if prevPipeline.Event == EventPull || prevPipeline.Event == EventPullClosed {
|
||||
prevSourceBranch, prevTargetBranch := getSourceTargetBranches(prevCommit.Refspec)
|
||||
setNonEmptyEnvVar(params, "CI_PREV_COMMIT_SOURCE_BRANCH", prevSourceBranch)
|
||||
setNonEmptyEnvVar(params, "CI_PREV_COMMIT_TARGET_BRANCH", prevTargetBranch)
|
||||
}
|
||||
|
||||
return params
|
||||
}
|
||||
|
||||
func (m *Metadata) getPipelineWebURL(pipeline Pipeline, stepNumber int) string {
|
||||
if stepNumber == 0 {
|
||||
return fmt.Sprintf("%s/repos/%d/pipeline/%d", m.Sys.URL, m.Repo.ID, pipeline.Number)
|
||||
}
|
||||
|
||||
return fmt.Sprintf("%s/repos/%d/pipeline/%d/%d", m.Sys.URL, m.Repo.ID, pipeline.Number, stepNumber)
|
||||
}
|
||||
|
||||
func getSourceTargetBranches(refspec string) (string, string) {
|
||||
var (
|
||||
sourceBranch string
|
||||
@ -45,124 +177,10 @@ func getSourceTargetBranches(refspec string) (string, string) {
|
||||
return sourceBranch, targetBranch
|
||||
}
|
||||
|
||||
// Environ returns the metadata as a map of environment variables.
|
||||
func (m *Metadata) Environ() map[string]string {
|
||||
sourceBranch, targetBranch := getSourceTargetBranches(m.Curr.Commit.Refspec)
|
||||
prevSourceBranch, prevTargetBranch := getSourceTargetBranches(m.Prev.Commit.Refspec)
|
||||
|
||||
params := map[string]string{
|
||||
"CI": m.Sys.Name,
|
||||
"CI_REPO": path.Join(m.Repo.Owner, m.Repo.Name),
|
||||
"CI_REPO_NAME": m.Repo.Name,
|
||||
"CI_REPO_OWNER": m.Repo.Owner,
|
||||
"CI_REPO_REMOTE_ID": m.Repo.RemoteID,
|
||||
"CI_REPO_SCM": m.Repo.SCM,
|
||||
"CI_REPO_URL": m.Repo.ForgeURL,
|
||||
"CI_REPO_CLONE_URL": m.Repo.CloneURL,
|
||||
"CI_REPO_CLONE_SSH_URL": m.Repo.CloneSSHURL,
|
||||
"CI_REPO_DEFAULT_BRANCH": m.Repo.Branch,
|
||||
"CI_REPO_PRIVATE": strconv.FormatBool(m.Repo.Private),
|
||||
"CI_REPO_TRUSTED_NETWORK": strconv.FormatBool(m.Repo.Trusted.Network),
|
||||
"CI_REPO_TRUSTED_VOLUMES": strconv.FormatBool(m.Repo.Trusted.Volumes),
|
||||
"CI_REPO_TRUSTED_SECURITY": strconv.FormatBool(m.Repo.Trusted.Security),
|
||||
// Deprecated remove in 4.x
|
||||
"CI_REPO_TRUSTED": strconv.FormatBool(m.Repo.Trusted.Security && m.Repo.Trusted.Network && m.Repo.Trusted.Volumes),
|
||||
|
||||
"CI_COMMIT_SHA": m.Curr.Commit.Sha,
|
||||
"CI_COMMIT_REF": m.Curr.Commit.Ref,
|
||||
"CI_COMMIT_REFSPEC": m.Curr.Commit.Refspec,
|
||||
"CI_COMMIT_BRANCH": sourceBranch,
|
||||
"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_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 pull_request or pull_request_closed
|
||||
"CI_COMMIT_PULL_REQUEST_LABELS": "", // will be set if event is pull_request or pull_request_closed
|
||||
|
||||
"CI_PIPELINE_NUMBER": strconv.FormatInt(m.Curr.Number, 10),
|
||||
"CI_PIPELINE_PARENT": strconv.FormatInt(m.Curr.Parent, 10),
|
||||
"CI_PIPELINE_EVENT": m.Curr.Event,
|
||||
"CI_PIPELINE_URL": m.getPipelineWebURL(m.Curr, 0),
|
||||
"CI_PIPELINE_FORGE_URL": m.Curr.ForgeURL,
|
||||
"CI_PIPELINE_DEPLOY_TARGET": m.Curr.DeployTo,
|
||||
"CI_PIPELINE_DEPLOY_TASK": m.Curr.DeployTask,
|
||||
"CI_PIPELINE_CREATED": strconv.FormatInt(m.Curr.Created, 10),
|
||||
"CI_PIPELINE_STARTED": strconv.FormatInt(m.Curr.Started, 10),
|
||||
|
||||
"CI_WORKFLOW_NAME": m.Workflow.Name,
|
||||
"CI_WORKFLOW_NUMBER": strconv.Itoa(m.Workflow.Number),
|
||||
|
||||
"CI_STEP_NAME": m.Step.Name,
|
||||
"CI_STEP_NUMBER": strconv.Itoa(m.Step.Number),
|
||||
"CI_STEP_STARTED": "", // will be set by agent
|
||||
"CI_STEP_URL": m.getPipelineWebURL(m.Curr, m.Step.Number),
|
||||
|
||||
"CI_PREV_COMMIT_SHA": m.Prev.Commit.Sha,
|
||||
"CI_PREV_COMMIT_REF": m.Prev.Commit.Ref,
|
||||
"CI_PREV_COMMIT_REFSPEC": m.Prev.Commit.Refspec,
|
||||
"CI_PREV_COMMIT_BRANCH": prevSourceBranch,
|
||||
"CI_PREV_COMMIT_URL": m.Prev.ForgeURL,
|
||||
"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_COMMIT_SOURCE_BRANCH": prevSourceBranch,
|
||||
"CI_PREV_COMMIT_TARGET_BRANCH": prevTargetBranch,
|
||||
|
||||
"CI_PREV_PIPELINE_NUMBER": strconv.FormatInt(m.Prev.Number, 10),
|
||||
"CI_PREV_PIPELINE_PARENT": strconv.FormatInt(m.Prev.Parent, 10),
|
||||
"CI_PREV_PIPELINE_EVENT": m.Prev.Event,
|
||||
"CI_PREV_PIPELINE_URL": m.getPipelineWebURL(m.Prev, 0),
|
||||
"CI_PREV_PIPELINE_FORGE_URL": m.Prev.ForgeURL,
|
||||
"CI_PREV_PIPELINE_DEPLOY_TARGET": m.Prev.DeployTo,
|
||||
"CI_PREV_PIPELINE_DEPLOY_TASK": m.Prev.DeployTask,
|
||||
"CI_PREV_PIPELINE_STATUS": m.Prev.Status,
|
||||
"CI_PREV_PIPELINE_CREATED": strconv.FormatInt(m.Prev.Created, 10),
|
||||
"CI_PREV_PIPELINE_STARTED": strconv.FormatInt(m.Prev.Started, 10),
|
||||
"CI_PREV_PIPELINE_FINISHED": strconv.FormatInt(m.Prev.Finished, 10),
|
||||
|
||||
"CI_SYSTEM_NAME": m.Sys.Name,
|
||||
"CI_SYSTEM_URL": m.Sys.URL,
|
||||
"CI_SYSTEM_HOST": m.Sys.Host,
|
||||
"CI_SYSTEM_PLATFORM": m.Sys.Platform, // will be set by pipeline platform option or by agent
|
||||
"CI_SYSTEM_VERSION": m.Sys.Version,
|
||||
|
||||
"CI_FORGE_TYPE": m.Forge.Type,
|
||||
"CI_FORGE_URL": m.Forge.URL,
|
||||
func setNonEmptyEnvVar(env map[string]string, key, value string) {
|
||||
if len(value) > 0 {
|
||||
env[key] = value
|
||||
} else {
|
||||
log.Trace().Str("variable", key).Msg("env var is filtered as it's empty")
|
||||
}
|
||||
if m.Curr.Event == EventTag || m.Curr.Event == EventRelease || strings.HasPrefix(m.Curr.Commit.Ref, "refs/tags/") {
|
||||
params["CI_COMMIT_TAG"] = strings.TrimPrefix(m.Curr.Commit.Ref, "refs/tags/")
|
||||
}
|
||||
if m.Curr.Event == EventRelease {
|
||||
params["CI_COMMIT_PRERELEASE"] = strconv.FormatBool(m.Curr.Commit.IsPrerelease)
|
||||
}
|
||||
if m.Curr.Event == EventPull || m.Curr.Event == EventPullClosed {
|
||||
params["CI_COMMIT_PULL_REQUEST"] = pullRegexp.FindString(m.Curr.Commit.Ref)
|
||||
params["CI_COMMIT_PULL_REQUEST_LABELS"] = strings.Join(m.Curr.Commit.PullRequestLabels, ",")
|
||||
}
|
||||
|
||||
// Only export changed files if maxChangedFiles is not exceeded
|
||||
if len(m.Curr.Commit.ChangedFiles) == 0 {
|
||||
params["CI_PIPELINE_FILES"] = "[]"
|
||||
} else if len(m.Curr.Commit.ChangedFiles) <= maxChangedFiles {
|
||||
// we have to use json, as other separators like ;, or space are valid filename chars
|
||||
changedFiles, err := json.Marshal(m.Curr.Commit.ChangedFiles)
|
||||
if err != nil {
|
||||
log.Error().Err(err).Msg("marshal changed files")
|
||||
}
|
||||
params["CI_PIPELINE_FILES"] = string(changedFiles)
|
||||
}
|
||||
|
||||
return params
|
||||
}
|
||||
|
||||
func (m *Metadata) getPipelineWebURL(pipeline Pipeline, stepNumber int) string {
|
||||
if stepNumber == 0 {
|
||||
return fmt.Sprintf("%s/repos/%d/pipeline/%d", m.Sys.URL, m.Repo.ID, pipeline.Number)
|
||||
}
|
||||
|
||||
return fmt.Sprintf("%s/repos/%d/pipeline/%d/%d", m.Sys.URL, m.Repo.ID, pipeline.Number, stepNumber)
|
||||
}
|
||||
|
@ -314,8 +314,8 @@ func TestCompilerCompile(t *testing.T) {
|
||||
for _, st := range backConf.Stages {
|
||||
for _, s := range st.Steps {
|
||||
s.UUID = ""
|
||||
assert.Truef(t, s.Environment["VERBOSE"] == "true", "expect to get value of global set environment")
|
||||
assert.Truef(t, len(s.Environment) > 50, "expect to have a lot of build in variables")
|
||||
assert.Truef(t, s.Environment["VERBOSE"] == "true", "expected to get value of global set environment")
|
||||
assert.Truef(t, len(s.Environment) > 10, "expected to have a lot of built-in variables")
|
||||
s.Environment = nil
|
||||
}
|
||||
}
|
||||
|
@ -132,7 +132,7 @@ func GetPipelines(c *gin.Context) {
|
||||
if events := c.Query("event"); events != "" {
|
||||
eventList := strings.Split(events, ",")
|
||||
wel := make(model.WebhookEventList, 0, len(eventList))
|
||||
for _, event := range events {
|
||||
for _, event := range eventList {
|
||||
we := model.WebhookEvent(event)
|
||||
if err := we.Validate(); err != nil {
|
||||
_ = c.AbortWithError(http.StatusBadRequest, err)
|
||||
|
@ -96,6 +96,24 @@ func TestGetPipelines(t *testing.T) {
|
||||
|
||||
assert.Equal(t, http.StatusOK, c.Writer.Status())
|
||||
})
|
||||
|
||||
t.Run("should filter pipelines by events", func(t *testing.T) {
|
||||
pipelines := []*model.Pipeline{fakePipeline}
|
||||
mockStore := store_mocks.NewStore(t)
|
||||
mockStore.On("GetPipelineList", mock.Anything, mock.Anything, mock.Anything).Return(pipelines, nil)
|
||||
|
||||
w := httptest.NewRecorder()
|
||||
c, _ := gin.CreateTestContext(w)
|
||||
c.Set("store", mockStore)
|
||||
c.Request, _ = http.NewRequest(http.MethodGet, "/?event=push,pull_request", nil)
|
||||
|
||||
GetPipelines(c)
|
||||
|
||||
mockStore.AssertCalled(t, "GetPipelineList", mock.Anything, mock.Anything, &model.PipelineFilter{
|
||||
Events: model.WebhookEventList{model.EventPush, model.EventPull},
|
||||
})
|
||||
assert.Equal(t, http.StatusOK, c.Writer.Status())
|
||||
})
|
||||
}
|
||||
|
||||
func TestDeletePipeline(t *testing.T) {
|
||||
|
@ -258,12 +258,9 @@ func PatchRepo(c *gin.Context) {
|
||||
c.String(http.StatusBadRequest, "Invalid require-approval setting")
|
||||
return
|
||||
}
|
||||
} else if in.IsGated != nil { // TODO: remove isGated in next major release
|
||||
if *in.IsGated {
|
||||
repo.RequireApproval = model.RequireApprovalAllEvents
|
||||
} else {
|
||||
repo.RequireApproval = model.RequireApprovalForks
|
||||
}
|
||||
} else if in.IsGated != nil {
|
||||
c.String(http.StatusBadRequest, "'gated' option has been removed, use 'require-approval' in >= 3.0")
|
||||
return
|
||||
}
|
||||
if in.Timeout != nil {
|
||||
repo.Timeout = *in.Timeout
|
||||
|
@ -139,8 +139,8 @@ func (g *RPC) Repo(_ context.Context, u *model.User, remoteID model.ForgeRemoteI
|
||||
return nil, err
|
||||
}
|
||||
|
||||
var resp *modelRepo
|
||||
err = json.Unmarshal(jsonResp, resp)
|
||||
var resp modelRepo
|
||||
err = json.Unmarshal(jsonResp, &resp)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
@ -54,8 +54,8 @@ func (s *RPCServer) URL(_ []byte, resp *string) error {
|
||||
}
|
||||
|
||||
func (s *RPCServer) Teams(args []byte, resp *[]byte) error {
|
||||
var a *modelUser
|
||||
err := json.Unmarshal(args, a)
|
||||
var a modelUser
|
||||
err := json.Unmarshal(args, &a)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
@ -82,8 +82,8 @@ func (s *RPCServer) Repo(args []byte, resp *[]byte) error {
|
||||
}
|
||||
|
||||
func (s *RPCServer) Repos(args []byte, resp *[]byte) error {
|
||||
var a *modelUser
|
||||
err := json.Unmarshal(args, a)
|
||||
var a modelUser
|
||||
err := json.Unmarshal(args, &a)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
@ -261,12 +261,12 @@ func (s *RPCServer) Hook(args []byte, resp *[]byte) error {
|
||||
}
|
||||
|
||||
func (s *RPCServer) Login(args []byte, resp *[]byte) error {
|
||||
var a *types.OAuthRequest
|
||||
err := json.Unmarshal(args, a)
|
||||
var a types.OAuthRequest
|
||||
err := json.Unmarshal(args, &a)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
user, red, err := s.Impl.Login(mkCtx(), a)
|
||||
user, red, err := s.Impl.Login(mkCtx(), &a)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
@ -31,23 +31,25 @@ func needsApproval(repo *model.Repo, pipeline *model.Pipeline) bool {
|
||||
return false
|
||||
}
|
||||
|
||||
switch repo.RequireApproval {
|
||||
// repository allows all events without approval
|
||||
if repo.RequireApproval == model.RequireApprovalNone {
|
||||
case model.RequireApprovalNone:
|
||||
return false
|
||||
}
|
||||
|
||||
// repository requires approval for pull requests from forks
|
||||
case model.RequireApprovalForks:
|
||||
if pipeline.Event == model.EventPull && pipeline.FromFork {
|
||||
return true
|
||||
}
|
||||
|
||||
// repository requires approval for pull requests
|
||||
if pipeline.Event == model.EventPull && repo.RequireApproval == model.RequireApprovalPullRequests {
|
||||
case model.RequireApprovalPullRequests:
|
||||
if pipeline.Event == model.EventPull {
|
||||
return true
|
||||
}
|
||||
|
||||
// repository requires approval for all events
|
||||
if repo.RequireApproval == model.RequireApprovalAllEvents {
|
||||
case model.RequireApprovalAllEvents:
|
||||
return true
|
||||
}
|
||||
|
||||
|
@ -44,19 +44,14 @@ func TestMetadataFromStruct(t *testing.T) {
|
||||
expectedMetadata: metadata.Metadata{Sys: metadata.System{Name: "woodpecker"}},
|
||||
expectedEnviron: map[string]string{
|
||||
"CI": "woodpecker",
|
||||
"CI_COMMIT_AUTHOR": "", "CI_COMMIT_AUTHOR_AVATAR": "", "CI_COMMIT_AUTHOR_EMAIL": "", "CI_COMMIT_BRANCH": "",
|
||||
"CI_COMMIT_MESSAGE": "", "CI_COMMIT_PULL_REQUEST": "", "CI_COMMIT_PULL_REQUEST_LABELS": "", "CI_COMMIT_REF": "", "CI_COMMIT_REFSPEC": "", "CI_COMMIT_SHA": "", "CI_COMMIT_SOURCE_BRANCH": "",
|
||||
"CI_COMMIT_TAG": "", "CI_COMMIT_TARGET_BRANCH": "", "CI_FORGE_TYPE": "", "CI_FORGE_URL": "",
|
||||
"CI_PIPELINE_CREATED": "0", "CI_PIPELINE_DEPLOY_TARGET": "", "CI_PIPELINE_DEPLOY_TASK": "", "CI_PIPELINE_EVENT": "", "CI_PIPELINE_FILES": "[]", "CI_PIPELINE_NUMBER": "0",
|
||||
"CI_PIPELINE_PARENT": "0", "CI_PIPELINE_STARTED": "0", "CI_PIPELINE_URL": "/repos/0/pipeline/0", "CI_PIPELINE_FORGE_URL": "",
|
||||
"CI_PREV_COMMIT_AUTHOR": "", "CI_PREV_COMMIT_AUTHOR_AVATAR": "", "CI_PREV_COMMIT_AUTHOR_EMAIL": "", "CI_PREV_COMMIT_BRANCH": "", "CI_PREV_COMMIT_SOURCE_BRANCH": "", "CI_PREV_COMMIT_TARGET_BRANCH": "",
|
||||
"CI_PREV_COMMIT_MESSAGE": "", "CI_PREV_COMMIT_REF": "", "CI_PREV_COMMIT_REFSPEC": "", "CI_PREV_COMMIT_SHA": "", "CI_PREV_COMMIT_URL": "", "CI_PREV_PIPELINE_CREATED": "0",
|
||||
"CI_PREV_PIPELINE_DEPLOY_TARGET": "", "CI_PREV_PIPELINE_DEPLOY_TASK": "", "CI_PREV_PIPELINE_EVENT": "", "CI_PREV_PIPELINE_FINISHED": "0", "CI_PREV_PIPELINE_NUMBER": "0", "CI_PREV_PIPELINE_PARENT": "0",
|
||||
"CI_PREV_PIPELINE_STARTED": "0", "CI_PREV_PIPELINE_STATUS": "", "CI_PREV_PIPELINE_URL": "/repos/0/pipeline/0", "CI_PREV_PIPELINE_FORGE_URL": "", "CI_REPO": "", "CI_REPO_CLONE_URL": "", "CI_REPO_CLONE_SSH_URL": "", "CI_REPO_DEFAULT_BRANCH": "", "CI_REPO_REMOTE_ID": "",
|
||||
"CI_REPO_NAME": "", "CI_REPO_OWNER": "", "CI_REPO_PRIVATE": "false", "CI_REPO_SCM": "", "CI_REPO_TRUSTED": "false", "CI_REPO_TRUSTED_NETWORK": "false",
|
||||
"CI_REPO_TRUSTED_VOLUMES": "false", "CI_REPO_TRUSTED_SECURITY": "false", "CI_REPO_URL": "",
|
||||
"CI_STEP_NAME": "", "CI_STEP_NUMBER": "0", "CI_STEP_STARTED": "", "CI_STEP_URL": "/repos/0/pipeline/0", "CI_SYSTEM_HOST": "", "CI_SYSTEM_NAME": "woodpecker",
|
||||
"CI_SYSTEM_PLATFORM": "", "CI_SYSTEM_URL": "", "CI_SYSTEM_VERSION": "", "CI_WORKFLOW_NAME": "", "CI_WORKFLOW_NUMBER": "0",
|
||||
"CI_PIPELINE_CREATED": "0", "CI_PIPELINE_FILES": "[]", "CI_PIPELINE_NUMBER": "0",
|
||||
"CI_PIPELINE_PARENT": "0", "CI_PIPELINE_STARTED": "0", "CI_PIPELINE_URL": "/repos/0/pipeline/0",
|
||||
"CI_PREV_PIPELINE_CREATED": "0",
|
||||
"CI_PREV_PIPELINE_FINISHED": "0", "CI_PREV_PIPELINE_NUMBER": "0", "CI_PREV_PIPELINE_PARENT": "0",
|
||||
"CI_PREV_PIPELINE_STARTED": "0", "CI_PREV_PIPELINE_URL": "/repos/0/pipeline/0",
|
||||
"CI_REPO_PRIVATE": "false", "CI_REPO_TRUSTED": "false", "CI_REPO_TRUSTED_NETWORK": "false", "CI_REPO_TRUSTED_SECURITY": "false", "CI_REPO_TRUSTED_VOLUMES": "false",
|
||||
"CI_STEP_NUMBER": "0", "CI_STEP_URL": "/repos/0/pipeline/0", "CI_SYSTEM_NAME": "woodpecker",
|
||||
"CI_WORKFLOW_NUMBER": "0",
|
||||
},
|
||||
},
|
||||
{
|
||||
@ -80,21 +75,16 @@ func TestMetadataFromStruct(t *testing.T) {
|
||||
},
|
||||
expectedEnviron: map[string]string{
|
||||
"CI": "woodpecker",
|
||||
"CI_COMMIT_AUTHOR": "", "CI_COMMIT_AUTHOR_AVATAR": "", "CI_COMMIT_AUTHOR_EMAIL": "", "CI_COMMIT_BRANCH": "",
|
||||
"CI_COMMIT_MESSAGE": "", "CI_COMMIT_PULL_REQUEST": "", "CI_COMMIT_PULL_REQUEST_LABELS": "", "CI_COMMIT_REF": "", "CI_COMMIT_REFSPEC": "", "CI_COMMIT_SHA": "", "CI_COMMIT_SOURCE_BRANCH": "",
|
||||
"CI_COMMIT_TAG": "", "CI_COMMIT_TARGET_BRANCH": "", "CI_FORGE_TYPE": "gitea", "CI_FORGE_URL": "https://gitea.com",
|
||||
"CI_PIPELINE_CREATED": "0", "CI_PIPELINE_DEPLOY_TARGET": "", "CI_PIPELINE_DEPLOY_TASK": "", "CI_PIPELINE_EVENT": "", "CI_PIPELINE_FILES": `["test.go","markdown file.md"]`,
|
||||
"CI_PIPELINE_NUMBER": "3", "CI_PIPELINE_PARENT": "0", "CI_PIPELINE_STARTED": "0", "CI_PIPELINE_URL": "https://example.com/repos/0/pipeline/3", "CI_PIPELINE_FORGE_URL": "",
|
||||
"CI_PREV_COMMIT_AUTHOR": "", "CI_PREV_COMMIT_AUTHOR_AVATAR": "", "CI_PREV_COMMIT_AUTHOR_EMAIL": "", "CI_PREV_COMMIT_BRANCH": "", "CI_PREV_COMMIT_SOURCE_BRANCH": "", "CI_PREV_COMMIT_TARGET_BRANCH": "",
|
||||
"CI_PREV_COMMIT_MESSAGE": "", "CI_PREV_COMMIT_REF": "", "CI_PREV_COMMIT_REFSPEC": "", "CI_PREV_COMMIT_SHA": "", "CI_PREV_COMMIT_URL": "", "CI_PREV_PIPELINE_CREATED": "0",
|
||||
"CI_PREV_PIPELINE_DEPLOY_TARGET": "", "CI_PREV_PIPELINE_DEPLOY_TASK": "", "CI_PREV_PIPELINE_EVENT": "", "CI_PREV_PIPELINE_FINISHED": "0", "CI_PREV_PIPELINE_NUMBER": "2", "CI_PREV_PIPELINE_PARENT": "0",
|
||||
"CI_PREV_PIPELINE_STARTED": "0", "CI_PREV_PIPELINE_STATUS": "", "CI_PREV_PIPELINE_URL": "https://example.com/repos/0/pipeline/2", "CI_PREV_PIPELINE_FORGE_URL": "", "CI_REPO": "testUser/testRepo", "CI_REPO_CLONE_URL": "https://gitea.com/testUser/testRepo.git", "CI_REPO_CLONE_SSH_URL": "git@gitea.com:testUser/testRepo.git",
|
||||
"CI_REPO_DEFAULT_BRANCH": "main", "CI_REPO_NAME": "testRepo", "CI_REPO_OWNER": "testUser", "CI_REPO_PRIVATE": "true", "CI_REPO_REMOTE_ID": "",
|
||||
"CI_REPO_SCM": "git", "CI_REPO_TRUSTED": "false", "CI_REPO_TRUSTED_NETWORK": "false",
|
||||
"CI_REPO_TRUSTED_VOLUMES": "false", "CI_REPO_TRUSTED_SECURITY": "false",
|
||||
"CI_REPO_URL": "https://gitea.com/testUser/testRepo",
|
||||
"CI_STEP_NAME": "", "CI_STEP_NUMBER": "0", "CI_STEP_STARTED": "", "CI_STEP_URL": "https://example.com/repos/0/pipeline/3", "CI_SYSTEM_HOST": "example.com",
|
||||
"CI_SYSTEM_NAME": "woodpecker", "CI_SYSTEM_PLATFORM": "", "CI_SYSTEM_URL": "https://example.com", "CI_SYSTEM_VERSION": "", "CI_WORKFLOW_NAME": "hello", "CI_WORKFLOW_NUMBER": "0",
|
||||
"CI_FORGE_TYPE": "gitea", "CI_FORGE_URL": "https://gitea.com",
|
||||
"CI_PIPELINE_CREATED": "0", "CI_PIPELINE_FILES": `["test.go","markdown file.md"]`,
|
||||
"CI_PIPELINE_NUMBER": "3", "CI_PIPELINE_PARENT": "0", "CI_PIPELINE_STARTED": "0", "CI_PIPELINE_URL": "https://example.com/repos/0/pipeline/3",
|
||||
"CI_PREV_PIPELINE_CREATED": "0",
|
||||
"CI_PREV_PIPELINE_FINISHED": "0", "CI_PREV_PIPELINE_NUMBER": "2", "CI_PREV_PIPELINE_PARENT": "0",
|
||||
"CI_PREV_PIPELINE_STARTED": "0", "CI_PREV_PIPELINE_URL": "https://example.com/repos/0/pipeline/2", "CI_REPO": "testUser/testRepo", "CI_REPO_CLONE_URL": "https://gitea.com/testUser/testRepo.git", "CI_REPO_CLONE_SSH_URL": "git@gitea.com:testUser/testRepo.git",
|
||||
"CI_REPO_DEFAULT_BRANCH": "main", "CI_REPO_NAME": "testRepo", "CI_REPO_OWNER": "testUser", "CI_REPO_PRIVATE": "true",
|
||||
"CI_REPO_SCM": "git", "CI_REPO_TRUSTED": "false", "CI_REPO_TRUSTED_NETWORK": "false", "CI_REPO_TRUSTED_SECURITY": "false", "CI_REPO_TRUSTED_VOLUMES": "false",
|
||||
"CI_REPO_URL": "https://gitea.com/testUser/testRepo", "CI_STEP_NUMBER": "0", "CI_STEP_URL": "https://example.com/repos/0/pipeline/3", "CI_SYSTEM_HOST": "example.com",
|
||||
"CI_SYSTEM_NAME": "woodpecker", "CI_SYSTEM_URL": "https://example.com", "CI_WORKFLOW_NAME": "hello", "CI_WORKFLOW_NUMBER": "0",
|
||||
},
|
||||
},
|
||||
}
|
||||
|
@ -140,9 +140,9 @@ func (f *forgeFetcherContext) checkPipelineFile(c context.Context, config string
|
||||
func (f *forgeFetcherContext) getFirstAvailableConfig(c context.Context, configs []string) ([]*types.FileMeta, error) {
|
||||
var forgeErr []error
|
||||
for _, fileOrFolder := range configs {
|
||||
log.Trace().Msgf("fetching %s from forge", fileOrFolder)
|
||||
if strings.HasSuffix(fileOrFolder, "/") {
|
||||
// config is a folder
|
||||
log.Trace().Msgf("fetching %s from forge", fileOrFolder)
|
||||
files, err := f.forge.Dir(c, f.user, f.repo, f.pipeline, strings.TrimSuffix(fileOrFolder, "/"))
|
||||
// if folder is not supported we will get a "Not implemented" error and continue
|
||||
if err != nil {
|
||||
|
@ -26,10 +26,8 @@ var gatedToRequireApproval = xormigrate.Migration{
|
||||
ID: "gated-to-require-approval",
|
||||
MigrateSession: func(sess *xorm.Session) (err error) {
|
||||
const (
|
||||
RequireApprovalNone string = "none"
|
||||
RequireApprovalForks string = "forks"
|
||||
RequireApprovalPullRequests string = "pull_requests"
|
||||
RequireApprovalAllEvents string = "all_events"
|
||||
requireApprovalOldNotGated string = "old_not_gated"
|
||||
requireApprovalAllEvents string = "all_events"
|
||||
)
|
||||
|
||||
type repos struct {
|
||||
@ -45,25 +43,17 @@ var gatedToRequireApproval = xormigrate.Migration{
|
||||
|
||||
// migrate gated repos
|
||||
if _, err := sess.Exec(
|
||||
builder.Update(builder.Eq{"require_approval": RequireApprovalAllEvents}).
|
||||
builder.Update(builder.Eq{"require_approval": requireApprovalAllEvents}).
|
||||
From("repos").
|
||||
Where(builder.Eq{"gated": true})); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
// migrate public repos to new default require approval
|
||||
// migrate non gated repos to old_not_gated (no approval required)
|
||||
if _, err := sess.Exec(
|
||||
builder.Update(builder.Eq{"require_approval": RequireApprovalForks}).
|
||||
builder.Update(builder.Eq{"require_approval": requireApprovalOldNotGated}).
|
||||
From("repos").
|
||||
Where(builder.Eq{"gated": false, "visibility": "public"})); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
// migrate private repos to new default require approval
|
||||
if _, err := sess.Exec(
|
||||
builder.Update(builder.Eq{"require_approval": RequireApprovalNone}).
|
||||
From("repos").
|
||||
Where(builder.Eq{"gated": false}.And(builder.Neq{"visibility": "public"}))); err != nil {
|
||||
Where(builder.Eq{"gated": false})); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
|
@ -0,0 +1,62 @@
|
||||
// Copyright 2024 Woodpecker Authors
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
package migration
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
|
||||
"src.techknowlogick.com/xormigrate"
|
||||
"xorm.io/builder"
|
||||
"xorm.io/xorm"
|
||||
)
|
||||
|
||||
var setNewDefaultsForRequireApproval = xormigrate.Migration{
|
||||
ID: "set-new-defaults-for-require-approval",
|
||||
MigrateSession: func(sess *xorm.Session) (err error) {
|
||||
const (
|
||||
RequireApprovalOldNotGated string = "old_not_gated"
|
||||
RequireApprovalNone string = "none"
|
||||
RequireApprovalForks string = "forks"
|
||||
RequireApprovalAllEvents string = "all_events"
|
||||
)
|
||||
|
||||
type repos struct {
|
||||
RequireApproval string `xorm:"require_approval"`
|
||||
Visibility string `xorm:"varchar(10) 'visibility'"`
|
||||
}
|
||||
|
||||
if err := sess.Sync(new(repos)); err != nil {
|
||||
return fmt.Errorf("sync new models failed: %w", err)
|
||||
}
|
||||
|
||||
// migrate public repos to require approval for forks
|
||||
if _, err := sess.Exec(
|
||||
builder.Update(builder.Eq{"require_approval": RequireApprovalForks}).
|
||||
From("repos").
|
||||
Where(builder.Eq{"require_approval": RequireApprovalOldNotGated, "visibility": "public"})); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
// migrate private repos to require no approval
|
||||
if _, err := sess.Exec(
|
||||
builder.Update(builder.Eq{"require_approval": RequireApprovalNone}).
|
||||
From("repos").
|
||||
Where(builder.Eq{"require_approval": RequireApprovalOldNotGated}.And(builder.Neq{"visibility": "public"}))); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
return nil
|
||||
},
|
||||
}
|
@ -50,6 +50,7 @@ var migrationTasks = []*xormigrate.Migration{
|
||||
&gatedToRequireApproval,
|
||||
&removeRepoNetrcOnlyTrusted,
|
||||
&renameTokenFields,
|
||||
&setNewDefaultsForRequireApproval,
|
||||
}
|
||||
|
||||
var allBeans = []any{
|
||||
|
@ -58,7 +58,7 @@
|
||||
"prettier": "^3.3.3",
|
||||
"tinycolor2": "^1.6.0",
|
||||
"typescript": "5.6.3",
|
||||
"vite": "^5.4.1",
|
||||
"vite": "^6.0.0",
|
||||
"vite-plugin-prismjs": "^0.0.11",
|
||||
"vite-plugin-windicss": "^1.9.3",
|
||||
"vite-svg-loader": "^5.1.0",
|
||||
|
1252
web/pnpm-lock.yaml
generated
1252
web/pnpm-lock.yaml
generated
File diff suppressed because it is too large
Load Diff
@ -518,7 +518,8 @@
|
||||
"not_started": "noch nicht gestartet",
|
||||
"sec_short": "sek",
|
||||
"template": "DD.MM.YYYY, HH:mm z",
|
||||
"weeks_short": "w"
|
||||
"weeks_short": "w",
|
||||
"just_now": "gerade eben"
|
||||
},
|
||||
"unknown_error": "Ein unbekannter Fehler ist aufgetreten",
|
||||
"update_woodpecker": "Du solltest deine Woodpecker-Instanz auf {0} aktualisieren",
|
||||
|
@ -193,8 +193,8 @@
|
||||
"add": "Ajouter un dépôt",
|
||||
"branches": "Branches",
|
||||
"deploy_pipeline": {
|
||||
"enter_target": "Environnement de déploiement ciblé",
|
||||
"title": "Déclenchement d'un événement de déploiement pour le pipeline courant #{pipelineId}",
|
||||
"enter_target": "Environnement de 'déploiement' ciblé",
|
||||
"title": "Déclenchement d'un événement de 'déploiement' pour le pipeline courant #{pipelineId}",
|
||||
"trigger": "Déployer",
|
||||
"variables": {
|
||||
"add": "Ajouter une variable",
|
||||
@ -365,7 +365,7 @@
|
||||
"general": {
|
||||
"allow_pr": {
|
||||
"allow": "Autoriser les demandes de fusions",
|
||||
"desc": "Les pipelines peuvent se déclencher sur les pull requests."
|
||||
"desc": "Permettre aux pipelines de se déclencher sur les pull requests."
|
||||
},
|
||||
"cancel_prev": {
|
||||
"cancel": "Annuler les pipelines précédents",
|
||||
@ -373,8 +373,8 @@
|
||||
},
|
||||
"general": "Général",
|
||||
"netrc_only_trusted": {
|
||||
"desc": "Injecter les identifiants netrc uniquement dans des conteneurs de confiance (recommandé).",
|
||||
"netrc_only_trusted": "Injecter les identifiants netrc uniquement dans des conteneurs de confiance"
|
||||
"desc": "Les plugins listés ici auront accès aux identifiants netrc qui peuvent être utiliser pour cloner des dépôts depuis la forge, ou pour pousser vers celle-ci.",
|
||||
"netrc_only_trusted": "Plugins de clonage personnalisés de confiance"
|
||||
},
|
||||
"pipeline_path": {
|
||||
"default": "Par défaut : .woodpecker/*.{'{yaml,yml}'} -> .woodpecker.yaml -> .woodpecker.yml",
|
||||
@ -388,14 +388,23 @@
|
||||
"protected": "Protégé"
|
||||
},
|
||||
"save": "Enregistrer les paramètres",
|
||||
"success": "Paramètres du dépôt mis à jour",
|
||||
"success": "Paramètres du projet mis à jour",
|
||||
"timeout": {
|
||||
"minutes": "minutes",
|
||||
"timeout": "Délai d’inactivité"
|
||||
},
|
||||
"trusted": {
|
||||
"desc": "Les conteneurs du pipeline ont accès à des capacités privilégiées (comme le montage de volumes).",
|
||||
"trusted": "Vérifié"
|
||||
"trusted": "Vérifié",
|
||||
"network": {
|
||||
"network": "Réseau"
|
||||
},
|
||||
"volumes": {
|
||||
"volumes": "Volumes"
|
||||
},
|
||||
"security": {
|
||||
"security": "Sécurité"
|
||||
}
|
||||
},
|
||||
"visibility": {
|
||||
"internal": {
|
||||
@ -413,8 +422,8 @@
|
||||
"visibility": "Visibilité du projet"
|
||||
},
|
||||
"allow_deploy": {
|
||||
"allow": "Autoriser les déploiements",
|
||||
"desc": "Autoriser les déploiements depuis les pipelines ayant réussis. À utiliser que si vous avez confiance dans les utilisateurs ayant un accès en écriture."
|
||||
"allow": "Autoriser les événements de 'déploiement'.",
|
||||
"desc": "Permettre les déploiements depuis les pipelines ayant réussis. À utiliser que si vous avez confiance dans les utilisateurs ayant un accès en écriture."
|
||||
}
|
||||
},
|
||||
"not_allowed": "Vous n'êtes pas autorisé à accéder aux paramètres de ce dépôt",
|
||||
@ -463,7 +472,22 @@
|
||||
},
|
||||
"settings": "Paramètres"
|
||||
},
|
||||
"user_none": "Cet(te) organisation / utilisateur n'a pas encore de projets."
|
||||
"user_none": "Cet(te) organisation / utilisateur n'a pas encore de projets.",
|
||||
"visibility": {
|
||||
"visibility": "Visibilité du projet",
|
||||
"public": {
|
||||
"public": "Publique",
|
||||
"desc": "Tout le monde peut voir le projet sans être connecté."
|
||||
},
|
||||
"private": {
|
||||
"private": "Privé",
|
||||
"desc": "Seul vous et les propriétaires de ce dépôt peuvent le voir."
|
||||
},
|
||||
"internal": {
|
||||
"internal": "Interne",
|
||||
"desc": "Seuls les comptes identifiés sur cet instance de Woodpecker peuvent voir ce projet."
|
||||
}
|
||||
}
|
||||
},
|
||||
"repos": "Dépôt",
|
||||
"repositories": "Dépôts",
|
||||
@ -476,7 +500,8 @@
|
||||
"not_started": "pas encore démarré",
|
||||
"sec_short": "sec",
|
||||
"template": "D MMM, YYYY, HH:mm z",
|
||||
"weeks_short": "s"
|
||||
"weeks_short": "s",
|
||||
"just_now": "il y a peu de temps"
|
||||
},
|
||||
"unknown_error": "Une erreur inconnue est survenue",
|
||||
"update_woodpecker": "Merci de mettre à jour votre instance Woodpecker vers la version {0}",
|
||||
|
@ -1,10 +1,13 @@
|
||||
<template>
|
||||
<Panel>
|
||||
<div class="flex flex-col border-b mb-4 pb-4 justify-center dark:border-wp-background-100">
|
||||
<div class="flex items-center justify-between">
|
||||
<h1 class="text-xl text-wp-text-100 flex items-center gap-1">
|
||||
{{ title }}
|
||||
<DocsLink v-if="docsUrl" :topic="title" :url="docsUrl" />
|
||||
</h1>
|
||||
<slot v-if="$slots.titleActions" name="titleActions" />
|
||||
</div>
|
||||
|
||||
<div class="flex flex-wrap gap-x-4 gap-y-2 items-center justify-between">
|
||||
<p v-if="description" class="text-sm text-wp-text-alt-100">{{ description }}</p>
|
||||
|
@ -1,6 +1,6 @@
|
||||
<template>
|
||||
<Settings :title="$t('repo.settings.badge.badge')">
|
||||
<template #headerActions>
|
||||
<template #titleActions>
|
||||
<a v-if="badgeUrl" :href="badgeUrl" target="_blank">
|
||||
<img :src="badgeUrl" />
|
||||
</a>
|
||||
|
@ -80,7 +80,6 @@ type (
|
||||
RepoPatch struct {
|
||||
Config *string `json:"config_file,omitempty"`
|
||||
IsTrusted *bool `json:"trusted,omitempty"`
|
||||
IsGated *bool `json:"gated,omitempty"` // TODO: remove in next major release
|
||||
RequireApproval *ApprovalMode `json:"require_approval,omitempty"`
|
||||
Timeout *int64 `json:"timeout,omitempty"`
|
||||
Visibility *string `json:"visibility"`
|
||||
|
Loading…
Reference in New Issue
Block a user