I am Abhishek Gautam, 3rd year student from Visvesvaraya National Institute of technology, India, Nagpur. I was a member of ACM Chapter and Google student developer club of my college. I am passionate about automation.

This is a GSoC 2018 project.

This project aims to develop a pull request Job Plugin. Users should be able to configure job type using YAML file placed in root directory of the Git repository being the subject of the pull request. The plugin should interact with various platforms like Bitbucket, Github, Gitlab, etc whenever a pull request is created or updated.

Plugin detects the presence of certain types of reports at conventional locations, and publish them automatically. If the reports are not present at their respective conventional location, the location of the report can be configured in the YAML file.

  • Project administrators will be able to handle pull request builds more easily.

  • Build specifications for pull requests can be written in a concise declarative format.

  • Build reports will be automatically published to Github, Bitbucket, etc.

  • Build status updates will be sent to git servers automatically.

  • Users will not have to deal with pipeline code.

  • If there will be no merge conflicts or build failures, the PR can be merged into target branch.

Please see Phase 1 blog post

Alpha version of the plugin is released. It supports all features of Multi-Branch Pipeline and offers the following features.

Build description is defined via YAML file stored within the SCM repo. This plugin will depend on GitHub plugin, Bitbucket plugin, Gitlab plugin if users will be using respective platforms for their repositories.

  1. Conversion of YAML to Declarative Pipeline: A class YamlToPipeline is written which will load the "Jenkinsfile.yaml" and make use of PipelineSnippetGenerator class to generate Declarative pipeline code.

  2. Reporting of results, only xml report types is supported for now.

  3. Use of Yaml file (Jenkinsfile.yaml) from target branch.

  4. Git Push step: To push the changes of pull request to the target branch. This is implemented using git-plugin, PushCommand is used for this from git-plugin. credentialId, branch name and repository url for interacting with Github, Bitbucket, etc will be taken automatically from "Branch-Source" (Users have to fill this details of branch source in job configuration UI). (You can see How to run the demo)

  5. StepConfigurator: To generate pipeline code for all supported steps in Jenkins. This is using Jenkins configuration-as-code plugin (JCasC plugin) to configure a particular step object and then that step object is passed to Snippetizer.object2Groovy() method to generate the script of that step.

For the phase 1 prototype demonstration, the following yaml file was used. Note that this format is subject to change in the next phases of the project, as we formalise the yaml format definition.

# Docker image agent example
agent: label: my_label customWorkspace: path_to_workspace dockerImage: maven:3-alpine args: -v /tmp:/tmp tools: maven : maven_3.0.1 jdk : jdk8 configuration: # Push PR changes to the target branch if the build succeeds. # default value is false pushPrOnSuccess: false # Trusted user to approve pull requests prApprovers: - username1 - username2 - username3 environment: variables: variable_1: value_1 variable_2: value_2 # Credentials contains only two fields. credentialId must be present in the Jenkins Credentials credentials: - credentialId : fileCredentialId variable : FILE # In user scripts Username and Password can be accessed by LOGIN_USR and LOGIN_PSW # respectively as environment variales - credentialId : dummyGitRepo variable : LOGIN stages: - name: stage1 agent: any steps: - sh: "scripts/hello" - sleep: time: 2 unit: SECONDS - sleep: 2 - junit: testResults: "target/**.xml" allowEmptyResults: true testDataPublishers: - AutomateTestDataPublisher - JunitResultPublisher: urlOverride: "urlOverride" # Post section for "stage1". All Conditions which are available in Jenkins # declarative pipeline are supported post: failure: - sh: "scripts/hello" # Outer post section. Just like declarative pipeline.
post: always: - sh: "scripts/hello"

  • Decide a proper YAML format to use for Jenkinsfile.yaml

  • Create Step Configurator for SPRP plugin. JENKINS-51637. This will enable users to use Pipeline steps in Jenkinsfile.yaml.

  • Automatic indentation generation in the generated PipelineSnippetGenerator class.

  • Write tests for the plugin.

  1. Test Multi-Branch Pipeline features support:

    1. Support for webhooks (JENKINS-51941)

    2. Check if trusted people have approved a pull request and start build accordingly (JENKINS-52517)

  2. Finalize documentation (JENKINS-52518)

  3. Release 1.0 (JENKINS-52519)

  4. Plugin overview blog post

Phase 2 evaluation presentation slides