Jenkins + Github Pull Request builder display name - github

For our project we use GitHub. We have TravicCI enabled (as this was required for our project to use). Besides that, we've also got a full instance of Jenkins running with the pull request builder.
Now this all works fine, and in the overview of a pull request this looks like this:
Now as you can see travis is displayed nicely with a name. The Jenkins setup is however shown as 'default'. I'd like to change this to something else, however I can not find anything anywhere (github, jenkins, plugin settings) on how/where to change this. How do I change this?

You can change this in the job.
Your Job > Configure > Build Triggers > Trigger Setup > Commit Status Context
Enter something in this field to override "default".

In the GHPRB ver 1.33.0, the option for changing the name of the check for GitHub PR is within the job configuration:
Your Job > Configure > Build Environment > Set GitHub commit status with custom context and message (Must configure upstream job using GHPRB trigger) > Commit Status Context

I might be late to this answer, but my suggestion is to create another user as a 'bot' account to connect with GitHub from your Jenkins server instead of using your main admin account. This adds another security layer to the connection. I wrote a bit about it here

Related

GitHub webhook repo is unable to trigger jenkins pipeline

Our Company used to self-host GitLab for source-code management and configured webhook on gitlab to trigger all the project pipelines on jenkins. Initially, the gitlab url was 'https://git.fulcrumdigital.com' and later for an upgraded version, they changed url to 'https://autobuild.fulcrumdigital.com'
Recently, we migrated to 'github.com' and created an organization. The source codes for various projects are found under this organization, which is private. Now, when I try to configure webhooks for these projects, I see that they deliver as intended to jenkins, but jenkins doesn't trigger the respective project's build. Instead, it gives out a message as shown below.
jenkins-github webhook error
I don't find any info regarding this webhook on global configuration page.
Here is a snapshot of jenkins logs
jenkins logs
I don't face this webhook issue for newly created pipeline-projects on jenkins. I face this issue for older pipeline-projects that already had their webhook configured earlier for gitlab.
Help me to resolve this issue and make jenkins trigger build from github webhook for older pipeline-projects.
Did you try force regenerating the webhooks?
Go to Manage Jenkins > Configure System > GitHub plugin > Advance > Re-registers hooks for all jobs.
I had this problem myself. The first thing you want to do is go to Manage Jenkins -> Configure System scroll down to the GitHub section and click on "Advanced". You will see this:
It's important to have access to your Jenkins log (I'm running Jenkins with Docker). When I clicked on Re-register hooks for all jobs, I got the following error:
In my case, the error mentioned something with my access token. So, I checked my Github personal access token and it turned out, I need to turn on Read and Write for Webhook:
Now, go back to Jenkins and click on Re-register hooks for all jobs again, and on the next push, the build was automatically triggered.

Unable to select "SonarCloud/Quality Gate" in "Require approval from additional services" in branch policies

