GitHub plugin use cases

4 minute readExtensibilityDeveloper productivity

The following examples illustrate how you can use the Git and GitHub plugins in CloudBees CD/RO to:

Create a release

This example shows how to add tasks to a pipeline stage to create a release. To create a release, you must:

Create a clone task

You must first create a pipeline and add a task to clone a remote repository.

To create a clone task:

  1. Create a new pipeline. For more information, refer to Create a pipeline.

  2. For the Pipeline stage, select Add+.

  3. Enter Clone as the task name.

  4. Click Select Task Type to define the task.

  5. From the Plugins list, select the EC-Git plugin and then select the Clone plugin procedure.

  6. Select Define, configure the plugin task’s input and output parameters, and select OK.

    Clone task
    Figure 1. Configure the clone task
  7. Select OK to save your changes.

Create a build task

After creating the clone task, you must create a build task.

To create a build task:

  1. For the Pipeline stage, select Add+.

  2. Enter Build as the task name.

  3. Click Select Task Type to define the task.

  4. From the Native list, select Command.

  5. Select Define, specify the build settings, and then select OK.

    Build task
    Figure 2. Configure the build task
  6. Select OK to save your changes.

Create a release task

After creating the change task, you must create a release task to create a new GitHub release or update an existing GitHub release.

To create a release task:

  1. For the Pipeline stage, select Add+.

  2. Enter Create Release as the task name.

  3. Click Select Task Type to define the task.

  4. From the Plugins list, select EC-GitHub, and then select the Create Release plugin procedure.

  5. Select Define, configure the plugin task’s input and output parameters, and then select OK.

    Create release task
    Figure 3. Configure the release task
  6. Select OK to save your changes.

    Your pipeline is now configured like the example below:

    Pipeline
    Figure 4. Configured Pipeline

Create a pull request

This example shows how to add tasks to a pipeline stage to create a GitHub pull request for the specified repository. To create a pull request, you must:

Create a clone task

You must first create a pipeline and add a task to clone a remote repository.

To create a clone task:

  1. Create a new pipeline. For more information, refer to Create a pipeline.

  2. For the Pipeline stage, select Add+.

  3. Enter Clone as the task name.

  4. Click Select Task Type to define the task.

  5. From the Plugins list, select the EC-Git plugin and then select the Clone plugin procedure.

  6. Select Define, configure the plugin task’s input and output parameters, and select OK.

    Clone task
    Figure 5. Configure the clone task
  7. Select OK to save your changes.

Create a change task

After creating the clone task, you must create a change task.

To create a change task:

  1. For the Pipeline stage, select Add+.

  2. Enter Change as the task name.

  3. Click Select Task Type to define the task.

  4. From the Native list, select Command.

  5. Select Define, specify the script settings, and select OK.

    Change task
    Figure 6. Configure the change task
  6. Select OK to save your changes.

Create a commit task

After creating the change task, you must create a task to commit and push changes to the remote repository.

To create a commit task:

  1. For the Pipeline stage, select Add+.

  2. Enter Commit + Push as the task name.

  3. Click Select Task Type to define the task.

  4. From the Plugins list, select EC-Git, and then select the Commit plugin procedure.

  5. Select Define, configure the plugin task’s input and output parameters, and then select OK.

    Commit task
    Figure 7. Configure the commit task
  6. Select OK to save your changes.

Create a pull request task

After creating the commit task, you must create a task to create a pull request for the specified repository.

To create a pull request task:

  1. For the Pipeline stage, select Add+.

  2. Enter Create PR as the task name.

  3. Click Select Task Type to define the task.

  4. From the Plugins list, select EC-GitHub, and then select the Create Pull Request plugin procedure.

  5. Select Define, configure the plugin task’s input and output parameters, and then select OK.

    Pull request task
    Figure 8. Configure the pull request task
  6. Select OK to save your changes.

    Your pipeline is now configured like the example below:

    Pipeline
    Figure 9. Configured Pipeline

Upload a file

This example shows how to add tasks to a pipeline stage to create a release. To upload a file, you must:

Create a get files task

You must first create a pipeline, add a task to fetch the content of the specified files, and store it in the filesystem or in the specified property.

To create a get files task:

  1. Create a new pipeline. For more information, refer to Create a pipeline.

  2. For the Pipeline stage, select Add+.

  3. Enter Get file as the task name.

  4. Click Select Task Type to define the task.

  5. From the Plugins list, select EC-GitHub, and then select the Get Files plugin procedure.

  6. Select Define, configure the plugin task’s input and output parameters, and then select OK.

    Get files task
    Figure 10. Configure the get file task
  7. Select OK to save your changes.

Create a change task

After creating the get files task, you must create a change task.

To create a change task:

  1. For the Pipeline stage, select Add+.

  2. Enter Change as the task name.

  3. Click Select Task Type to define the task.

  4. From the Native list, select Command.

  5. Select Define, specify the script settings, and select OK.

    Change task
    Figure 11. Configure the change task
  6. Select OK to save your changes.

Create an upload files task

After creating the change task, you must create a task to upload files to the specified repository.

To create an upload files task:

  1. For the Pipeline stage, select Add+.

  2. Enter Upload file as the task name.

  3. Click Select Task Type to define the task.

  4. From the Plugins list, select EC-GitHub, and then select the Upload Files plugin procedure.

  5. Select Define, configure the plugin task’s input and output parameters, and then select OK.

    Upload file
    Figure 12. Configure the upload file task
  6. Select OK to save your changes.

    Your pipeline is now configured like the example below:

    Pipeline
    Figure 13. Configured Pipeline