src/main/java/org/gitlab4j/api/ProjectApi.java
public PushRules createPushRules(Integer projectId, PushRules pushRule) throws GitLabApiException {

        if (projectId == null) {
            throw new RuntimeException("projectId cannot be null");
        }

        GitLabApiForm formData = new GitLabApiForm()
            .withParam("deny_delete_tag", pushRule.getDenyDeleteTag())
            .withParam("member_check", pushRule.getMemberCheck())
            .withParam("prevent_secrets", pushRule.getPreventSecrets())
            .withParam("commit_message_regex", pushRule.getCommitMessageRegex())
            .withParam("branch_name_regex", pushRule.getBranchNameRegex())
            .withParam("author_email_regex", pushRule.getAuthorEmailRegex())
            .withParam("file_name_regex", pushRule.getFileNameRegex())
            .withParam("max_file_size", pushRule.getMaxFileSize());

        Response response = post(Response.Status.CREATED, formData, "projects", projectId, "push_rule");
        return (response.readEntity(PushRules.class));
    }
/**
     * Adds a push rule to a specified project.
     *
     * POST /projects/:id/push_rule
     *
     * The following properties on the PushRules instance are utilized in the creation of the push rule:
     *
     *<code>
     * denyDeleteTag (optional) - Deny deleting a tag
     * memberCheck (optional) - Restrict commits by author (email) to existing GitLab users
     * preventSecrets (optional) - GitLab will reject any files that are likely to contain secrets
     * commitMessageRegex (optional) - All commit messages must match this, e.g. Fixed \d+\..*
     * branchNameRegex (optional) - All branch names must match this, e.g. `(feature
     * authorEmailRegex (optional) - All commit author emails must match this, e.g. @my-company.com$
     * fileNameRegex (optional) - All committed filenames must not match this, e.g. `(jar
     * maxFileSize (optional) - Maximum file size (MB
     *</code>
     *
     * @param projectId the project ID to add the push rule to
     * @param pushRule the PushRule instance containing the push rule configuration to add
     * @return a PushRules instance with the newly created push rule info
     * @throws GitLabApiException if any exception occurs
     */
Adds a push rule to a specified project.

The following properties on the PushRules instance are utilized in the creation of the push rule.

denyDeleteTag (optional) - Deny deleting a tag
memberCheck (optional) - Restrict commits by author (email) to existing GitLab users
preventSecrets (optional) - GitLab will reject any files that are likely to contain secrets
commitMessageRegex (optional) - All commit messages must match this, e.g. Fixed \d+\
branchNameRegex (optional) - All branch names must match this, e.g. `(feature
authorEmailRegex (optional) - All commit author emails must match this, e.g. @my-company.com$
fileNameRegex (optional) - All committed filenames must not match this, e.g. `(jar
maxFileSize (optional) - Maximum file size (MB

@param projectId the project ID to add the push rule to
@param pushRule the PushRule instance containing the push rule configuration to add
@return a PushRules instance with the newly created push rule info
@throws GitLabApiException if any exception occurs
Adds a push rule to a specified project . The following properties on the PushRules instance are utilized in the creation of the push rule . denyDeleteTag ( optional ) - Deny deleting a tag memberCheck ( optional ) - Restrict commits by author ( email ) to existing GitLab users preventSecrets ( optional ) - GitLab will reject any files that are likely to contain secrets commitMessageRegex ( optional ) - All commit messages must match this e . g . Fixed \ d + \ branchNameRegex ( optional ) - All branch names must match this e . g . ` ( feature authorEmailRegex ( optional ) - All commit author emails must match this e . g . @my - company . com$ fileNameRegex ( optional ) - All committed filenames must not match this e . g . ` ( jar maxFileSize ( optional ) - Maximum file size ( MB @param projectId the project ID to add the push rule to @param pushRule the PushRule instance containing the push rule configuration to add @return a PushRules instance with the newly created push rule info @throws GitLabApiException if any exception occurs
public PushRules createPushRules(Integer projectId, PushRules pushRule) throws GitLabApiException {
        if (projectId == null) {
            throw new RuntimeException("projectId cannot be null");
        }
        GitLabApiForm formData = new GitLabApiForm()
            .withParam("deny_delete_tag", pushRule.getDenyDeleteTag())
            .withParam("member_check", pushRule.getMemberCheck())
            .withParam("prevent_secrets", pushRule.getPreventSecrets())
            .withParam("commit_message_regex", pushRule.getCommitMessageRegex())
            .withParam("branch_name_regex", pushRule.getBranchNameRegex())
            .withParam("author_email_regex", pushRule.getAuthorEmailRegex())
            .withParam("file_name_regex", pushRule.getFileNameRegex())
            .withParam("max_file_size", pushRule.getMaxFileSize());
        Response response = post(Response.Status.CREATED, formData, "projects", projectId, "push_rule");
        return (response.readEntity(PushRules.class));
    }
public PushRules createPushRules ( Integer projectId , PushRules pushRule ) throws GitLabApiException { if ( projectId == null ) { throw new RuntimeException ( "projectId cannot be null" ) ; } GitLabApiForm formData = new GitLabApiForm ( ) . withParam ( "deny_delete_tag" , pushRule . getDenyDeleteTag ( ) ) . withParam ( "member_check" , pushRule . getMemberCheck ( ) ) . withParam ( "prevent_secrets" , pushRule . getPreventSecrets ( ) ) . withParam ( "commit_message_regex" , pushRule . getCommitMessageRegex ( ) ) . withParam ( "branch_name_regex" , pushRule . getBranchNameRegex ( ) ) . withParam ( "author_email_regex" , pushRule . getAuthorEmailRegex ( ) ) . withParam ( "file_name_regex" , pushRule . getFileNameRegex ( ) ) . withParam ( "max_file_size" , pushRule . getMaxFileSize ( ) ) ; Response response = post ( Response . Status . CREATED , formData , "projects" , projectId , "push_rule" ) ; return ( response . readEntity ( PushRules . class ) ) ; }
Adds a push rule to a specified project.
Adds a push rule to a specified project .