
Security News
Crates.io Implements Trusted Publishing Support
Crates.io adds Trusted Publishing support, enabling secure GitHub Actions-based crate releases without long-lived API tokens.
bitbucket-server-utils-cli
Advanced tools
[](https://www.npmjs.com/package/bitbucket-server-utils-cli)
Bitbucket Server utilities packaged as a standalone command line tool. Can be used in CI pipelines and similar things.
Using Bitbucket Server REST API
You will need to create a token: https://bitbucket-server/plugins/servlet/access-tokens/manage
The CLI can be run from this repo with:
npm run start -- \
-at asd...asd \
-u http://localhost:8080/rest/api/latest \
-p PROJ_1
Or standalone with:
npx bitbucket-server-utils-cli \
-at asd...asd \
-u http://localhost:8080/rest/api/latest \
-p PROJ_1
Gather state and store it in a file. This allows other features to quickly have access to the state. You may, for example, want to have this state file versioned in a Git repository to have access to it in CI pipelines.
npx bitbucket-server-utils-cli \
--gather-state \
--url http://localhost:8080/rest/api/latest \
--access-token asd...asd \
--projects PROJ_1 \
--state-file /tmp/some-file.json
Format a string by rendering a Handlebars-template with the state as context.
template=$(cat <<-END
{{#each pullRequests}}
<p>
<b>Last updated:</b> <i>{{lastUpdated}}</i>
</p>
{{/each}}
END
)
renderedString=$(npx bitbucket-server-utils-cli \
--format-string \
--state-file /tmp/some-file.json \
--template "$template")
echo "The rendered string is: $renderedString"
Or get the template from a file with --template "$(</tmp/template.hbs)"
.
Now the $renderedString
can perhaps be used as a comment, or maby it is rendered HTML that you want to write to a file.
Comment a pull-request:
npx bitbucket-server-utils-cli \
--post-pull-request-comment "this is the comment" \
--url http://localhost:8080/rest/api/latest \
--access-token asd...asd \
--projects PROJ_1 \
--repository-slug repo_1 \
--pull-request 461 \
--severity BLOCKER \
--comment-key somethingunique
Delete comment in pull-request:
npx bitbucket-server-utils-cli \
--delete-pull-request-comment \
--url http://localhost:8080/rest/api/latest \
--access-token asd...asd \
--projects PROJ_1 \
--repository-slug repo_1 \
--pull-request 461 \
--pull-request-comment-id 999
Delete any comments in pull-request if they contain the comment key:
npx bitbucket-server-utils-cli \
--delete-pull-request-comment \
--url http://localhost:8080/rest/api/latest \
--access-token asd...asd \
--projects PROJ_1 \
--repository-slug repo_1 \
--pull-request 461 \
--comment-key somethingunique
A comment with specific message to authors who has other pull-requests to review. The context contains the author and the pull-requests.
template=$(cat <<-END
You, **{{authorPullRequest.author}}**, have pull-requests that are waiting for your feedback:
{{#each pullRequests}}
- [{{title}}](http://bitbucket-server/projects/{{repository.projectSlug}}/repos/{{repository.repoSlug}}/pull-requests/{{id}}/)
{{/each}}
END
)
npx bitbucket-server-utils-cli \
--post-pull-request-comment-if-open-pull-requests \
--pull-request-title-filter ^\(?\!WIP:\).*
--url http://localhost:8080/rest/api/latest \
--access-token asd...asd \
--state-file /tmp/some-file.json \
--severity BLOCKER \
--ignore-authors-slug optional,list,of,slugs,to,ignore \
--template "$template"
Options:
-at, --access-token <token> Bitbucket Server access token
-u, --username <username> Bitbucket Server username
-p, --password <password> Bitbucket Server password
-u, --url <url> Bitbucket Server to use for REST integration
(https://bitbucket-server/rest/api/latest)
-p, --projects <projects> Bitbucket Server projects. Example: PROJ_1,PROJ_2,PROJ_3
-rs, --repository-slug <rs>
-prid, --pull-request <prid>
-prtf, --pull-request-title-filter <id> Only include pull requests with title matching this regexp. (default: ".*")
-prcid, --pull-request-comment-id <id>
-prcv, --pull-request-comment-version <version>
-sf, --state-file <filename> File to read, and write, state to.
-t, --template <string> String containing Handlebars template.
-sev, --severity <rs> BLOCKER or NORMAL (default: "NORMAL")
-ck, --comment-key <rs> Some string that identifies the comment. Will ensure same comment is not
re-posted if unchanged and replaced if changed.
--log-level <level> Log level DEBUG, INFO or ERROR (default: "INFO")
-s, --sleep-time <milliseconds> Milliseconds to sleep between HTTP requests. (default: "300")
-dr, --dry-run Dry run, no POST/PUT/DELETE requests. (default: false)
-ias, --ignore-authors-slug <authors> Ignore authors by slug. Example: abc,def,fgh (default: [])
-gs, --gather-state Gather state from Bitbucket Server and store it in a file.
-fc, --format-string Format a string by rendering a Handlebars-template with the state as
context.
-pprc, --post-pull-request-comment <comment> Post a pull-request comment
-pprciopr, --post-pull-request-comment-if-open-pull-requests Post pull-request comment if author has open pull-requests to review
-dprc, --delete-pull-request-comment Delete pull-request comment with given ID
-h, --help display help for command
FAQs
[](https://www.npmjs.com/package/bitbucket-server-utils-cli)
We found that bitbucket-server-utils-cli demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Crates.io adds Trusted Publishing support, enabling secure GitHub Actions-based crate releases without long-lived API tokens.
Research
/Security News
Undocumented protestware found in 28 npm packages disrupts UI for Russian-language users visiting Russian and Belarusian domains.
Research
/Security News
North Korean threat actors deploy 67 malicious npm packages using the newly discovered XORIndex malware loader.