Skip to content

Support setting commit status #82

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

Merged
merged 1 commit into from
Jan 13, 2016

Conversation

cdbennett
Copy link

Support commit status updates. Commit status can be set by a POST to
the appropriate commit URL. The status can be updated by a subsequent
POST to the same URL with the same name and ref, but different
values for state, description, etc.

@@ -787,6 +802,7 @@ class Project(GitlabObject):
managers = [
('branches', ProjectBranchManager, [('project_id', 'id')]),
('commits', ProjectCommitManager, [('project_id', 'id')]),
('statuses', ProjectCommitStatusManager, [('project_id', 'id')]),
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For consistency I'd call the attribute 'commitstatuses' instead of 'statuses' (to match the class name).

@gpocentek
Copy link
Contributor

Looks good, but could you address my comments? Thanks!

@cdbennett
Copy link
Author

Sure, thanks for the review and suggestions. I update based on your recommendations.

Support commit status updates.  Commit status can be set by a POST to
the appropriate commit URL.  The status can be updated by a subsequent
POST to the same URL with the same `name` and `ref`, but different
values for `state`, `description`, etc.

Note: Listing the commit statuses is not yet supported.  This is done
through a different path on the server, under the `repository` path.

Example of use from the CLI:

    # add a build status to a commit
    gitlab project-commit-status create --project-id 2 \
        --commit-id a43290c --state success --name ci/jenkins \
        --target-url http://server/build/123 \
        --description "Jenkins build succeeded"
@cdbennett
Copy link
Author

OK, I addressed your comments by doing the following and rebased the topic branch fresh on master:

  1. Rename attribute to commitstatuses
  2. Add blank line per PEP8
  3. Remove deprecated function that was being added to Gitlab class
  4. And also: Remove usage example from the deleted README.md file

The usage example seems helpful to give a quick summary of the expectations of the multiple GitLab attributes for this operation:

gitlab project-commit-status create --project-id 2 --commit-id a43290c \
    --state success --name ci/jenkins --target-url http://server/build/123 \
    --description "Jenkins build succeeded"

And the docstring that was in the Gitlab class function was a useful quick reference:

    This is often used for automated software build or test status.

    Args:
        id: Commit reference.
        kwargs: Arbitrary keyword arguments for the status:
            Required:
            - state: pending, running, success, failed, canceled
            Optional:
            - description: short description of this status
            - name:        label for this status e.g., name=ci/jenkins
            - ref:         branch reference e.g., ref=master
            - target_url:  hyperlink target for this status

At some point it would be nice to add this kind of info to the docs for the project-commit-status creation operation.

gpocentek pushed a commit that referenced this pull request Jan 13, 2016
Support setting commit status
@gpocentek gpocentek merged commit 02c5398 into python-gitlab:master Jan 13, 2016
@gpocentek
Copy link
Contributor

Thanks for the patch. I'll add the documentation bits

@cdbennett cdbennett deleted the commitstatus branch February 5, 2016 22:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants