https://github.com/wolox/jenkins-github-job-creator
Script to generate Jenkins jobs with Github repositories
https://github.com/wolox/jenkins-github-job-creator
ci git github jenkins ruby
Last synced: 3 months ago
JSON representation
Script to generate Jenkins jobs with Github repositories
- Host: GitHub
- URL: https://github.com/wolox/jenkins-github-job-creator
- Owner: Wolox
- License: mit
- Created: 2015-02-24T19:13:47.000Z (over 11 years ago)
- Default Branch: master
- Last Pushed: 2023-01-03T13:57:30.000Z (over 3 years ago)
- Last Synced: 2025-01-16T22:26:46.291Z (over 1 year ago)
- Topics: ci, git, github, jenkins, ruby
- Language: Ruby
- Homepage:
- Size: 22.5 KB
- Stars: 0
- Watchers: 23
- Forks: 0
- Open Issues: 3
-
Metadata Files:
- Readme: README.md
- License: LICENSE.md
Awesome Lists containing this project
README
## Jenkins Github Job Creator
This Sinatra project creates jobs in a Jenkins instance with some basic configuration. It does the following:
- Add deploy key to Github repository and a Credential to Jenkins
- Adds Jenkins Service as a Github webhook to allow Pull Requests integration
- Creates the two basic jobs needed for every technology.
This script is used at [Wolox](https://wolox.co), so many things in the script could suit Wolox way or working. Fill free to propose changes.
## Environment Configuration
### Installing Ruby
- Download and install [Rbenv](https://github.com/sstephenson/rbenv).
- Download and install [Ruby-Build](https://github.com/sstephenson/ruby-build).
- Install the appropriate Ruby version by running `rbenv install [version]` where `version` is the one located in [.ruby-version](.ruby-version)
### Installing Gems
- Clone the repository.
- Install [Bundler](http://bundler.io/).
- Install all the gems included in the project.
```bash
git clone https://github.com/Wolox/jenkins-github-job-creator.git
gem install bundler
rbenv rehash
bundle
```
### How to use it
Access to `http://your-server/authorize?project=github-repo-name&tech=project-technology` where `github-repo-name` is the github repository name you want to authorize and `project-technology` is either `rails`, `angular` or `android`.
### Environment configuration
You must have a `.credentials.yml` in the project root with the following information:
- jenkins_url: Jenkins domain url. Eg: `https://some-domain.com`
- access_token: Github access token
- uri: https://api.github.com/repos/your-organization
- jenkins_hook_url: https://your-server/github-webhook/
- username: authentication user
- password: authentication password
- jenkins_api_user: A Github username
- jenkins_api_token: The api token of the Github username username chosen.
## Deploy
Then you need to access the EC2 instance by `ssh` and run:
```bash
sudo su - jenkins
git clone https://github.com/Wolox/jenkins-github-job-creator.git
cd jenkins-github-job-creator
nohup irb authorize.rb&
```
You can kill the process by running `ps ax | grep nohup` and killing it with `kill -9 PID`. If you can't see the process pid and you know its running you can get the pid by running `netstat -l -p | grep 4567`.
## Logs
You can see the logs by running `tail -f nohup.out` under the `jenkins-github-job-creator` folder.
## Nginx configuration
In order to run this Sinatra app with jenkins, you need to configure nginx (/etc/nginx/sites-available/jenkins) like this:
```bash
upstream app_server {
server 127.0.0.1:8080 fail_timeout=0;
}
upstream sinatra {
server 127.0.0.1:4567;
}
server {
listen 80;
listen [::]:80 default ipv6only=on;
server_name your-server-url;
location / {
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header Host $http_host;
proxy_redirect off;
if (!-f $request_filename) {
proxy_pass http://app_server;
break;
}
}
location /authorize {
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header Host $http_host;
proxy_redirect off;
if (!-f $request_filename) {
proxy_pass http://sinatra;
break;
}
}
}
```
## Contributing
1. Fork it
2. Create your feature branch (`git checkout -b my-new-feature`)
3. Commit your changes (`git commit -am 'Add some feature'`)
4. Push to the branch (`git push origin my-new-feature`)
5. Create new Pull Request
## License
```
Copyright (c) 2017 Esteban Pintos
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
```
## Maintainers
This project is maintained by [Esteban Pintos](https://github.com/epintos) and it is written by [Wolox](http://www.wolox.com.ar).