According to the tutorial written on the sonarcloud blog (https://blog.sonarsource.com/integrate-sonarcloud-with-vsts-to-boost-code-quality) and the Azure DevOps lab (https://www.azuredevopslabs.com/labs/vstsextend/sonarcloud/) I should be able to use the outcome of the analysis as a qualitygate for my pullrequest.
Unfortunatly this option does not appear when adding a new status policy.
The code has been analysed in the build and in the buildsummary you can see the outcome from sonarcloud.
The last thing I need to do is add it as an approval pull-request requirement.
After several attempts, changes and other setting tweaks i'd managed to get this operational. I think the problem was solved by creating a new personal access token with only the code read/write option selected.
Now the sonarcloud decoration works (providing comments for codesmells) and the status policy is selectable in the branch security policy settings.
If SonarQube is updating each time you run a build, but when you try to add a PR Status Check via AzDO you cannot see the 'SonarQube/quality gate' option appear in the dropdown list you must then enable 'PR Decoration'.
As a SQ Admin, go-to General Settings -> PR Decoration -> select the organisation URL and add the AzDO project name and repository name.

VSTS\Azure-DevOps: Enabling Continuous Integration on pipeline with source from Bitbucket fails with error

Regards,
Your help will be appreciated.
I have created a pipeline in VSTS\Azure-DevOps. It gets its sources from a repository in Bitbucket. Queueing a build works fine. It builds and the tests succeed.
Now I want a build to run on every commit to the repository on Bitbucket. However, when I edit the pipeline and in the Triggers tab enable 'Continuous Integration' and click 'Save' I get the following error:
Unable to configure a service on the selected Bitbucket repository. Bitbucket returned the error 'Forbidden: '.
I am confused that I get 'Forbidden', while getting the source-code already works.
What is it that I am doing wrong? Is there something I must configure in VSTS\Azure-DevOps or in Bitbucket?
Answering my own question:
It appeared that in Bitbucket I only had the rights of 'Writer' for the Repository. When we changed it to 'Administrator' enabling Continuous Integration worked and we verified that committing a code change triggered the build.
Good news / bad news.
It looks like - for now - you can configure a pipeline without being a BitBucket admin on the repo... but not using the templates.
So you can build an empty pipeline based on a BitBucket repo (no admin access), and manually add each of the tasks.
Based on further tests: what you cannot do is set the Continuous Integration trigger, because that requires admin access to set up the webhooks
I know, this is not what you want... but at least there is a way to end up with a working pipeline.
Regards,
Jose

Github Pull Request is not triggering TeamCity

My TeamCity CI has the plugin GitHub Commit Hooks provided by Jetbrains to detect new pull requests and trigger a run. I've installed this plugin and configured it clicking here:
After that, the web hook is created on GitHub but the address is 0000:8111 which is wrong. So I change to the correct DNS and redeliver the request.
It seems to work, the server returns 202 with the message Scheduled checking for changes for 2 VCS roots. (Server time: 20180615T122359.142+0100) but the trigger is not working.
After a while another problem happens, the server starts rejecting the requests and GitHub returns this:
No stored auth data (secret key) found for public key "72WE45221-19fe-433b-9265-66b2168EW6c". Seems hook created not by this TeamCity server. Reinstall hook via TeamCity UI.
Environment:
TeamCity version: 2017.2.4 (build 51228)
GitHub Commit Hooks version: 62
What I can do to solve this issue? Is there any issue with my DNS?
EDIT 1:
Now I am able to trigger the build by commits and solved the secret key issue. But pull requests are not triggering the CI.
To solve the secret key issue, you need to change the Server URL on Global Settings.
A bit of a workaround, but have you tried using a VCS trigger to detect and build pull requests rather than a commit hook? This works the same as any other VCS check in trigger, so if your current configuration is already detecting VCS changes from Github it should be more straightforward to setup.
Pull requests on Github are automatically referenced using the following pattern +:refs/pull/*/head so with a VCS branch specification you can have a TeamCity build project that's dedicated to building pull requests.
See https://blog.jetbrains.com/teamcity/2013/02/automatically-building-pull-requests-from-github-with-teamcity/
I had a similar issue; the solution is to change the TC installation's settings so it's aware of its correct URL, and then re-adding the webhook through the plugin. The setting in question is Administration > Server Administration > Global Settings > Server Url:

how to setup remote host for jenkins parameterized remote trigger plugin

How do you setup the remote host field for Jenkins Parameterized Remote Trigger Plugin? The documentation doesn't seem clear to me, and this explanatory blog post has some Jenkins UI features that I can't locate.
This article suggests going to Manage Jenkins > Configure Credentials to add a Domain, but when I go there I see no "Add Domain" button:
The plugin wiki shows screenshots of a section on a page labelled "Parameterized Remote Trigger Configuration". How do I view this section in Jenkins, where is it? I thought it might be in Manage Jenkins > Manage Plugins, but there is no "Manage" or "Configure" button there:
How do I add a "Host" to my Parameterized Remote Trigger Plugin so that I can use it in a Jenkins job?
Update: The official Parameterized Remote Plugin has gone stale and may not fully work. sap-production appears to be maintaining a much more up-to-date version here. You can install it on your instance by cloning the repo then running mvn package. Then install the ./target/Parameterized-Remote-Trigger.hpi file using Manage Jenkins > Manage Plugins > Advanced (tab) > Upload Plugin
It appears that the Jenkins UI has changed over time. Here is how it works now.
Add The Domain
On the left sidebar of the main Jenkins UI, click Credentials > System > Add domain
Name the domain whatever you like, then click Add > Hostname
Fill in the IP or hostname of the remote Jenkins instance in "Includes"
Set Up Credentials
The previous step leaves you on a page with an "Add Credentials" button. Click that. If you can't find it, then you can locate it from the main view via: Credentials > System > Your Domain
If not already selected, then select "Username with password". Choose a scope.
Fill in all the fields as shown. I personally recommend creating a new user on the remote Jenkins and generating an API token and using that here, but you could also just generate an API token for your own user. Click OK.
Configure Parameterized Remote Trigger Plugin
From the main Jenkins page click Manage Jenkins > Configure System, then scroll down to the Parameterized Remote Trigger Configuration section and click Add.
Fill out at least the Authentication and Remote address and port properties, then click Save.
Add Build Step In Job
Open an existing Jenkins job or create a new one, scroll down to the Build section, and add the build step Trigger a remote parameterized job:
Select your host, and fill the rest of the values in.
This is well documented on the plugin's wiki page. See the "System configuration option" section. If you're having trouble with one of the fields specifically, please add more detail to your question.