Date: Fri, 29 Mar 2024 14:25:50 +0000 (UTC) Message-ID: <578224101.3.1711722350936@af252f78c3b5> Subject: Exported From Confluence MIME-Version: 1.0 Content-Type: multipart/related; boundary="----=_Part_2_617764481.1711722350936" ------=_Part_2_617764481.1711722350936 Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: quoted-printable Content-Location: file:///C:/exported.html
This page explains how to integrate Jenkins builds into a GitHub workflo= w. In particular:
a Jenkins build gets triggered by any PR or any update to any PR or when= any PR are merged
the outcome of the Jenkins build outcome is displayed on GitHub
a Jenkins build failure disables the GitHub merge button
start:
an existing repo
a Jenkins machine
end:
one more job on Jenkins
GitHub repo linked
Log into you GitHub account, that must be an account with admin privileg= es to the repo
Go to =E2=80=9CSettings=E2=80=9D of your GitHub account, then go to =E2= =80=9CDeveloper settings->Personal access tokens=E2=80=9C
Click =E2=80=9CGenerate new token=E2=80=9C and Select the following scop= es:
repo
repo:status
repos_deployment
public_repo
admin:repo_hook
write:repo_hook
read:repo_hook
Give a name of the token in the =E2=80=9CNote=E2=80=9C field and Click = =E2=80=9CGenerate token=E2=80=9C
The token will show up under the =E2=80=9CPersonal access tokens=E2=80= =9C page, click =E2=80=9Ccopy=E2=80=9D button to copy the token to somewher= e temporal. When it=E2=80=99s set in the target application, remove delete = the token from anywhere else.
Log into your GitHub account, that must be an account with admin p= rivileges to the repo
In the =E2=80=9CSettings=E2=80=9D tab of the repo, click on =E2=80=9CWeb= hooks=E2=80=9D
Click =E2=80=9CAdd webhook=E2=80=9D, under =E2=80=9CWebhooks / Manage we= bhook=E2=80=9D
Put <https://openwsn-builder.paris.i= nria.fr/github-webhook/> (=E2=80=9Cgithub-webhook=E2=80=9C is a magi= c string identifying the GitHub plugin) in the Payload URL
Select =E2=80=9CLet me select individual events=E2=80=9C and check the = =E2=80=9CPull Request=E2=80=9D, =E2=80=9CPush=E2=80=9D and =E2=80=9CReposit= ories=E2=80=9D as the event to trigger the build
Click =E2=80=9CUpdate webhook=E2=80=9D to create the webhook
You should see the payload URL is the =E2=80=9CWebhooks=E2=80=9D list, w= ith a green check mark.
install plugin
Log into builder.openwsn.org
Go to =E2=80=9CManage Jenkins =E2=86=92 Manage Plugins=E2=80=9D, under A= vailable tab, search for =E2=80=9DGitHub Branch Source=E2=80=9D, mark the c= heckbox of the plugin
search for =E2=80=9DSCM Filter Branch PR=E2=80=9D and mark the checkbox = of the plugin
click =E2=80=9CInstall without restart=E2=80=9D to install
Go to builder.openwsn.org/restart and click =E2=80=9CYes=E2=80= =9D to restart Jenkins
create new job
Click =E2=80=9CNew Item=E2=80=9D to create a job, give a name of the job= , select =E2=80=9CGitHub Organization=E2=80=9D and then click =E2=80=9COK= =E2=80=9D to get in the job configure page
In the =E2=80=9CProjects=E2=80=9D Tab, in the =E2=80=9CGitHub Organizati= on=E2=80=9C section, Click =E2=80=9CAdd=E2=80=9D next to =E2=80=9CCredentia= ls=E2=80=9C
Select the option with the job name
In =E2=80=9CKind=E2=80=9C text box, select =E2=80=9CUsername with passwo= rd=E2=80=9C
In =E2=80=9CUsername=E2=80=9C text box, write down the GitHub account na= me
In =E2=80=9CPassword=E2=80=9C text box, write down the token created in = Create= -token-on-GitHub
Click =E2=80=9CAdd=E2=80=9C to return to the =E2=80=9Cconfigure=E2=80=9C= page
In the drop box of =E2=80=9CCredentials=E2=80=9C, select =E2=80=9C[accou= tname]/**********=E2=80=9C
In the =E2=80=9COwner=E2=80=9C text box, type down the GitHub Account/Or= ganization name. This allows the Job to read the related branches/PR associ= ated with the account/organization
In the =E2=80=9CBehaviors=E2=80=9C part, click the =E2=80=9CAdd=E2=80=9C= button at bottom to add the following configurations:
Repositories
=E2=80=9CFilter by name (with wildcards)=E2=80=9D, using =E2=80=9CInclud= e=E2=80=9C/=E2=80=9DExclude=E2=80=9D to filter the repository you want the = job to hook
Within repository
=E2=80=9CDiscover branches=E2=80=9C, select =E2=80=9CStrategy=E2=80=9C a= s =E2=80=9CExclude branches that are also filed as PRs=E2=80=9C
=E2=80=9CDiscover pull requests from forks=E2=80=9C, select =E2=80=9CStr= ategy=E2=80=9C as =E2=80=9CMerging the pull request with current target=E2= =80=9C, select =E2=80=9CTrust=E2=80=9C as =E2=80=9CEveryone=E2=80=9C
=E2=80=9CFilter by name including PRs destined for this branch (with wil= dcards)=E2=80=9C, type down =E2=80=9Cmaster=E2=80=9C in =E2=80=9C Branch In= clude=E2=80=9D text box
In the =E2=80=9CProject Recongnizers=E2=80=9C part, write down the Scrip= t path to the =E2=80=9CJenkinsfile=E2=80=9C, which contains the Pipeline sc= ript that the Job should run
In =E2=80=9CScan organization triggers=E2=80=9C, uncheck the =E2=80=9CPe= riodically if not otherwise run=E2=80=9C
In =E2=80=9CChild Scan Triggers=E2=80=9C, uncheck the =E2=80=9CPeriodica= lly if not otherwise run=E2=80=9C
Click =E2=80=9CApply=E2=80=9C then =E2=80=9CSave=E2=80=9D to complete th= e settings.Create-token-on-GitHub
The Github Organization job uses Pipeline as the build action to run.
The Pipeline script lives in the repository with name =E2=80=9Cjenkinsfi= le=E2=80=9D. Following is an example what the Pipeline script looks like.= p>
pipelin= e { agent { label 'windows && a102' } stages { stage('Test') { steps { bat 'pytest --junitxml=3Dreport.xml' } } } post { always { junit 'report.xml' } } }
repo: https://github.com/changtengfei= /demo_github_jenkins_repo
Jenkins job: https://openwsn-builder.pari= s.inria.fr/job/testdemo/
GitHub Status images:
When Jenkins build passes, GitHub shows
When Jenkins build fails, GitHub shows