User Tools

Site Tools


projects:bitbucket:pullrequestplugin

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
Last revisionBoth sides next revision
projects:bitbucket:pullrequestplugin [2016/04/17 23:28] mkuciaprojects:bitbucket:pullrequestplugin [2016/04/25 22:02] – [Notes] mkucia
Line 1: Line 1:
-====== Bitbucket Server Pull Request Hook Plugin ====== +====== Bitbucket Server Repository Pull Request Hook Plugin ======
-  * [[Atlassian Marketplace]] +
-  * [[Sources]]+
  
-===== TODOs =====+{{ :projects:bitbucket:repopullrequest-pluginlogo.png?nolink|}} 
 + 
 +  * [[https://marketplace.atlassian.com/plugins/com.maciejkucia.atlasbbplugin.repopullrequest/server/overview|Atlassian Marketplace]] 
 +  * [[https://github.com/MaciejKucia/bitbucket-server-repopullrequest|Sources]] 
 + 
 +===== Planned features =====
   * Internationalization   * Internationalization
   * Support for HTTPs   * Support for HTTPs
-  * Test button in the config 
- 
 ===== Introduction ===== ===== Introduction =====
 The plugin provides the following functionality: The plugin provides the following functionality:
Line 18: Line 19:
   * Per-repository configuration via 'repository hooks' tab   * Per-repository configuration via 'repository hooks' tab
   * Accessible by the repository administrators   * Accessible by the repository administrators
 +  * The following HTTP operations are supported:
 +    * POST
 +    * GET
 +    * PUT
 +    * DELETE
  
 ===== Usage ===== ===== Usage =====
Line 26: Line 32:
 ''${all_keys}'' ''${all_keys}''
  
-[IMAGE]+{{:projects:bitbucket:bb_body_json.png?nolink|}}
  
 ==== Authorization ==== ==== Authorization ====
Line 32: Line 38:
 In such case the field will look like: In such case the field will look like:
  
-[IMAGE]+{{:projects:bitbucket:bb_auth_headers.png?nolink|}}
  
 Please visit [[wp>Basic_access_authentication|wikipedia]] to learn how to construct basic auth header. Please visit [[wp>Basic_access_authentication|wikipedia]] to learn how to construct basic auth header.
Line 40: Line 46:
 It allows using anonymous request + build token (think of API key). It allows using anonymous request + build token (think of API key).
  
-===== Example ===== +===== Example ===== 
-We want to capture the following behaviours+  - Create Jenkins job "Bitbucket Capture" 
-  * Creation of the new Pull Request +    - Add String Parameter ''ALL'' 
-  * Changes to the Pull Request +    - Add Token ''BBBUILD'' in ''Build Triggers'' ''Trigger builds remotely (e.g., from scripts)'' 
-  * New comment+  - Check if the job is working 
 +    - Trigger job manually using your browser's private mode 
 +    - Enter the (appropriate to your setup) URL ''http://localhost:8080/buildByToken/buildWithParameters?token=BBBUILD&job=Bitbucket%20Capture&ALL=Hello'' 
 + 
 +Entering URL will take you to an empty page. Back in Jenkins you should see that the job was triggered and parameter is successfully passed: 
 + 
 +{{:projects:bitbucket:bb_example1_1.png?nolink|}} 
 + 
 + 
 +  - Add more String Parameters to the Jenkins job: 
 +    - ''ACTION'' 
 +    - ''PR_ID'' 
 +    - ''REPO'' 
 +    - ''PROJECT'' 
 +  - Configure Bitbucket Server 
 +    - Ensure that the plugin is installed. 
 +    - Enter any repository Settings, then Hooks 
 +    - Enable ''Pull Request Hook'' 
 +    - Enter URL ''http://localhost:8080/buildByToken/buildWithParameters?token=BBBUILD&job=Bitbucket%20Capture&ALL=${all_keys}&ACTION=${action}&PR_ID=${pr_id}&REPO=${repo}&PROJECT=${project}'' 
 +    - Enable all triggers 
 +    - Save 
 + 
 +{{:projects:bitbucket:bb_example1_4.png?nolink|}} 
 +{{:projects:bitbucket:bb_example1_3.png?nolink|}} 
 +{{:projects:bitbucket:bb_example1_5.png?nolink|}} 
 + 
 +  - Test connection 
 +    - Create pull request 
 +    - Add a comment 
 + 
 +After that you should notice that a new builds were run. Inspect those builds parameters. 
 + 
 +{{:projects:bitbucket:bb_example1_2.png?nolink|}} 
 + 
 +=== Extras === 
 + 
 +Jenkins job ''config.xml'': 
 +<code xml> 
 +<project> 
 +  <actions/> 
 +  <description/> 
 +  <keepDependencies>false</keepDependencies> 
 +  <properties> 
 +    <hudson.model.ParametersDefinitionProperty> 
 +      <parameterDefinitions> 
 +        <hudson.model.StringParameterDefinition> 
 +          <name>ALL</name> 
 +          <description/> 
 +          <defaultValue/> 
 +        </hudson.model.StringParameterDefinition> 
 +      </parameterDefinitions> 
 +    </hudson.model.ParametersDefinitionProperty> 
 +  </properties> 
 +  <scm class="hudson.scm.NullSCM"/> 
 +  <canRoam>true</canRoam> 
 +  <disabled>false</disabled> 
 +  <blockBuildWhenDownstreamBuilding>false</blockBuildWhenDownstreamBuilding> 
 +  <blockBuildWhenUpstreamBuilding>false</blockBuildWhenUpstreamBuilding> 
 +  <authToken>BBBUILD</authToken> 
 +  <triggers/> 
 +  <concurrentBuild>false</concurrentBuild> 
 +  <builders/> 
 +  <publishers/> 
 +  <buildWrappers/> 
 +</project> 
 +</code> 
 + 
 + 
 +===== Displaying Log ===== 
 +There is a button in the configuration dialog that leads to a log. Communications are logged per-repository. 
 +{{:projects:bitbucket:bb_example_viewlogs.png?nolink|}} 
 + 
 +{{:projects:bitbucket:bb_example_weblog.png?nolink&800|}} 
 + 
 +===== Notes ===== 
 +  * Connection time-out is set to 5 seconds 
 +===== Test scenarios =====
  
-Captured event will be propagated to [[https://jenkins.io/|Jenkins]] instance.+==== Configuration ==== 
 +  * Entering incorrect URL 
 +    * https:\\123.com 
 +    * 45434.com 
 +    * http:\\ space .com 
 +  * Entering incorrect header data 
 +    * without colon 
 +    * empty lines
  
-There is only a single URL per repository therefore we will need a relay job to extract necessary variables and call appropriate jobs.+==== Core ==== 
 +  * Enable all notification types and check them one-by one 
 +  * Set all possible variables in body and check if it is valid for all notification types 
 +  * Use basic-auth header
  
-1. Configure Jenkins +==== Weblog ==== 
-  * Add Token ''BBBUILD'' +  * Accessing non-existing log 
-  * Add Parameters+  * Accessing existing log by admin of other project 
 +  * Accessing log with non-configured plugin for given repository 
 +  * Accessing log when non-existing URL is set in config
  
-2. Configure Bitbucket 
-  * Set URL ''localhost'' 
projects/bitbucket/pullrequestplugin.txt · Last modified: 2016/04/25 22:08 by mkucia