Before you do anything make sure you have installed the plugins for the particular git repo you are working.
It's not as simple as the Bitbucket integration.
Go to Jenkins/configuration then scroll down to GitHub
Make sure you select Git in the Source Control Management section
Make sure you install the Bitbucket plugin |
In any project make sure the following are set
Simply go to your Settings / Webhooks and add a webhook - <the URL to Jenkins>/bitbucket-hook/
Make sure the url ends with /.
Goto Settings / Integrations & Services / Add services / Jenkins (Github plugin)
Specify the webhook
The save/update the service
Script to build in a pipeline
node { // Mark the code checkout 'stage'.... stage 'Checkout' // Get some code from a GitHub repository withCredentials([usernamePassword(credentialsId: 'b0dab3e6-22ae-4db4-a7fd-5dd417a64a6c', passwordVariable: 'myLord43in43@ccan', usernameVariable: 'swright@celestial.co.uk')]) { //git url: 'https://bitbucket.org/stream2stream/loginmanager/' checkout([$class: 'GitSCM', branches: [[name: '*/master']], doGenerateSubmoduleConfigurations: false, extensions: [], submoduleCfg: [], userRemoteConfigs: [[credentialsId: 'b0dab3e6-22ae-4db4-a7fd-5dd417a64a6c', url: 'https://stream2stream@bitbucket.org/stream2stream/loginmanager.git']]]) // Get the maven tool. // ** NOTE: This 'M3' maven tool must be configured // ** in the global configuration. //def mvnHome = tool 'M3' // Mark the code build 'stage'.... stage 'Build' // Run the maven build //sh "${mvnhome}/bin/mvn clean install" sh "/bin/mvn clean package" sh 'cp target/LoginManager-1.0.war target/LoginManager.war' sh 'mv target/LoginManager.war /var/jenkins_home/workspace/"Deploy Login Manager"/' } } |