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

rules:changes #395

Closed
ck-trigfb opened this issue Feb 23, 2022 · 2 comments · Fixed by #1221
Closed

rules:changes #395

ck-trigfb opened this issue Feb 23, 2022 · 2 comments · Fixed by #1221
Labels
feature Feature missing according to gitlab ci standard

Comments

@ck-trigfb
Copy link

In Gitlab CI you can add the keyword "rules:changes" for a job that should only be executed if specified file changed.: https://docs.gitlab.com/ee/ci/yaml/#ruleschanges

Example:

build:
  script:
    - echo "building"
  rules:
    - if: $CI_COMMIT_BRANCH == 'master'
      changes:
        - src/**/*

What i want to achieve with that: Assuming you multiple services and all of them will be compiled in a big pipeline. So if i only change something in one of the services i have to wait since the whole pipeline finished building. With "rules:changes" i want to achieve something similar other tools like skaffold do: Only build that service / container where changes in code / configuration happend.

Actual problem: gitlab-ci-local seems to completely ignore that setting. I dont get an error but the job runs regardless of whether changes take place or not.

@firecow
Copy link
Owner

firecow commented Feb 23, 2022

Its ignored on purpose for now 🤣

One way to solve this is via checksum comparison of what ever is specified in changes: unfortunately we can't rely on git commit sha's via git log command, like remote can.

@firecow firecow added the feature Feature missing according to gitlab ci standard label Feb 23, 2022
@firecow firecow changed the title Support rules:changes rules:changes Feb 23, 2022
@ck-trigfb
Copy link
Author

Maybe you can do somthing like this
git diff --name-only HEAD HEAD~1
or this:
git diff --name-only HEAD~1

This will result in something like this:

.gitlab-ci-local/.gitignore
.gitlab-ci.yml
src/main/java/com/example/demo/DemoApplication.java

Then you can compare if some of the changed files match to the filter criteria in the "rules:changes" section.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature Feature missing according to gitlab ci standard
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants