{"id":19687182,"url":"https://github.com/trinitronx/jenkins-job-batch-git-clone","last_synced_at":"2025-10-17T21:38:12.294Z","repository":{"id":136205803,"uuid":"43445112","full_name":"trinitronx/jenkins-job-batch-git-clone","owner":"trinitronx","description":"Query Jenkins Server API for jobs matching filter / regex \u0026 clone all git repos","archived":false,"fork":false,"pushed_at":"2015-10-01T20:03:30.000Z","size":136,"stargazers_count":2,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-01-10T07:47:18.665Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"Ruby","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/trinitronx.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2015-09-30T16:39:37.000Z","updated_at":"2021-02-19T10:58:29.000Z","dependencies_parsed_at":"2023-03-13T10:42:37.529Z","dependency_job_id":null,"html_url":"https://github.com/trinitronx/jenkins-job-batch-git-clone","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/trinitronx%2Fjenkins-job-batch-git-clone","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/trinitronx%2Fjenkins-job-batch-git-clone/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/trinitronx%2Fjenkins-job-batch-git-clone/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/trinitronx%2Fjenkins-job-batch-git-clone/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/trinitronx","download_url":"https://codeload.github.com/trinitronx/jenkins-job-batch-git-clone/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":240993952,"owners_count":19890419,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-11-11T18:33:20.447Z","updated_at":"2025-10-17T21:38:07.256Z","avatar_url":"https://github.com/trinitronx.png","language":"Ruby","funding_links":[],"categories":[],"sub_categories":[],"readme":"Jenkins Job Batch Git Clone\n===========================\n\nA Ruby Script to query a Jenkins Server and find the jobs matching a particular filter.\nGet the Git clone URL of each job and check them out to `/tmp/src`.\n\nAvailable Environment Variables\n-------------------------------\n\n - `GIT_CLONE_DIR`: Checkout repo to this directory **inside** the Docker Container.\u003cbr/\u003e (Useful for [boot2docker][b2docker] / [docker-machine][docker-machine] running on a Mac with an automatic `/Users` shared directory from Host Mac -\u003e Docker Host VM)\n - `GIT_CLONE_USER`: Checkout repo using this SSH username.\u003cbr/\u003e (Translates to: `git clone ssh://${GIT_CLONE_USER}@host:port/path`)\n - `GIT_CLONE_FQDN`: Default FQDN to use for short hostnames found for git repo URIs.\u003cbr/\u003e (Useful when short hostnames are found in Jenkins Job git URIs which are not resolvable from the Docker Container)\n - `JENKINS_DEBUG`: Turns on extra info debug logging.\n - `JENKINS_HOST`: Jenkins Host to query for job list.\n - `JENKINS_JOB_FILTER`: A regex to filter what jobs to search for Git URIs.\u003cbr/\u003e (Uses: `@client.job.list(jobs_to_filter)` from [jenkins_api_client][jenkins-api])\n - `JENKINS_PASSWORD`: Jenkins [API Access Token][jenkins-api-token].\u003cbr/\u003e Get one via: `http://jenkins.yourdomain.example.net/me/configure`\n - `JENKINS_PORT`: Port to access Jenkins API on.\n - `JENKINS_USER`: User to access Jenkins API with.\n\nExample Usage\n-------------\n\nYou will need an API token from your Jenkins Server to use this script.  To obtain one:\n\n - Go to: http://jenkins.example.net/user/me/configure\n - Click \"`Show API Token...`\"\n - Copy the API Token\n\nUse the API Token as `JENKINS_PASSWORD` when running the container.\n\n### Examples:\n\nTo checkout all repos listed in Jenkins Jobs matching '`foo`' to `~/src` on the Docker Host, run:\n\n    docker run -ti -e JENKINS_HOST=jenkins.example.net -e JENKINS_USER=myjenkinsuser -e JENKINS_PASSWORD=1deadbeefbadc0de123456789abcd -e JENKINS_JOB_FILTER='foo' -v ~/src/:/tmp/src trinitronx/jenkins-job-batch-git-clone\n\nTo checkout all repos listed in Jenkins Jobs matching '`foo`' to `/Users/myboot2dockeruser/src` in the Docker Container, run:\n\n    docker run -ti -e GIT_CHECKOUT_DIR=/Users/myboot2dockeruser/src -e JENKINS_HOST=jenkins.example.net -e JENKINS_USER=myjenkinsuser -e JENKINS_PASSWORD=1deadbeefbadc0de123456789abcd -e JENKINS_JOB_FILTER='foo' -v ~/src/:/tmp/src trinitronx/jenkins-job-batch-git-clone\n\n\nTo run in debug mode (shows extra info):\n\n    docker run -ti -e JENKINS_DEBUG=1 -e JENKINS_HOST=jenkins.example.net -e JENKINS_USER=myjenkinsuser -e JENKINS_PASSWORD=1deadbeefbadc0de123456789abcd -e JENKINS_JOB_FILTER='foo' -v ~/src/:/tmp/src trinitronx/jenkins-job-batch-git-clone\n\nTo run in debug mode \u0026 test repo checkout only inside Docker Container's `/tmp/src` directory (doesn't checkout files to the Docker Host):\n\n    docker run -ti -e JENKINS_DEBUG=1 -e JENKINS_HOST=jenkins.example.net -e JENKINS_USER=myjenkinsuser -e JENKINS_PASSWORD=1deadbeefbadc0de123456789abcd -e JENKINS_JOB_FILTER='foo' trinitronx/jenkins-job-batch-git-clone\n\n\nKnown Issues / TODO\n-------------------\n\nIf cloning via SSH URI, or private repos git credentials can prevent an easy batch clone.  You will need to pass through your git SSH keys, or use `ssh-agent`.  In the case of GitHub, you may choose to use a [GitHub API Token][github-api-token].\n\nA good place to start is to run `ssh-agent` on either the Docker Host machine, or on the Hosting physical machine that is running [`boot2docker`][b2docker] or [`docker-machine`][docker-machine].  You will then need to pass through the `$SSH_AUTH_SOCK` environment variable, and mount the actual socket file as a [docker volume][docker-volumes] into the Docker Container.  The [method][docker-ssh-agent] for doing this depends on where you are running the `docker` daemon (e.g.: [`boot2docker`][b2docker] on a Mac / physical machine, [`docker-machine`][docker-machine] on a Mac / physical machine, inside another Linux VM, on a physical machine, etc...)\n\nHere are some helpful methods:\n\n - [If using `docker` daemon on physical or VM host][docker-ssh-forward]\n - [If using `boot2docker`][b2docker-ssh-agent], or [this script][b2docker-ssh-agent-script]\n - [If using `docker-machine`][docker-machine-ssh-agent]\n\n[b2docker]: http://boot2docker.io/\n[docker-machine]: https://docs.docker.com/machine/\n[jenkins-api]: https://github.com/arangamani/jenkins_api_client\n[jenkins-api-token]: https://wiki.jenkins-ci.org/display/JENKINS/Authenticating+scripted+clients\n[docker-volumes]: http://container-solutions.com/understanding-volumes-docker/\n[docker-ssh-agent]: http://stackoverflow.com/q/27036936/645491\n[docker-ssh-forward]: https://gist.github.com/d11wtq/8699521\n[b2docker-ssh-agent]: https://gist.github.com/d11wtq/8699521#gistcomment-1424725\n[b2docker-ssh-agent-script]: https://gist.github.com/rcoup/53e8dee9f5ea27a51855\n[docker-machine-ssh-agent]: https://gist.github.com/leedm777/923706741c8296869e7d\n[github-api-token]: https://github.com/blog/1509-personal-api-tokens\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftrinitronx%2Fjenkins-job-batch-git-clone","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ftrinitronx%2Fjenkins-job-batch-git-clone","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftrinitronx%2Fjenkins-job-batch-git-clone/lists"}