Skip to content

Update/gitlab v4 api #3

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

Open
wants to merge 13 commits into
base: master
Choose a base branch
from
Open
5 changes: 3 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
/config/parameters.yml
/vendor/
vendor/
composer.phar
config.yaml
23 changes: 4 additions & 19 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -1,22 +1,7 @@
The MIT License (MIT)
Copyright 2018 Velocity, A Managed Services Company

Copyright (c) 2015 Olivier Balais
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:

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.
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.
76 changes: 46 additions & 30 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,49 +1,65 @@
# Create a Gitlab issue from a mail
# GITLAB ISSUE BY E-MAIL

Add new issue to your Gitlab by sending an email to [email protected]
Summary: create an Issue in Gitlab by sending an e-mail

## Why?

Gitlab is a fantastic tool to work with and is getting more awesome everyday.
Gitlab is a fantastic solution to work with and manage source code and issues. Its main features are private repository hosting, issue tracking, code review, and complete workflow all the way through deployment and production.

It offers you in just a few minutes Private Repositories Hosting, great Code Review tooling for your team, Wiki,
Issue Tracker and everything.
As great as it is, there are still a few missing features that we'd all like to have. One of these is the ability to send an e-mail and have an issue automatically created.

But as awesome as it is, we must admit that the Issue Tracker lacks a few features. One of them, is the ability for your
team or customers to send a mail to some mail address of yours and see it transformed into a beautiful Gitab Issue.
## How does it work?

This is the purpose of this ridiculously simple project.
This simple CLI application checks an IMAP e-mail box for any new messages. It uses the subject of the e-mail as the issue title and the body of the e-mail as the issue description and creates a Gitlab issue using Gitlab's API, then the e-mail is deleted. This command can then be executed periodically with a crontab or systemd timer.

## How does it work?
## DEPENDENCIES

- PHP >= `5.6.0`
- PHP extensions
- `imap`
- `pdo-pgsql`

## Quick Start

1. `git clone` this repository
2. `cp config.yaml.example config.yaml`
3. Edit `config.yaml` to match your setup
4. `composer install`
5. `./console gitlab:fetch-mail`

## `confg.yaml` Example

```yaml
mail:
server: imap.yourdomain.tld
type: imap
port: 143
username: gouzigouza
password: passw0rd

gitlab:
host: gitlab.com
projectId: 1
token: 123456789
```

This project is a simple command you can execute every X minutes to poll mail from any address of yours.
If a new mail is detected, the script parse its content, create an issue with the mail subject as title and content as
description and delete it from your mail server. That's all. Nothing more!
## Composer

## Setup
This application uses `composer` to pull in 3rd-party dependencies. If you are unable to install composer from your operating system's repositories, you may use the provided script to fetch a local copy of it. To do this, run the following command:

1. `git clone ...`
2. `cp config/parameters.yml.dist config/parameters.yml` and edit it to fit your needs
`scripts/get_composer.sh` (run from the application's root directory)

```yaml
mail:
server: imap.yourdomain.tld
type: imap
port: 143
username: gouzigouza
password: passw0rd
This will create an executable file called `composer.phar`.

gitlab:
host: gitlab.com
projectId: 1
token: 123456789
```
Executing `./composer.phar install` will install all dependencies

3. `bin/console gitlab:fetch-mail -v`
## Optional configuration

You should create some kind of CRON to run this command regularly.
- Set up a crontab or systemd timer to periodically run `./console gitlab:fetch-mail` at regular intervals. This is outside the scope of this document.

## TODO
## To-do / Planned Features

- Support STARTTLS
- Support multiple API keys (for different users)
- Extract attachments and add them to Gitlab issue
- Add unit tests
11 changes: 0 additions & 11 deletions bin/console

This file was deleted.

39 changes: 33 additions & 6 deletions composer.json
Original file line number Diff line number Diff line change
@@ -1,12 +1,39 @@
{
"name": "velocityorg/gitlab-issue-by-email",
"description": "Create a Gitlab issue by sending an e-mail",
"version": "1.0.1",
"type": "project",
"keywords": [
"gitlab", "email", "mail", "imap", "issue", "git"
],
"license": "MIT",
"authors": [
{
"name": "Steven Cook",
"email": "[email protected]",
"role": "Developer"
}
],
"support": {
"email": "[email protected]"
},
"require": {
"symfony/console": "^2.6",
"tedivm/fetch": "^0.6.1",
"m4tthumphrey/php-gitlab-api": "^7.10",
"symfony/yaml": "^2.6",
"symfony/config": "^2.6"
"guzzlehttp/psr7": "1.4.2",
"m4tthumphrey/php-gitlab-api": "^9.10",
"monolog/monolog": "^1.23",
"php-http/curl-client": "v1.7.1",
"php-http/guzzle6-adapter": "v1.1.1",
"php-http/message": "1.7.0",
"symfony/config": "^v4.1",
"symfony/console": "^v4.1",
"symfony/yaml": "^v4.1",
"tedivm/fetch": "^0.7.1",
"nette/database": "^2.4"
},
"autoload": {
"psr-4": { "Bobey\\": "src/Bobey" }
"psr-4": {
"Bobey\\": "src/Bobey",
"Velocityorg\\": "src/Velocityorg"
}
}
}
Loading