perfecting your development tools: updates to the helix plugin for jenkins
TRANSCRIPT
![Page 1: Perfecting Your Development Tools: Updates to the Helix Plugin for Jenkins](https://reader031.vdocuments.net/reader031/viewer/2022013104/58895ad41a28abef658b5877/html5/thumbnails/1.jpg)
Perforce Plugin for JenkinsAn introduction to the ‘P4’ Plugin and update on the latest features.
Paul Allen – Perforce Software
![Page 2: Perfecting Your Development Tools: Updates to the Helix Plugin for Jenkins](https://reader031.vdocuments.net/reader031/viewer/2022013104/58895ad41a28abef658b5877/html5/thumbnails/2.jpg)
© Perforce Software Inc. All Rights Reserved.
Paul AllenSenior Integration EngineerPerforce
![Page 3: Perfecting Your Development Tools: Updates to the Helix Plugin for Jenkins](https://reader031.vdocuments.net/reader031/viewer/2022013104/58895ad41a28abef658b5877/html5/thumbnails/3.jpg)
© Perforce Software Inc. All Rights Reserved.
Introduction
◦ The Perfect Monorepo◦ P4 plugin◦ Credentials◦ Workspace management◦ Perforce Operations◦ Polling, triggers and reviews◦ P4 Groovy
![Page 4: Perfecting Your Development Tools: Updates to the Helix Plugin for Jenkins](https://reader031.vdocuments.net/reader031/viewer/2022013104/58895ad41a28abef658b5877/html5/thumbnails/4.jpg)
The Perfect MonorepoWhat is a Monorepo?
![Page 5: Perfecting Your Development Tools: Updates to the Helix Plugin for Jenkins](https://reader031.vdocuments.net/reader031/viewer/2022013104/58895ad41a28abef658b5877/html5/thumbnails/5.jpg)
© Perforce Software Inc. All Rights Reserved.
One Repo to rule them all, One Repo to find them, One Repo to bring them all and in the server bind them.
One Repo
![Page 6: Perfecting Your Development Tools: Updates to the Helix Plugin for Jenkins](https://reader031.vdocuments.net/reader031/viewer/2022013104/58895ad41a28abef658b5877/html5/thumbnails/6.jpg)
© Perforce Software Inc. All Rights Reserved.
One Store
Store all sources, projects and sub projects; even artifacts, tooling, docs and test reports...
![Page 7: Perfecting Your Development Tools: Updates to the Helix Plugin for Jenkins](https://reader031.vdocuments.net/reader031/viewer/2022013104/58895ad41a28abef658b5877/html5/thumbnails/7.jpg)
© Perforce Software Inc. All Rights Reserved.
One History
Boldly go across source and timeReproduce any source at any point in time
![Page 8: Perfecting Your Development Tools: Updates to the Helix Plugin for Jenkins](https://reader031.vdocuments.net/reader031/viewer/2022013104/58895ad41a28abef658b5877/html5/thumbnails/8.jpg)
© Perforce Software Inc. All Rights Reserved.
Global Access
Any file any where
Fast Global DistributionFine grain protections
![Page 9: Perfecting Your Development Tools: Updates to the Helix Plugin for Jenkins](https://reader031.vdocuments.net/reader031/viewer/2022013104/58895ad41a28abef658b5877/html5/thumbnails/9.jpg)
P4 PluginPerforce plugin support for Jenkins
![Page 10: Perfecting Your Development Tools: Updates to the Helix Plugin for Jenkins](https://reader031.vdocuments.net/reader031/viewer/2022013104/58895ad41a28abef658b5877/html5/thumbnails/10.jpg)
© Perforce Software Inc. All Rights Reserved.
Disambiguation
◦ Community ‘Perforce’ pluginhttps://wiki.jenkins-ci.org/display/JENKINS/Perforce+Plugin
◦ Perforce Supported ‘P4’ pluginhttps://wiki.jenkins-ci.org/display/JENKINS/P4+Plugin
![Page 11: Perfecting Your Development Tools: Updates to the Helix Plugin for Jenkins](https://reader031.vdocuments.net/reader031/viewer/2022013104/58895ad41a28abef658b5877/html5/thumbnails/11.jpg)
© Perforce Software Inc. All Rights Reserved.
The ‘P4’ plugin
◦ WhyAccess the power of Perforce from within Jenkins
◦ P4JavaPure Java solutionNo ‘P4’ executable to install and keep up-to-date.
◦ Latest featuresStreams, sync and clean up options
![Page 12: Perfecting Your Development Tools: Updates to the Helix Plugin for Jenkins](https://reader031.vdocuments.net/reader031/viewer/2022013104/58895ad41a28abef658b5877/html5/thumbnails/12.jpg)
CredentialsConnecting to Perforce…
![Page 13: Perfecting Your Development Tools: Updates to the Helix Plugin for Jenkins](https://reader031.vdocuments.net/reader031/viewer/2022013104/58895ad41a28abef658b5877/html5/thumbnails/13.jpg)
© Perforce Software Inc. All Rights Reserved.
Credentials
◦ Perforce CredentialsShared CredentialsManaged from one locationIndependent from the Job configurationUpdate connection details in one location
◦ Credential Types1. Perforce Password Credential2. Perforce Ticket Credential
![Page 14: Perfecting Your Development Tools: Updates to the Helix Plugin for Jenkins](https://reader031.vdocuments.net/reader031/viewer/2022013104/58895ad41a28abef658b5877/html5/thumbnails/14.jpg)
© Perforce Software Inc. All Rights Reserved.
Credentials
◦ Connection informationUsername/PasswordPerforce address and portworkshop.perforce.com:1666
◦ Password credentialsUsernamePasswordID (useful to reference in the DSL)Description
![Page 15: Perfecting Your Development Tools: Updates to the Helix Plugin for Jenkins](https://reader031.vdocuments.net/reader031/viewer/2022013104/58895ad41a28abef658b5877/html5/thumbnails/15.jpg)
© Perforce Software Inc. All Rights Reserved.
Credentials
◦ Ticket based securityPerforce generated Ticket String$ p4 login –p4E034A8812F81B38229BF8FA62B0FEB1Location of Perforce P4TICKET file/home/pallen/.p4ticket
◦ SSL and TrustCheck the SSL box to add the ssl: part to P4PORTUse p4 trust or click test to get the fingerprint
![Page 16: Perfecting Your Development Tools: Updates to the Helix Plugin for Jenkins](https://reader031.vdocuments.net/reader031/viewer/2022013104/58895ad41a28abef658b5877/html5/thumbnails/16.jpg)
Workspace ManagementJenkins and Perforce Workspaces
![Page 17: Perfecting Your Development Tools: Updates to the Helix Plugin for Jenkins](https://reader031.vdocuments.net/reader031/viewer/2022013104/58895ad41a28abef658b5877/html5/thumbnails/17.jpg)
© Perforce Software Inc. All Rights Reserved.
Workspaces
◦ Jenkins workspaceLocation of files (on the master or slave) for Jenkins to build
◦ Perforce workspaceLocation where Perforce will manage the versioned an non-versioned files
◦ Shared rootRecommend Perforce and Jenkins workspaces share the same rootOne Jenkins workspace to map to one Perforce workspace
![Page 18: Perfecting Your Development Tools: Updates to the Helix Plugin for Jenkins](https://reader031.vdocuments.net/reader031/viewer/2022013104/58895ad41a28abef658b5877/html5/thumbnails/18.jpg)
© Perforce Software Inc. All Rights Reserved.
Workspaces
◦ Workspace ConfigurationStreams WorkspaceManual WorkspaceTemplate WorkspaceStatic Workspace (predefined) Spec Workspace (spec depot or file)
workspace: [$class: 'StreamWorkspaceImpl', charset: 'none', format: 'jenkins-${NODE_NAME}-${JOB_NAME}', pinHost: false, streamName: '//streams/st1-main']
![Page 19: Perfecting Your Development Tools: Updates to the Helix Plugin for Jenkins](https://reader031.vdocuments.net/reader031/viewer/2022013104/58895ad41a28abef658b5877/html5/thumbnails/19.jpg)
Perforce OperationsCheckout, Build and Post Build Steps
![Page 20: Perfecting Your Development Tools: Updates to the Helix Plugin for Jenkins](https://reader031.vdocuments.net/reader031/viewer/2022013104/58895ad41a28abef658b5877/html5/thumbnails/20.jpg)
© Perforce Software Inc. All Rights Reserved.
CD Pipe
◦ SCM Operations
Artifact
SCM
{"id":[{"name":"bob"}]}
CI Build pipeline
package mainimport "fmt”func main() {
@change @label
Label
@review
populate
unsh
elve
label
publish
![Page 21: Perfecting Your Development Tools: Updates to the Helix Plugin for Jenkins](https://reader031.vdocuments.net/reader031/viewer/2022013104/58895ad41a28abef658b5877/html5/thumbnails/21.jpg)
© Perforce Software Inc. All Rights Reserved.
SCM Operations
◦ Populate p4sync / checkoutSynchronize the files in the Workspace prior to build.
◦ Unshelve p4unshelveUnshelve code into the Workspace prior to build.
◦ Publish p4publishSubmit files back into Perforce, post build.
◦ Label p4tagAutomatic label against the populated files in the Workspace, post build.
![Page 22: Perfecting Your Development Tools: Updates to the Helix Plugin for Jenkins](https://reader031.vdocuments.net/reader031/viewer/2022013104/58895ad41a28abef658b5877/html5/thumbnails/22.jpg)
© Perforce Software Inc. All Rights Reserved.
Populate
◦ Auto Cleanup and Syncpopulate:[$class:'AutoCleanImpl',
delete:true, replace:true, modtime:false, quiet:true, pin:''
]
◦ Force Clean and Syncpopulate: [$class: 'ForceCleanImpl',
have:false, pin:'', quiet:true]
![Page 23: Perfecting Your Development Tools: Updates to the Helix Plugin for Jenkins](https://reader031.vdocuments.net/reader031/viewer/2022013104/58895ad41a28abef658b5877/html5/thumbnails/23.jpg)
© Perforce Software Inc. All Rights Reserved.
Unshelve
◦ Unshelve Build StepUnshelve the change as a Build step defined in the JobFiles are unshelved and resolved prior build.
p4unshelve resolve:'at', shelf:'12345'
![Page 24: Perfecting Your Development Tools: Updates to the Helix Plugin for Jenkins](https://reader031.vdocuments.net/reader031/viewer/2022013104/58895ad41a28abef658b5877/html5/thumbnails/24.jpg)
© Perforce Software Inc. All Rights Reserved.
Publish
◦ Shelve or Submit a change◦ Connection & Workspace ◦ Use a narrow view◦ Virtual stream◦ Read/Write access for files
Set Workspace option ALLWRITE or use filetype +w
![Page 25: Perfecting Your Development Tools: Updates to the Helix Plugin for Jenkins](https://reader031.vdocuments.net/reader031/viewer/2022013104/58895ad41a28abef658b5877/html5/thumbnails/25.jpg)
© Perforce Software Inc. All Rights Reserved.
Publish
p4publish credential:'phooey1666', publish: [ $class:'SubmitImpl', delete:false, description:'Build: ${BUILD_TAG}', onlyOnSuccess:false, reopen:false], workspace: [ $class:'StreamWorkspaceImpl', charset:'none', format:'jenkins-${JOB_NAME}-publish', pinHost:false, streamName:'//streams/st1-main']
![Page 26: Perfecting Your Development Tools: Updates to the Helix Plugin for Jenkins](https://reader031.vdocuments.net/reader031/viewer/2022013104/58895ad41a28abef658b5877/html5/thumbnails/26.jpg)
© Perforce Software Inc. All Rights Reserved.
Label
◦ Automatic labelLabel on success optionUses Populate Client’s View
◦ Name & Descriptionp4tag rawLabelName:'${JOB_NAME}-passed',rawLabelDesc:'''Jenkins job: ${JOB_NAME}Jenkins build: ${BUILD_TAG}Jenkins build date: ${BUILD_ID}Jenkins build number: ${BUILD_NUMBER}'''
![Page 27: Perfecting Your Development Tools: Updates to the Helix Plugin for Jenkins](https://reader031.vdocuments.net/reader031/viewer/2022013104/58895ad41a28abef658b5877/html5/thumbnails/27.jpg)
Polling, Triggers and ReviewsStill polling?
![Page 28: Perfecting Your Development Tools: Updates to the Helix Plugin for Jenkins](https://reader031.vdocuments.net/reader031/viewer/2022013104/58895ad41a28abef658b5877/html5/thumbnails/28.jpg)
© Perforce Software Inc. All Rights Reserved.
Polling… if you must
◦ Polling build FiltersExclude changes from Depot pathExclude changes from userExclude changes outside view maskPoll on Master using Latest BuildPolling per Change
◦ Workspace modesWorkspace to check the build - Preview check Only (sync –k)
![Page 29: Perfecting Your Development Tools: Updates to the Helix Plugin for Jenkins](https://reader031.vdocuments.net/reader031/viewer/2022013104/58895ad41a28abef658b5877/html5/thumbnails/29.jpg)
© Perforce Software Inc. All Rights Reserved.
Triggers
◦ Perforce triggered build◦ Subscribe Job (P4 Trigger)
curl --header 'Content-Type: application/json' \ --request POST \ --data "payload={change:200,p4port:\"perforce.com:1666\"}" \ http://jenkins:8080/p4/change
◦ Swarm (P4 Review)Build triggered by Perforce Swarm.Review or Change unshelved into workspace prior to build
![Page 30: Perfecting Your Development Tools: Updates to the Helix Plugin for Jenkins](https://reader031.vdocuments.net/reader031/viewer/2022013104/58895ad41a28abef658b5877/html5/thumbnails/30.jpg)
© Perforce Software Inc. All Rights Reserved.
Swarm
[POST]https://swarm:[email protected]:8443/job/myJob/review/build?change={change}&status={status}&review={review}&pass={pass}&fail={fail}
![Page 31: Perfecting Your Development Tools: Updates to the Helix Plugin for Jenkins](https://reader031.vdocuments.net/reader031/viewer/2022013104/58895ad41a28abef658b5877/html5/thumbnails/31.jpg)
P4 GroovyP4 command access for Groovy
![Page 32: Perfecting Your Development Tools: Updates to the Helix Plugin for Jenkins](https://reader031.vdocuments.net/reader031/viewer/2022013104/58895ad41a28abef658b5877/html5/thumbnails/32.jpg)
© Perforce Software Inc. All Rights Reserved.
P4Groovy
◦ P4Groovy objectCredentialWorkspace
ws = [$class: 'StreamWorkspaceImpl', charset: 'none', format: 'jenkins-${JOB_NAME}', pinHost: false, streamName: '//streams/projAce']
p4 = p4(credential: 'phooey', workspace: ws)
![Page 33: Perfecting Your Development Tools: Updates to the Helix Plugin for Jenkins](https://reader031.vdocuments.net/reader031/viewer/2022013104/58895ad41a28abef658b5877/html5/thumbnails/33.jpg)
© Perforce Software Inc. All Rights Reserved.
P4Groovy Methods
◦ RunRequires: command, arguments (‘,’ separated String)Returns: tagged output (specifically Map<String, Object>[])
p4.run(’changes', '-m5, //...')
◦ Gettersp4.getUserName()p4.getClientName()
![Page 34: Perfecting Your Development Tools: Updates to the Helix Plugin for Jenkins](https://reader031.vdocuments.net/reader031/viewer/2022013104/58895ad41a28abef658b5877/html5/thumbnails/34.jpg)
© Perforce Software Inc. All Rights Reserved.
P4Groovy Methods
◦ FetchRequires: spec type, spec idReturns: a spec as a Map
client = p4.fetch(‘client’, ‘my_ws’)
◦ Save Requires: spec type, the spec as a MapReturns: tagged output (specifically Map<String, Object>[])
p4.save(‘client’, client)
![Page 35: Perfecting Your Development Tools: Updates to the Helix Plugin for Jenkins](https://reader031.vdocuments.net/reader031/viewer/2022013104/58895ad41a28abef658b5877/html5/thumbnails/35.jpg)
© Perforce Software Inc. All Rights Reserved.
Example
◦ Combine Steps with P4GroovyPopulate is made up of several steps not just syncUse P4Groove for custom operations e.g.
node() { ... job = p4.fetch('job', 'job000006') desc = job.get('Description') desc = desc + env.BUILD_URL job.put('Description', desc) p4.save('job', job)}
![Page 36: Perfecting Your Development Tools: Updates to the Helix Plugin for Jenkins](https://reader031.vdocuments.net/reader031/viewer/2022013104/58895ad41a28abef658b5877/html5/thumbnails/36.jpg)
Thanks for Joining us!
![Page 37: Perfecting Your Development Tools: Updates to the Helix Plugin for Jenkins](https://reader031.vdocuments.net/reader031/viewer/2022013104/58895ad41a28abef658b5877/html5/thumbnails/37.jpg)
End