I have managed to set up some custom checks on Bitbucket server and they work ok.
However I seemingly need Bitbucket Premium to make them required, but I don't think there is a Premium option for Bitbucket Server. So how do I setup required merge checks for Bitbucket Server?
You've linked to a Bitbucket Cloud document, but you're asking about Bitbucket Server.
You need to have your custom merge checks return RepositoryHookResult.rejected(String summaryMessage, String detailedMessage) (or the equivalent in your language of choice) to Bitbucket Server upon failure. https://developer.atlassian.com/server/bitbucket/tutorials-and-examples/controlling-when-pull-requests-can-be-merged/ has some example code.
Related
I'm new to Bitbucket Server.
Currently, I'm trying to configure a Jenkins job to build my repository, which is located in my personal space of Bitbucket Server (I'm not admin of BitBucket Server).
I followed the video here: https://www.youtube.com/watch?v=0-FugzVYJQU.
Inside Jenkins setting, I have put the URL to my company bitbucket server, personal access token, Credentials as per hint from Video... But the connection still fails.
My question is:
1 - Do I need the admin right of Bitbucket Server to setup these procedures or did I configure something wrong?
2 - If possible, how to get the Bitbucket Server instance when I don't have the
admin right of Bitbucket Server?
Sorry English not my native language.
Thank you for your help :)
Jenkins Setting - Bitbucket Server instances entry
Regarding your question 1,you don't need any admin access to bitbucket server to setup this procedure.If you are cloning from any repository, you need to make sure that the credential you are using, should have at least read access to particular repository.
For your second question, if you are setting up any jenkins job and Bitbucket team is different, you need to ask them for url or IP. Even you dont know ip, bitbucket server URL should be fine to connect with as long you are using correct credentials.
There can be multiple issue like firewall/no connectivity/security rules if jenkins is not able to connect though you are using correct credentials.
1 - Do I need the admin right of Bitbucket Server to set up these
procedures or did I configure something wrong?
You do not need admin rights of Bitbucket Server. You can add your own personal access token(PAT). Make sure your PAT has admin access.
If possible, how to get the Bitbucket Server instance when I don't have the admin right of Bitbucket Server?
You have to configure your Bitbucket instance manually. Its explained from here in the video.
If your repository is in your personal space, make sure while creating a job, the project name is ~<yourusername>. Example ~jsmith. Repository name will be populated using this.
Regards,
Bitbucket Server Developer
Just to quote as an example one can submit a remote-run with some tool like TeamCity (similar to Jenkins) where it will apply delta/patch on what user is trying to commit & produces result whether changes is good from set-of configured checks for that project.
With Github & Jenkins, can such validation be achieved with any plugins out there?, which will avoid breaking a build?
I know with pull-request & status check one can achieve similar end-result. But without commit/push to remote repo of Git - is there a way Jenkins can handle this validation & produce initial result ??
It isn't possible to have GitHub perform checks on data it doesn't have, so if you don't push the data to the remote server, GitHub won't know anything about it and therefore will do nothing.
Jenkins does have a REST API that you could use to do this, provided you equipped each developer with appropriate credentials. However, this is not a common situation and wouldn't be a recommended configuration.
You'd be better off with a script in the repository that users could install as a hook or invoke from a hook that would perform the testing you want. If your CI jobs run a script in your repository, then sharing code between them should be easy.
Note that you shouldn't mandate pre-commit hooks, since they can interfere with advanced users (who may make intentionally incomplete temporary commits) and they can be disabled by users. Any sort of required checks should be done as part of CI, where policy can be enforced appropriately.
I want to move an issue to the deployed stage (transition) when the gitlab pipeline of a merge request has finished. Is that even possible?
My Idea so far:
The pipeline is related to that specific issue by both the branch name (see 1.) of the merge request and also the message of that merge request like so "Finish PV-1234".
I can parse the issue key from the branch name.
I can call a server to run a script making the Jira api call.
If you directly want to close the issu, look into the gitlab jira integration docs - therefore you have to add a description to your MR, to tell the integration to close the issue, as soon as the MR was merged.
If you want more control, write yourself a simple script, that first gets the ids of the available transition (You can get them via /rest/api/3/issue/{issueIdOrKey}/transitions see here) and after that posts the transition you want (You can do that by posting on the same endpoint, as the get command mentioned before see here).
Sad that the jira integration doesn't provide more issue-movement than jsut closing issues...
I am using the GitHub pull request builder plugin in Jenkins to make pull requests on GitHub automatically trigger Jenkins jobs.
I am using GitHub Enterprise and when I try to get the values of environment vars ghprbActualCommitAuthor and ghprbActualCommitAuthorMail, I get incorrect values:
ghprbActualCommitAuthor : GitHub Enterprise
ghprbActualCommitAuthorEmail : noreply#github.***.com
Please help, thanks!
This behavior is seen in GitHub Enterprise when users commit changes directly using the web UI or they have not set their email addresses.
According to GHE support:
This is by design, since the commit is actually done by the GitHub Enterprise instance. This is because we do not impersonate users when creating commits.
You can fix this by ensuring that users make commits only through the Git clients using their own SSH credentials or Personal Access Tokens.
I have a scenario where I'm setting up Jenkins for my app. I have BitBucket set up and firing appropriate webhooks.
I want to start a build whenever a push is made to the repo as well as whenever someone creates/updates a pull request.
I've looked at the BitBucket Plugin. It works good if I have the BitBucket webhook to fire for all pushes.
Then I added the BitBucket Pull request plugin to build on every pull request create/update. So I changed the BitBucket webhook preferences to fire on pushes and PR creates/updates.
Unfortunately, these plugins have conflicting settings, hence they cannot be used at the same time (as per my research, the minute I send custom webhooks from BitBucket, the first one stops working, but the second one works)
Has anyone been able to set this up correctly? Maybe there's a plugin for what I want, but I couldn't find it.
I want to keep writing a proxy in front of Jenkins to manage webhooks the last option, only if there really is nothing I can do.
Thanks for the help!