Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add changed files env var #853

Closed
3 tasks done
qwerty287 opened this issue Mar 26, 2022 · 5 comments · Fixed by #2935
Closed
3 tasks done

Add changed files env var #853

qwerty287 opened this issue Mar 26, 2022 · 5 comments · Fixed by #2935
Labels
feature add new functionality

Comments

@qwerty287
Copy link
Contributor

qwerty287 commented Mar 26, 2022

Clear and concise description of the problem

There isn't a way to get the changed files of a commit/PR, which would be useful for static code checks so that they don't have to run on all files, only changed ones.

Suggested solution

Add an environment variable that contains changed files, i.e. the list under the Changed files tab. To make it machine-readable, a json-style string could used. For example, this build would be:

[".woodpecker/docs.yml"]

And an example with more files from a PR, https://ci.woodpecker-ci.org/woodpecker-ci/woodpecker/build/2303:

["web/src/components/repo/build/BuildLog.vue","web/package.json","web/yarn.lock","web/src/components/repo/build/BuildProcList.vue","web/src/compositions/useBuildProc.ts","web/src/views/repo/build/Build.vue","web/src/views/repo/build/BuildWrapper.vue"]

Alternative

I don't know if that's possible, but you could extract the build URL and then request the files from the api (if there's one).

Additional context

I'm working on a plugin which checks files and I don't want this plugin to check all files of a repo, only changed ones.

Validations

@wxiaoguang
Copy link

Maybe another alternative: let plugin-git output the changed files into a file in workspace. It could avoid large memory usage if there are a lot of changed files in a big repo.

@luwol03
Copy link

luwol03 commented Mar 26, 2022

Why integrating all that into woodpecker? What about a 3rd party plugin like it can be archived with github actions?

@qwerty287
Copy link
Contributor Author

If you refer to this action, this is what @wxiaoguang is suggesting (plugin-git isn't part of woodpecker itself).
For me this option is fine, but it would be probably good to

  • not save the file into the repository folder, but another one
  • make this have a fixed location in docker containers or just add something like an env var with the file location

@qwerty287
Copy link
Contributor Author

In general, I'd say the plugin approach requires a way to store data outside of the repo itself and then always add this as an extra volume to the docker containers, and maybe provide an env var likeg CI_EXTERNAL that allows to find the directory easily that is used to store data outside of the repo.

@anbraten anbraten added feature add new functionality and removed pending:feature labels Feb 28, 2023
@zc-devs
Copy link
Contributor

zc-devs commented Dec 3, 2023

We can use something like git diff --name-only HEAD HEAD~1 > "$WORKDIR/changed.txt (and store it in workspace, it is volume already).

6543 added a commit that referenced this issue Dec 18, 2023
add **`CI_PIPELINE_FILES`** to builtin env vars

close  #853

---
*Sponsored by Kithara Software GmbH*
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature add new functionality
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants