Skip to content

Instantly share code, notes, and snippets.

@kpantic
Last active March 5, 2016 18:54
Show Gist options
  • Save kpantic/22dbe0d0b406aafa2c89 to your computer and use it in GitHub Desktop.
Save kpantic/22dbe0d0b406aafa2c89 to your computer and use it in GitHub Desktop.

Trello

First sync

When a project is initially linked to a Trello board, certain events need to be created to reflect the current status of the project. The following is a list of certain actions that need to be done to reflect the current status on varys.

  • For each card on Trello create the following Events:
    • Event card_created with an event_object_type of card.
    • Event card_added_to_list with an event_object_type of card and its ID.
  • For each list on Trello create the following Events:
    • Event list_created with an event_object_type of list.

Trello Events

Card moved from one list to another

Event card_added_to_list with an event_object_type of card. The event_data must contain the name of the board.

Card created in a list

Event card_created with an event_object_type of card. Event card_added_to_list created as well with an event_object_type of card and the event_data must contain the name of the board.

GitLab

Merge request created

Event merge_request_created is created associated to the user that created the merge request with an event_object_type of merge_request and the event_object_id of the merge request. The assignee of the merge request is available at data['object_attributes']['assignee_id'].

Comment added on merge request

Event comment_on_merge is created associated to the user that create the merge request and the event_object is the Merge Request.

Merge request is closed (not merged)

Event merge_was_closed is created associated to the user that closed it (Merge Master or assignee) and the event object is the Merge Request.

Merge request is re-opened

Event merge_was_reopened is created associated to the user that reopened it (Merge Master or assignee) and the event object is the Merge Request.

Merge request is merged

Event merge_was_merged is created associated to the user that merged it (Merge Master or assignee) and the event object is the Merge Request.

Push event

Event git_push is created associated to the user that pushed it. The event_object_type of this event is a git_push object and its event_object_id is the checkout_sha attribute. Event git_commit is created for each commit in the push and associated to the user that pushed it. The event_object_type is a git_commit object and its event_object_id is the commit hash.

Build event (passed)

Event build_passed is created associated to the user that started it. The event_object_type of this event is a build object and its event_object_id is the same as the build_id in the GitLab event. The duration of the build is available at data['build_duration'].

Build event (failed)

Event build_failed is created associated to the user that started it. The event_object_type of this event is a build object and its event_object_id is the same as the build_id in the GitLab event.

Example JSON objects for different event on GitLab

Merge request created

{
 'project': {
    'git_ssh_url': 'git@gitlab.com:kpantic/cupmatch.git',
    'path_with_namespace': 'kpantic/cupmatch',
    'name': 'cupmatch',
    'avatar_url': None,
    'url': 'git@gitlab.com:kpantic/cupmatch.git',
    'default_branch': 'master',
    'namespace': 'kpantic',
    'git_http_url': 'https://gitlab.com/kpantic/cupmatch.git',
    'web_url': 'https://gitlab.com/kpantic/cupmatch',
    'ssh_url': 'git@gitlab.com:kpantic/cupmatch.git',
    'http_url': 'https://gitlab.com/kpantic/cupmatch.git',
    'visibility_level': 0,
    'homepage': 'https://gitlab.com/kpantic/cupmatch',
    'description': 'A soccer cup match respository, associating each match with the corresping teams, stadium and cup. '
 },
 'object_attributes': {
    'target_project_id': 897098,
    'source_branch': 'revert-db089a61',
    'updated_at': '2016-03-05 16:05:15 UTC',
    'work_in_progress': False,
    'assignee_id': None,
    'updated_by_id': None,
    'id': 351389,
    'target_branch': 'master',
    'merge_error': None,
    'title': 'Revert "Merge branch \'feature/test\' into \'master\'"',
    'merge_commit_sha': None,
    'source': {
       'git_ssh_url': 'git@gitlab.com:kpantic/cupmatch.git',
       'path_with_namespace': 'kpantic/cupmatch',
       'name': 'cupmatch',
       'avatar_url': None,
       'url': 'git@gitlab.com:kpantic/cupmatch.git',
       'default_branch': 'master',
       'namespace': 'kpantic',
       'git_http_url': 'https://gitlab.com/kpantic/cupmatch.git',
       'web_url': 'https://gitlab.com/kpantic/cupmatch',
       'ssh_url': 'git@gitlab.com:kpantic/cupmatch.git',
       'http_url': 'https://gitlab.com/kpantic/cupmatch.git',
       'visibility_level': 0,
       'homepage': 'https://gitlab.com/kpantic/cupmatch',
       'description': 'A soccer cup match respository, associating each match with the corresping teams, stadium and cup. '
    },
    'state': 'opened',
    'last_commit': {
       'url': 'https://gitlab.com/kpantic/cupmatch/commit/def3a7e40bc526d5a2fbd5d04f26f772cad77106',
       'timestamp': '2016-03-05T16:04:56+00:00',
       'message': 'Revert "Merge branch \'feature/test\' into \'master\'\r"\n\nThis reverts merge request !1',
       'id': 'def3a7e40bc526d5a2fbd5d04f26f772cad77106',
       'author': {
          'name': 'Kristoffer Pantic',
          'email': 'kristoffer.pantic@gmail.com'
        }
    },
    'merge_params': {},
    'description': 'This reverts merge request !1',
    'iid': 2,
    'locked_at': None,
    'milestone_id': None,
    'source_project_id': 897098,
    'target': {
       'git_ssh_url': 'git@gitlab.com:kpantic/cupmatch.git',
       'path_with_namespace': 'kpantic/cupmatch',
       'name': 'cupmatch',
       'avatar_url': None,
       'url': 'git@gitlab.com:kpantic/cupmatch.git',
       'default_branch': 'master',
       'namespace': 'kpantic',
       'git_http_url': 'https://gitlab.com/kpantic/cupmatch.git',
       'web_url': 'https://gitlab.com/kpantic/cupmatch',
       'ssh_url': 'git@gitlab.com:kpantic/cupmatch.git',
       'http_url': 'https://gitlab.com/kpantic/cupmatch.git',
       'visibility_level': 0,
       'homepage': 'https://gitlab.com/kpantic/cupmatch',
       'description': 'A soccer cup match respository, associating each match with the corresping teams, stadium and cup. '
    },
    'merge_when_build_succeeds': False,
    'merge_status': 'unchecked',
    'url': 'https://gitlab.com/kpantic/cupmatch/merge_requests/2',
    'created_at': '2016-03-05 16:05:15 UTC',
    'merge_user_id': None,
    'action': 'open',
    'position': 0,
    'author_id': 423134
 },
 'object_kind': 'merge_request',
 'repository': {
    'url': 'git@gitlab.com:kpantic/cupmatch.git',
    'homepage': 'https://gitlab.com/kpantic/cupmatch',
    'name': 'cupmatch',
    'description': 'A soccer cup match respository, associating each match with the corresping teams, stadium and cup. '
 },
 'user': {
    'username': 'kpantic',
    'avatar_url': 'https://secure.gravatar.com/avatar/972777864b63ffac6c541bc69f8138bd?s=80&d=identicon',
    'name': 'Kristoffer Pantic'
 }
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment