softdevteam / mattermost-github-integration

GitHub integration for Mattermost
Other
79 stars 50 forks source link

AttributeError: 'module' object has no attribute 'SERVER #50

Closed etursunbaev closed 5 years ago

etursunbaev commented 5 years ago
root@mmm:/mattermost-github-integration# python server.py
Traceback (most recent call last):
  File "server.py", line 7, in <module>
    host=config.SERVER['address'] or "0.0.0.0",
AttributeError: 'module' object has no attribute 'SERVER'
root@mmm:/mattermost-github-integration# 

Using method 1

README is not clear full

How to install and run properly this app?

root@mmm:/mattermost-github-integration# cat mattermostgithub/config.py
USERNAME = "Github"
ICON_URL = ""

# Repository settings
MATTERMOST_WEBHOOK_URLS = {
    'default' : ("https://my_domain.com/hooks/eimqnptb678gfrwb9w56szeaya", "room-bots"),
}

# Ignore specified event actions
GITHUB_IGNORE_ACTIONS = {
    "pull_request": ["synchronize"]
}

# Ignore events from specified users
IGNORE_USERS = {
    "someuser": ["push"],
    "anotheruser": ["push", "create"]
}

# Redirect events to different channels
REDIRECT_EVENTS = {
    "push": "commits"
}
SECRET = ""
SHOW_AVATARS = True
SERVER = {
    'hook': "/",
    'address': "0.0.0.0",
    'port': 5000,
}
ptersilie commented 5 years ago

You are right, the Readme is not entirely clear on this. The config.py file needs to be copied to the root folder, e.g. mattermost-github-integration. I will adjust the Readme accordingly.

ptersilie commented 5 years ago

Actually, it shouldn't matter. The config can live either in the root or in mattermostgithub. In your case it may be that you have another config.py in the root, which is missing the SERVER bit. So maybe just delete that or move mattermost-github-integration/mattermostgithub/config.py to mattermost-github-integration/config.py.

etursunbaev commented 5 years ago

copied to root and seems to work now

root@mmm:/mattermost-github-integration# python server.py
 * Serving Flask app "mattermostgithub" (lazy loading)
 * Environment: production
   WARNING: Do not use the development server in a production environment.
   Use a production WSGI server instead.
 * Debug mode: off
 * Running on http://0.0.0.0:5000/ (Press CTRL+C to quit)

How to make sure it works?

I mean the mattermost part, which webhooks to use "incoming/outgoing" and etc?

etursunbaev commented 5 years ago

I need some good instruction how to configure in mattermost and GitHub parts.

ptersilie commented 5 years ago

You have to use incoming webhooks. See https://docs.mattermost.com/developer/webhooks-incoming.html for more information on this.

etursunbaev commented 5 years ago

seems I am close to make it work, but anyway not clear and I do smth wrong I have 2 servers: Server A, running Mattermost and incoming webhook is created and using mm.example.com domain name Server B, running this integration app on LXC container and using integration.example.com domain name. Also 80 port is proxy passed to LXC container to 5000 port

Should be used one domain name in both servers? or better use in one server?

etursunbaev commented 5 years ago

@ptersilie sorry man, can you help me to make it run your product.

etursunbaev commented 5 years ago

Made it work when in one server and same domain Made it work on different servers and domain names.

Thank you

it would be awesome add other events

ptersilie commented 5 years ago

Great! If there's events missing, please file an another issue or if you want make a PR for them.