Modify YACC settings programmatically

YACC settings can be fetched and modified via the Bitbucket REST API, as documented here. For example,

Fetching the YACC settings for a repository

Pre-receive hook settings:

curl -u admin -X GET -d "" -H "Content-Type: application/json" http://localhost:7990/rest/api/latest/projects/PROJECT_1/repos/rep_1/settings/hooks/com.isroot.stash.plugin.yacc:yaccHook/settings

Merge check settings:

curl -u admin -X GET -d "" -H "Content-Type: application/json" http://localhost:7990/rest/api/latest/projects/PROJECT_1/repos/rep_1/settings/hooks/com.isroot.stash.plugin.yacc:yaccMergeCheck/settings

Where:

  • admin is replaced with the username for a Bitbucket administrator

  • localhost:7990 is replaced with with the hostname and port of your Bitbucket instance.

  • PROJECT_1 and rep_1 are replaced with the project and repository you are interested in.

If your Bitbucket instance is served via HTTPS, update the command above to https:// instead of http://.

Updating the YACC settings for a repository

Pre-receive hook settings:

curl -u admin -X PUT -d @settings.json -H "Content-Type: application/json" http://localhost:7990/rest/api/latest/projects/PROJECT_1/repos/rep_1/settings/hooks/com.isroot.stash.plugin.yacc:yaccHook/settings

Merge check settings:

curl -u admin -X PUT -d @settings.json -H "Content-Type: application/json" http://localhost:7990/rest/api/latest/projects/PROJECT_1/repos/rep_1/settings/hooks/com.isroot.stash.plugin.yacc:yaccMergeCheck/settings

  • These commands are the same as for fetching the settings, but usePUT instead of GET, and specifies the new settings with the -d flag.

  • To generate settings.json, fetch the full YACC settings as described above and modify as needed.

Turning YACC on or off for a repository

To enable the YACC pre-receive hook for a specific repository:

curl -u admin -X PUT http://localhost:7990/rest/api/latest/projects/PROJECT_1/repos/rep_1/settings/hooks/com.isroot.stash.plugin.yacc:yaccHook/enabled

To disable the YACC pre-receive hook for a specific repository:

curl -u admin -X DELETE http://localhost:7990/rest/api/latest/projects/PROJECT_1/repos/rep_1/settings/hooks/com.isroot.stash.plugin.yacc:yaccHook/enabled

Where:

  • admin is replaced with the username for a Bitbucket administrator

  • localhost:7990 is replaced with with the hostname and port of your Bitbucket instance.

  • PROJECT_1 and rep_1 are replaced with the project and repository you are interested in.

To enable the YACC merge check for a specific repository:

curl -u admin -X PUT http://localhost:7990/rest/api/latest/projects/PROJECT_1/repos/rep_1/settings/hooks/com.isroot.stash.plugin.yacc:yaccMergeCheck/enabled

To disable the YACC merge check for a specific repository:

curl -u admin -X DELETE http://localhost:7990/rest/api/latest/projects/PROJECT_1/repos/rep_1/settings/hooks/com.isroot.stash.plugin.yacc:yaccMergeCheck/enabled

Where:

  • admin is replaced with the username for a Bitbucket administrator

  • localhost:7990 is replaced with with the hostname and port of your Bitbucket instance.

  • PROJECT_1 and rep_1 are replaced with the project and repository you are interested in.

If your Bitbucket instance is served via HTTPS, update the command above to https:// instead of http://.

 

Â