How to change "default" Jenkins build status label on GitHub? - jenkins

What do I have:
Jenkins job (Freestyle Project). Job trigger is GitHub Pull Request Builder
GitHub repository
Webhook to trigger the Jenkins job
What do I want: change "default" label from the screenshot below to something more specific, lets say, "Codestyle"
, so the text will be "Codestyle - Build finished."
What have I tried: adding GitHub commit status
It resulted in two build statuses:

Found a workaround (reference):
GitHub Pull Request Builder -> Application Setup:
Job -> Build Triggers -> Trigger Setup
Result:
To keep build statuses, I removed --none-- from "Commit Status Build Triggered" and "Commit Status Build Started" fields.

Build triggers ==> Trigger Setup ==> Commit Status Context ==> Here specify the name and it will appear on the github.

Related

How to force circle ci build on master branches if commit message contains [ci skip]?

The build is skipped when a pr that contains [ci skip] in the squashed commit, gets merged into master.
Is there a way in CircleCI to force the build to run on master? Can we ignore [ci skip] for branches?
Or do I need to ensure that upon merging I strip out [ci skip]?
The string [ci skip] will need to be removed from the commit message in order for the merge to master to build.
Simply navigate to the project's page in CircleCI and select which branch you wish to trigger automation for with the drop-down menu. Then click "Trigger Pipeline".
There are a few other ways a [ci skip] tag can be ignored:
The build is associated with a forked PR
The build is associated with a scheduled build
The build is generated from the "Trigger a new pipeline" API endpoint
The build is triggered via a tag
You include it at the end of a commit body that has more than 247 characters
Sources:
https://support.circleci.com/hc/en-us/articles/360048785251-Why-Is-ci-skip-or-skip-ci-Not-Working-
https://circleci.com/docs/skip-build/

Bitbucket hook build from branch does not work for Jenkins

I have Jenkins with a job for SonarQube analysis, with the following value:
GIT SSH URL - set correctly
Branch Specifier - "**"
In Bitbucket, I have given the following value:
Jenkins URL - http://101.101.101.101:8080/Jenkins
Skip SSL Certificate - Enabled
Omit SHA1 Hash Code - Unchecked
Omit Branch Name - Unchecked
Omit the Trigger Build Button - Unchecked
Advanced Config:
Committers to Ignore - Blank
Branch Options - Build All selected and Blank field
I want Bitbucket to trigger Jenkins only if code is merged (from a pull request) to particular branch.
I tried the following settings in Bitbucket:
Branch Options - Build From selected and "release/Integeration" in the field
Still changes to every branch is triggered.
I tried this in Bitbucket:
Branch Options - Build From selected and "ref/heads/release/Integeration" in the field
Now nothing gets triggered.
Assuming you use HOOK from Bitbucket with the plugin Parameterized Builds for Jenkins and assuming you set a job using that plugin in Bitbucket. If so, did you define the pull request (PR) trigger only?

Jenkins with parameterized build

