0

There is a Bitbucket project with roughly 40 repositories. I would like to add a Jenkins file with lint checking:

staticTests {
    lintTargets = ["*.yml", "roles"] }

to each repository, because cloning each repo, adding the file, then committing and pushing to each repo is a tedious and time consuming task.

I did some searching to check if there is an accepted way to do this automatically, however I could not come up with anything.

EDIT: I believe this question is different to pull/push from multiple remote locations due to involving different repositories rather than different remote locations for the same repository.

tl;dr: How to add a file to multiple different git repositories at once?

B.Batiege
  • 23
  • 4
  • Possible duplicate of [pull/push from multiple remote locations](https://stackoverflow.com/questions/849308/pull-push-from-multiple-remote-locations) – ervidio Oct 03 '17 at 11:21

1 Answers1

0

You can make a script to automate the procedure (clone, add, commit, push) to all repositories, like in the following example:

BITBUCKET_REST_URL="https://BITBUCKET-SERVER/rest/api/1.0"

repos=$(curl -s --user USER:PASS --request GET $BITBUCKET_REST_URL/projects/PROJECT/repos | jq --raw-output '.values[].slug')

for r in $repos
do
    # CLONE
    ...
    # ADD
    ...
    # COMMIT
    ...
    # PUSH
    ...
done