Commit graph

1036 commits

Author SHA1 Message Date
Matheus Moraes 85e157bb10
fix(server/api/repo): Fix repair webhook host (#2372)
Fixes https://github.com/woodpecker-ci/woodpecker/issues/2371

Similar change to
https://github.com/woodpecker-ci/woodpecker/pull/1869/files#diff-3cd73db84155aa0447a17dadc8f50271d646fcf6132606cf2ab703cc7b80eb38R113
2023-09-06 12:17:23 +02:00
qwerty287 56b8ba151a
Delete repos/secrets on org deletion (#2367) 2023-09-02 15:00:13 +02:00
qwerty287 3e563ef198
Use API error helpers and improve response codes (#2366) 2023-09-02 13:31:10 +02:00
guangwu 287590acfb
Import packages only once (#2362)
Co-authored-by: qwerty287 <80460567+qwerty287@users.noreply.github.com>
2023-09-01 17:02:21 +02:00
qwerty287 aab7e73322
Execute make generate with new versions (#2365)
Fixes current swagger checks:
https://ci.woodpecker-ci.org/repos/3780/pipeline/7605/26
2023-09-01 16:44:55 +02:00
qwerty287 e847cbadfa
Check permissions on repo lookup (#2357)
There was no permission check when looking up repos so you were able to
get basic repo information even if you're not allowed to.

This uses `session.MustPull` (and set repo/perms before) to fix this.
2023-08-30 16:35:34 +02:00
qwerty287 5bd12aa646
Show that repo is disabled (#2340)
And allow to show badges for disabled repos

Fixes 3rd checkbox from
https://github.com/woodpecker-ci/woodpecker/discussions/2162#discussion-5498655

![Screenshot 2023-08-28 at 11-13-23
Woodpecker](https://github.com/woodpecker-ci/woodpecker/assets/80460567/d881f0c5-6225-4921-9d05-a26f27ad5365)
2023-08-28 18:57:44 +02:00
Anbraten 25225d4902
Update grpc generated code (#2339)
missed in #2173

---------
2023-08-28 18:00:52 +02:00
qwerty287 6f1f0e37ce
Fix org fetching (#2343) 2023-08-28 17:01:18 +02:00
qwerty287 479ced3b25
Add org list (#2338)
![Screenshot 2023-08-28 at 10-08-20
Woodpecker](https://github.com/woodpecker-ci/woodpecker/assets/80460567/e3248b05-7899-43ca-a0cf-4834eae078d8)
Closes #2307
2023-08-28 11:15:16 +02:00
qwerty287 7adfa6c2ba
Fix migration (#2319) 2023-08-22 17:37:29 +02:00
Pablo Ovelleiro Corral cf9a4be128
Add missing return (#2316) 2023-08-22 09:47:29 +02:00
Anbraten 4de8cbec76
Rename grpc pipeline to workflow (#2173)
closes #1823

Co-authored-by: 6543 <6543@obermui.de>
2023-08-21 18:30:19 +02:00
qwerty287 81ead7cbf2
Support user secrets (#2126) 2023-08-21 15:04:12 +02:00
Pablo Ovelleiro Corral 09624aa286
Pass netrc data to external config service request (#2310)
Co-authored-by: Anbraten <anton@ju60.de>
2023-08-21 13:22:33 +02:00
Lauris BH a58e3b9e06
Handle parsed hooks that should be ignored (#2243)
Currently it would fail with panic:

```
runtime error: invalid memory address or nil pointer dereference
...
/woodpecker/src/github.com/woodpecker-ci/woodpecker/server/forge/gitea/gitea.go:492 (0xdfb32e)
```
2023-08-18 14:25:29 +02:00
6543 a5ef372190
Move "skip ci" logic into global pipeline conditions (#2216)
... and make custom errors follow std err conventions

this fix a 500 response if the whole pipeline is filtered out
2023-08-17 15:52:43 +02:00
6543 c2448b1745
Restructure webhook parsing (#2221)
Co-authored-by: Anbraten <anton@ju60.de>
2023-08-16 16:15:44 +02:00
Anbraten 479e500b1b
Move hook and events-stream routes to use /api prefix (#2212)
- move hook and events-stream routes to use `/api` prefix
- rename build to pipeline
2023-08-16 02:42:37 +02:00
qwerty287 4d83ea0de8
Add SSH clone URL env var (#2198)
to improve https://github.com/woodpecker-ci/plugin-git/pull/75
2023-08-12 17:39:13 +02:00
qwerty287 8cdac56d8f
Check for correct license header (#2137) 2023-08-10 11:06:00 +02:00
qwerty287 6e0def58a1
Switch to upstream ttlcache (#2187)
We've been using https://github.com/lafriks/ttlcache but it's archived.
It does work with the upstream library too, so its better to use it.
2023-08-10 09:17:12 +02:00
6543 63d5c40afd
Deprecate "platform" filter in favour of "labels" (#2181)
Co-authored-by: qwerty287 <80460567+qwerty287@users.noreply.github.com>
2023-08-09 16:09:44 +02:00
6543 ada3659eb7
make EqualStringSlice to generic EqualSliceValues (#2179)
just a fly-by refactoring
2023-08-09 09:00:12 +02:00
6543 17ab945825
Fix 'add-orgs' migration (#2117)
close  #2096

~~blocked by https://gitea.com/xorm/xorm/pulls/2320~~
2023-08-08 00:16:50 +03:00
6543 d253f8cc30
Make sure we dont have hidden options for backend and pipeline compiler (#2123)
move options based on **os.Getenv** into flags

---------
*Sponsored by Kithara Software GmbH*
2023-08-07 21:13:26 +02:00
qwerty287 4558f7c691
Fix vite server (#2134)
#1799 broke it
2023-08-07 17:03:26 +02:00
qwerty287 67b7de5cc2
Fix UI and backend paths with subpath (#1799)
I'm not sure if this is an ideal fix for this, but it seems to work for
me. If you have another idea just let me know.

Closes #1798 
Closes #1773
2023-08-07 16:05:18 +02:00
qwerty287 4ad3968ff1
Fix swagger response code (#2119)
Closes #2118
2023-08-05 19:44:49 +02:00
runephilosof-karnovgroup 8487ed92cd
Forge Github Org: Use login instead of name (#2104)
For "woodpecker-ci" the `name` is "Woodpecker CI"
 and the `login` is "woodpecker-ci"

Fixes #2092

This was causing the organization lookup to fail, because it looks up
using the `login`, when it did not find the organization, it would try
to create it. The creation would fail, because it uses the `name`, and
an organization with that `name` already exists.
Resulting in:

```
pq: duplicate key value violates unique constraint "UQE_orgs_name"
```
2023-08-03 17:30:56 +02:00
qwerty287 1a7f7a9427
Allow to disable swagger (#2093)
https://github.com/woodpecker-ci/woodpecker/issues/1944
2023-08-03 02:42:30 +02:00
Michalis Zampetakis b0fe17322f
Add some testsvfor bitbucket forge (#2097) 2023-08-03 02:06:03 +02:00
Michalis Zampetakis 4ad2c4eb45
Support bitbucket Dir() / multi-workflows (#2045) 2023-08-02 13:15:57 +02:00
Anbraten e0ed1b3e49
Change master to main (#2044) 2023-07-31 05:47:23 +02:00
Anbraten 5a812e3254
Remove default branch fallbacks (#2065) 2023-07-30 18:28:52 +02:00
6543 6d373daea0
Handle case where there is no latest pipeline for GetBadge (#2042)
address  error 2 of #2036
2023-07-28 00:34:22 +02:00
6543 bc2e2c7a1b
let generic datastore error include func name (#2041)
error logs like:
```
{"level":"warn","error":"sql: no rows in result set","time":"2023-07-25T21:29:56Z"}
```

have to less context to be helpfull.
this will cange it as the message now looks like:

```
{"level":"warn","error":"GetPipelineLast: sql: no rows in result set", "time":"2023-07-27T02:54:25+02:00"}
```
2023-07-27 21:22:24 +02:00
Anbraten e5d5ec8b47
Use id to access orgs (#1873)
closes #1743 

fixes: setting secrets for own user namespace

- create org in database
- use orgID for org related APIs

Co-authored-by: 6543 <6543@obermui.de>
2023-07-21 19:45:32 +02:00
Michalis Zampetakis dcba48f916
Add bitbucket forge BranchHead implementation (#2011)
In order to test this functionality, we had to expose the `BranchHead()`
through an API endpoint
```
GET /repos/{repo_id}/branches/{branch}/head
```

The response is a string that contains the latest commit hash of the
requested branch.
2023-07-17 21:30:06 +02:00
6543 1b646a28b4
Index stepID for logEntries so loading time decrease significantly (#2006)
speedup from 2min loading to 0.01sec :D

got missed by  #1802
2023-07-17 02:35:20 +03:00
Robert Kaussow 443c23c58a
Use global logger for xorm logs and add options (#1997)
Please let me know if this goes in the right direction. Needs some tests and docs.
2023-07-15 01:15:13 +02:00
6543 d9991e67e5
let HookParse func explicit ignore events (#1942)
for now it's not clear defined, what to do on an unsupported event.
e.g. gitea webhook panel shows 500 error and no message.

now we have a successful webhook and a message to show an info
2023-07-14 02:03:54 +02:00
qwerty287 570f5044e8
Drop support for Bitbucket Server (#1994)
Closes #1962
2023-07-13 15:47:25 +02:00
Patrick Schratz a4c791c6e5
Correct wording (#1982) 2023-07-12 13:49:18 +02:00
6543 edb92025df
Correct api docs of PostRepo & GetRepos (#1974)
... and report if needed forge_remote_id is not valid
2023-07-11 18:51:03 +02:00
6543 e85eeb10fc
Fix repo gate protection (#1969)
- clarify docs
- don't block cron pipelines
- run manual triggered pipelines right away

---------

Co-authored-by: Anbraten <anton@ju60.de>
2023-07-11 17:34:50 +02:00
6543 b54f6ebad6
Let pipeline-compiler export step types (#1958) 2023-07-11 15:53:05 +02:00
Martin W. Kirst 2c1fc4b500
support custom .JS and .CSS files for custom banner messages (white-labeling) (#1781)
This PR introduces two new server configuration options, for providing a
custom .JS and .CSS file.
These can be used to show custom banner messages, add
environment-dependent signals, or simply a corporate logo.

### Motivation (what problem I try to solve)

I'm operating Woodpecker in multiple k8s clusters for different
environments.
When having multiple browser tabs open, I prefer strong indicators for
each environment.
E.g. a red "PROD" banner, or just a blue "QA" banner.
Also, we sometimes need to have the chance for maintenance, and instead
of broadcasting emails,
I prefer a banner message, stating something like: "Heads-up: there's a
planned downtime, next Friday, blabla...".

Also, I like to have the firm's logo visible, which makes Woodpecker
look more like an integral part of our platform.

### Implementation notes

* Two new config options are introduced ```WOODPECKER_CUSTOM_CSS_FILE```
and ```WOODPECKER_CUSTOM_JS_FILE```
* I've piggy-bagged the existing handler for assets, as it seemed to me
a minimally invasive approach
* the option along with an example is documented
* a simple unit test for the Gin-handler ensures some regression safety
* no extra dependencies are introduced

### Visual example

The documented example will look like this.

![Screenshot 2023-05-27 at 17 00
44](https://github.com/woodpecker-ci/woodpecker/assets/1189394/8940392e-463c-4651-a1eb-f017cd3cd64d)

### Areas of uncertainty 

This is my first contribution to Woodpecker and I tried my best to align
with your conventions.
That said, I found myself uncertain about these things and would be glad
about getting feedback.

* The handler tests are somewhat different than the other ones because I
wanted to keep them simple - I hope that still matches your coding
guidelines
* caching the page sometimes will let the browser not recognize changes
and a user must reload. I'm not fully into the details of how caching is
implemented and neither can judge if it's a real problem. Another pair
of eyes would be good.
2023-07-10 12:46:35 +02:00
6543 7c99c8b843
Adjust model database type mapping (#1949)
adjust definitions according to feedback from real world usage
(ci.codeberg.org)

close  #1892
close  #1865
2023-07-08 20:09:53 +02:00
6543 6c58e9db9b
Fix agent auth (#1952)
if no global agent secret set, disable agent registration via it
2023-07-08 18:09:34 +02:00
6543 b4acbafffc
save forge at the beginning and use it (#1939)
fly-by refactor ...
2023-07-07 15:43:11 +02:00
6543 2961aaf72b
Harden datastore (#1940)
- only explicit when filters
 - write all more complex filter with builder
 - reuse builder
2023-07-07 13:10:16 +02:00
6543 94f2331a4c
Make sure step passed into go routine exist and does not change (#1903)
just a tiny code improvement
2023-07-06 20:19:10 +02:00
Thomas Anderson b616a822a0
Fixed when:evaluate on non-standard (non-CI*) env vars (#1907)
Makes it possible to evaluate `when` constraint on custom environment
variables.
2023-07-02 23:45:22 +02:00
Anbraten 3d435a9cb7
Fix log view (#1874)
closes #1857
closes #1520
closes #1879 
- fixes unicode log lines as reported in matrix

---------

Co-authored-by: 6543 <6543@obermui.de>
2023-07-01 18:55:00 +02:00
qwerty287 cd982fcbd1
Fix pipeline status calculation/reporting (#1898)
Closes #1895 
Regression of #1784
2023-06-29 14:56:01 +02:00
6543 e1c31df6c6
Refactor AgentFindByToken (#1891)
followup of #1890
2023-06-28 06:59:58 +02:00
Anbraten b57b6f27f6
Fix empty agent token (#1890)
Using an empty token for an agent was returning the first agent from the
database as the orm is not adding where clauses for empty strings of a
model when querying.

# Huge thanks for reporting and explaining the issue ❤️ 

- Dominik Heidler
- Timo Tomasini
2023-06-28 01:22:19 +02:00
Michalis Zampetakis 456725dde7
Add pull-request implementation for bitbucket forge (#1889) 2023-06-27 23:40:28 +02:00
qwerty287 3033abc3b4
Add own workflow model (#1784)
Closes #1287

---------

Co-authored-by: 6543 <6543@obermui.de>
2023-06-27 18:01:18 +02:00
Michalis Zampetakis b1787f82dc
Fix bitbucket forge add repo (#1887)
The workspace is a required field for ivoking bitbucket's API. While
workspace is not available it must be fetched through the Repos func.

Fixes #1882
2023-06-26 23:55:21 +02:00
Benedikt Kleiner a958049485
sync repo permissions on login (#1853)
if indeed a bug, fixes #1851 after re-log

close #1666
2023-06-24 10:08:34 +02:00
qwerty287 c3c1d3bcb5
Return after error (#1875)
This allows you to work around the max timeout on the server.
2023-06-19 17:46:48 +02:00
Thomas Anderson 0c3021473f
Added Woodpecker Host Config used for Webhooks (#1869)
When SCM and Woodpecker are deployed in the same cluster, I want that
SCM requests Woodpecker directly by internal URL.


![Webhook-host-diagram](https://github.com/woodpecker-ci/woodpecker/assets/127358482/c4689d55-839a-4731-95b3-5734ba561e5f)
 
This PR adds optional URL used for Webhook calls.
2023-06-18 14:47:40 +02:00
Benedikt Kleiner 182a236793
logs stream: fix url parameter (#1858)
was missed during #1691
2023-06-13 14:40:40 +02:00
6543 6be61e6c9a
logs table migration: skip on corrupted json and fail later (#1856)
enhance  #1828
2023-06-13 12:50:11 +03:00
Anbraten ff01a9ff1d
Access repos by their ids (#1691)
closes #1295 
closes #648

# TODO
- [x] add new routes with `:repoID`
- [x] load repo in middleware using `:repoID` if present
- [x] update UI routes `:owner/:name` to `:repoID`
- [x] load repos using id in UI
- [x] add lookup endpoint `:owner/:name` to `:repoID`
- [x] redirect `:owner/:name` to `:repoID` in UI
- [x] use badge with `:repoID` route in UI
- [x] update `woodpecker-go`
- [x] check cli
- [x] add migrations / deprecation notes
- [x] check if #648 got solved directly
- [x] Test
  - [x] create repo
  - [x] repo pages
  - [x] ui redirects
  - [x] forge status links
2023-06-13 01:07:52 +02:00
6543 5139624cf8
Migrate old logs to new database schema (#1828)
address new models based on #1802
2023-06-12 22:43:14 +02:00
6543 b5b3b95721
Print ongoing alive sign for migrations after 20s (#1846) 2023-06-10 12:59:15 +03:00
qwerty287 5d74174bc3
Drop old columns (#1838) 2023-06-07 19:22:44 +02:00
Anbraten 556607b525
Rework log streaming and related functions (#1802)
closes #1801
closes #1815 
closes #1144
closes  #983
closes  #557
closes #1827
regression of #1791

# TODO
- [x] adjust log model
- [x] add migration for logs
- [x] send log line via grpc using step-id
- [x] save log-line to db
- [x] stream log-lines to UI
- [x] use less structs for log-data
- [x] make web UI work
  - [x] display logs loaded from db
  - [x] display streaming logs
- [ ] ~~make migration work~~ -> dedicated pull (#1828)

# TESTED
- [x] new logs are stored in database
- [x] log retrieval via cli (of new logs) works
- [x] log streaming works (tested via curl & webui)
- [x] log retrieval via web (of new logs) works

---------

Co-authored-by: 6543 <6543@obermui.de>
2023-06-06 09:52:08 +02:00
qwerty287 b82ed13586
Database migrations run in seperate sessions and commit on success right away (#1822)
This isolates single migration tasks from each other.
The migration itself is now not atomic anymore but each single migration
now on it's own.
This takes load away from databases, as new sessions have a committed
schema available.

We also disable xorm.cache, as the speed improvements are minor but
invalid cache caused by schema changes did happen already in the past.

---------
Reverts #1817
Closes #1821

---------

Co-authored-by: 6543 <6543@obermui.de>
2023-06-06 03:27:17 +02:00
6543 ea895baf83
Resolve built-in variables for global when filter (#1790)
addresses
bd461477bd

close  #1244, close #1580

---------

Co-authored-by: Anbraten <anton@ju60.de>
2023-06-05 00:15:07 +02:00
Martin W. Kirst 14177635b6
Update swagger API specification (#1782)
# Summary

This PR drops the outdated former swagger.yaml/json and introduced
automatic API document generation from Go code.
The generated code is also used to generate documentation/markdown for
the community page,
as well as enable the Woodpecker server to serve a Swagger Web UI for
manual tinkering.

I did opt-in for gin-swagger, a middleware for the Gin framework, to
ease implementation and have a sophisticated output.
This middleware only produces Swagger v2 specs. AFAIK the newer OpenApi
3x tooling is not yet that mature,
so I guess that's fine for now.

## Implemenation notes

- former swagger.json files removed
- former // swagger godocs removed
- introduced new dependency gin-swagger, which uses godoc annotations on
top of Gin Handler functions.
- reworked Makefile to automatically generate Go code for the server
- introduce new dependency go-swagger, to generate Markdown for
documentation purposes
- add a Swagger Web UI, incl. capabilities for manual API exploration
- consider relative root paths in the implementation
- write documentation for all exposed API endpoints
- incl. API docs in the community website (auto-generated)
- provide developer documentation, for the Woodpecker authors
- no other existing logic/code was intentionally changed

---------

close #292

---------

Co-authored-by: qwerty287 <80460567+qwerty287@users.noreply.github.com>
Co-authored-by: 6543 <6543@obermui.de>
2023-06-03 21:38:36 +02:00
qwerty287 b9731d8da9
Fix missing table name (#1817)
Bug from #1806 

We don't need the sync because the step_machine is there since the model
was added the first time so it mill *always* be in the table
2023-06-03 20:24:37 +02:00
6543 317bd24abb
Define Glossary (#1800)
based on
https://github.com/woodpecker-ci/woodpecker/issues/745#issuecomment-1313401427

close  #1724

---------

Co-authored-by: qwerty287 <80460567+qwerty287@users.noreply.github.com>
Co-authored-by: Anbraten <anton@ju60.de>
2023-06-03 16:39:56 +02:00
qwerty287 b59d654f45
Do not use oauth client without token (#1803)
Closes https://github.com/woodpecker-ci/woodpecker/issues/1370
2023-06-03 03:03:06 +02:00
qwerty287 36870d1797
Drop step_machine column (#1806)
Bug 3 in #1712 

Was changed in f13ffc2c8f
2023-06-02 14:39:29 +02:00
Xavier Maillard f683c62748
Fix Gitea version constraint to get files changed on PR (#1805) 2023-06-02 12:41:49 +02:00
Xavier Maillard 9813411c69
Fix nil pointer in repo repair (#1804)
Address **Bug 2** from the following issue
https://github.com/woodpecker-ci/woodpecker/issues/1712
2023-06-02 12:25:09 +02:00
qwerty287 f91ee5d23a
Remove MSSQL specific code and cleanups (#1796)
We don't have MSSQL support

---------

Co-authored-by: Anbraten <anton@ju60.de>
2023-05-31 21:27:57 +02:00
6543 524611cf00
Add Forge Metadata (#1789)
close  #1787
2023-05-31 18:30:41 +02:00
Anbraten c464f857ae
Remove unused file system api (#1791)
Co-authored-by: 6543 <6543@obermui.de>
2023-05-31 18:03:03 +02:00
6543 f5a85d21be
Drop ".drone.yml" as default pipeline config (#1795)
it did make sense to have it still supported within v0.15.0,

but as we move future away and with the release of v1.0.0
we should not give the appearance of still support the original drone
v0.8 config
2023-05-31 16:02:20 +02:00
qwerty287 540ad108df
Fix static assets with subpath (#1783)
Closes #1773
2023-05-30 17:25:18 +02:00
qwerty287 3605979df0
Fix pipeline used for status reporting (#1758) 2023-05-14 16:12:48 +02:00
qwerty287 a15821428f
Always send a status back to forge (#1751) 2023-05-14 14:18:43 +02:00
qwerty287 2ccf7c6f1a
Drop Gogs support (#1752)
Gogs support is broken (and we won't fix it because we don't care about
it...) because it does not support OAuth, at least after we introduced
the new Vue UI.

See:

77d830d5b5/server/forge/gogs/gogs.go (L84)

This route is not present in the new UI.
2023-05-14 10:34:05 +02:00
meak 41a50ae915
Allow to configure port for SSL (#1735)
Co-authored-by: Mehdi Katranji <hello@mek.yt>
Co-authored-by: Lauris BH <lauris@nix.lv>
2023-05-11 06:11:10 +02:00
qwerty287 6d2240b2e6
Identify users using their remote ID (#1732) 2023-05-11 05:19:35 +02:00
6543 f3074ddaf9
Some small code refactorings (#1727)
Refactorings taken from pull requests #1722 and #1725
2023-04-30 17:02:47 +02:00
qwerty287 54d4ec04c0
Drop Gogs private mode (#1726)
You should use `WOODPECKER_AUTHENTICATE_PUBLIC_REPOS` instead if repos
sent from forge as public should be authenticated
2023-04-30 14:01:11 +02:00
qwerty287 0f9188597e
Initiate Pagination Implementation for API and Infinite Scroll in UI (#1651)
- Add pagination support to the API endpoints that return lists of items
- Adjust UI to enable infinite scrolling via pagination
2023-04-30 03:40:13 +02:00
qwerty287 b90e7904a5
Support path prefix (#1714)
closes #1636 
closes #1429
supersedes #1586

Uses a different approach: just take the index.html compiled by vite and
replace the paths to js and other files using regex. This is not
compatible with the dev proxy which is also the reason why we can't use
go templates for this.
2023-04-29 17:51:50 +02:00
qwerty287 cfdb32ae45
Fully support .yaml (#1713)
Follow-up to https://github.com/woodpecker-ci/woodpecker/pull/1388
Closes https://github.com/woodpecker-ci/woodpecker/issues/1073

---------

Co-authored-by: 6543 <6543@obermui.de>
2023-04-29 10:12:36 +02:00
qwerty287 9b32d021b3
Consistent status on delete (#1703)
Closes #1675
2023-04-15 15:22:39 +02:00
qwerty287 a06d3e1a61
Stable sort order for DB lists (#1702) 2023-04-11 09:33:27 +02:00
Anbraten 36b5ae3459
Add env for workflow and step name (#1693)
closes #1681
2023-04-08 13:15:28 +02:00
Julien Palard 6af9371011
Docs: The WOODPECKER_ADMIN environment variable is singular. (#1699) 2023-04-08 01:34:36 +02:00
qwerty287 4b4d078377
Fix Bitbucket Server branches (#1698)
Closes #1695
2023-04-07 18:09:17 +02:00