I am configuring a post commit hook and would like to be able to trigger a build on the branch that has been committed.
So far i have set up the post-commit hook file
curl http://jenkins.local:8080/git/notifyCommit?url=GITHUB_URL/REPO_NAME.git
Within Jenkins i have set
This build is parameterized
**String Paramenter**
Name: branch
Branches to build: $branch
How can i get jenkins to build the branch that has just been committed?
See http://<Your Jenkins>/job/<Your job's name>/api/:
Perform a build
If the build has parameters, post to this URL [http://<Your Jenkins>/job/<Your job's name>/buildWithParameters] and provide the parameters as form data.

Jenkins gerrit trigger not fetching my change while building

I have configured jenkins with gerrit trigger plugin to validate every commit we push to gerrit.
I am expecting this trigger to include my latest change with original repo and make a build.
But, it is cloning only repo project and compiling without my change.
Below is my configuration settings for gerrit trigger in jenkins.
Refspec: $GERRIT_REFSPEC
Branches to build: $GERRIT_BRANCH
Build trigger: Gerrit event
Trigger on: patch set created
Gerrit project: added project and branch
Below is the build output message
Triggered by Gerrit: http://ci-test1/22
Building on master in workspace /var/lib/jenkins/jobs/Build_Adserver_4.7/workspace
Checkout:workspace / /var/lib/jenkins/jobs/Build_Adserver_4.7/workspace - hudson.remoting.LocalChannel#733aee56
Using strategy: Default
Last Built Revision: Revision 701a75ef38aa191ac1b806c48e6b3451671888f6 (ads/4.7)
Fetching changes from 1 remote Git repository
Fetching upstream changes from abc
Commencing build of Revision 701a75ef38aa191ac1b806c48e6b3451671888f6 (ads/4.7)
Checking out Revision 701a75ef38aa191ac1b806c48e6b3451671888f6 (ads/4.7)
[workspace] $ /bin/sh -xe /tmp/hudson1375188638196718521.sh
+ echo 'Started Build'
Started Build
+ echo ..................
..................
+ echo 'Build Finished'
Build Finished
Finished: SUCCESS
Here 701a75ef38aa191ac1b806c48e6b3451671888f6 is HEAD of repo branch and 8cbda558adcad4fb7eb714e0b3fb98a6fbf5811c is the SHA-id of my latest change trigged the build.
I verified from jenkins workspace also, it doesn't include my change.
sorry if I am missing any information to mention. Please let me know
please help me if I am missing anything here.
Using Jenkins 1.532.2 Git Client Plugin 1.6.2 Git Plugin 2.0.1 Git Trigger 2.11.0
Here are the steps for configuring the Gerrit Trigger (from memory, hopefully all works fine):
Install the plugin(s) "Gerrit Trigger", "Git Plugin" and "Git Client Plugin"
In the main jenkins config (HOME->Manage Jenkins), click on Gerrit Trigger.
Create the server and configure it. Use "Test Connection" to be sure it works.
At the end, under "Control" press "start" (No idea what that does or if it's actually needed, but I did that).
Go to your project's config (MYPROJECT->Configure)
Check "Gerrit event" under "Build Triggers"
In the newly added menu, select your server, your triggers, etc.
For Gerrit Project I used "Plain" with "MYPROJECT" as pattern
For Branch, I used "Path" and "**" as pattern (builds all branches)
Under "Source Code Management" (up from triggers in my UI), click on "Git"
Set the Repository URL, here $USER matches for me, but otherwise write the correct user $GERRIT_SCHEME://$USER#$GERRIT_HOST:$GERRIT_PORT/$GERRIT_PROJECT
Specify a branch: $GERRIT_BRANCH
Under "Repositories" on the right, click Advanced, for "Refspec" enter $GERRIT_REFSPEC
Click Add right below, and select "Strategy for choosing what to build"
Select "Gerrit Trigger"
Not very intuitive but it should work. I suggest making sure the correct SHA1 Ids are being built.
If run into Error stderr: fatal: Couldn't find remote ref $GERRIT_REFSPEC
You have to change the Choosing Strategy to Gerrit Trigger
Go to the configuration page of your job and then click on the 2nd Advanced button under the git section. Almost at the bottom there is a Choosing Strategy that you will need to change to Gerrit Trigger
This will cause Git to fetch the correct version for your build
Fixing small issues in Lewis answer, change the values to the following to ensure the latest SHA1 is built.
branch: $GERRIT_REFSPEC
REFSPEC: $GERRIT_REFSPEC:$GERRIT_REFSPEC
I am using Jenkins 2.15 and faced the Issue and got resolved with following settings.
In Git Advances add Refspec : $GERRIT_REFSPEC
Branches to build : $GERRIT_BRANCH.
In Addititional behaviors section select Strategy for choosing what to build and select gerrit Trigger.

Make jenkins auto build one a day but build only when there are source code changed

I have problem in configure jenkins to auto build and deploy java project. I want to build and deploy once a day. However this build only there are changes during the day. IF there is no changes, I don't want jenkins to auto build and deploy.
Note: that I used gitlab as source code management.
Can you help me with this configuration.?
Firstly, you should configure the Git SCM section at the top of the job config page to point to your GitLab repository.
Then you can use the built-in "Poll SCM" build trigger — this will periodically check whether your source code repository has changed — and if it has, a build of this job will be started.
If the repository has not changed since the last build, then no build will be started.
You can configure this trigger — whether using a cron-like syntax, or a shortcut like #daily or #midnight — so that Jenkins only checks the source repository once a day.
Additionally, you should make sure that the "ignore post-commit hooks" option is enabled. If you're using webhooks from your Git repository to start Jenkins jobs whenever a commit occurs, this option prevents your once-per-day job from being triggered for every Git commit.
Here's the detail document: "Jenkins CI integration"
http://doc.gitlab.com/ee/integration/jenkins.html
Update to match your comment.
You don't want to trigger the Jenkins build via webhook. It's ok.
You want to check the code change 1 time a day.
Example on Linux, build at 6:00 AM if there's any code change.
Install
https://wiki.jenkins-ci.org/display/JENKINS/PostBuildScript+Plugin
https://wiki.jenkins-ci.org/display/JENKINS/Text-finder+Plugin
Build Triggers
Build periodically: 0 6 * * *
Execute shell
Like this
SINCE=`curl http://192.168.0.1:8080/job/MyJava/lastStableBuild/buildTimestamp?format=dd-MMM-yyyy`
cd /opt/code/myjava/
git log --pretty="%h - %s" --author=gitster --since=$SINCE --before=$SINCE --no-merges -- t/
Post Build actions
Post build task
Log text: commit
Operation: AND
Script: Your script to build your Java
Jenkins text finder
Also search the console output
Regular expression: Could not match
Unstable if found

Resources