Lesson 4: Creating a source template

A source template is a reusable source configuration that can be used by any project that requires the same source type.

Ensure that you installed the Git source-type plug-in before you start this lesson.
In this lesson, you define a Git configuration that is used by the tutorial project.
  1. On the left navigational panel, click Templates, click Source, and then click Create.
  2. In the Source Type list, select Git.
    All installed source-type plug-ins are listed.
  3. Click Select.
    Fields that are related to the selected source type are displayed.
  4. In the Name field, type GitHub.
  5. In the Working Directory Script list, select Default Workflow Directory.
  6. In the Remote URL field, type ${p:git.project}.
    This refers to a property you create in the next section. You supply the property value when you configure the project.
  7. In the Branch field, type ${p?:git.branch}.
  8. Click Save.
The GitHub source template is listed along with the other source templates on the Source Templates tab.

Creating properties for the source template

Define the properties you referenced in the previous section.

  1. If the Source tab is not already displayed, then on the Build dashboard, click Templates, click Source, and then click the GitHub source template that you created earlier in the lesson.
  2. Click Properties, and then click Create.
  3. Create the git.project property by completing these steps.
    1. In the Name field, type git.project.
    2. In the Label field, type Git Project.
      The label text identifies the property to users that use the source template.
    3. In the Description field, type Path of the GitHub project within the account.
      The description text is displayed to users.
    4. In the Display Type list, select Text.
    5. In the Value area, accept the default option Defined.
      The Value option determines when and where the value for the property is defined. By selecting Defined, you can provide a value in the Default Value field, or supply the value on the project configuration before the project runs.
    6. Leave the Default Value field blank.
      You define the property value when you configure the project.
    7. Select the Value Required check box.
    8. Click Save.
  4. Create the git.branch property by completing these steps.
    1. On the Properties tab, click Create.
    2. In the Name field, type git.branch.
    3. In the Label field, type Git Branch.
    4. In the Description field, type Source branch. Leave the field blank for the master branch.
    5. In the Display Type list, select Text.
    6. Leave the Default Value field blank.
    7. Clear the Required check box.
    8. Click Save.

Lesson checkpoint

In this lesson, you created a source template and defined properties that identify the source material used in the build.

The GitHub source template properties are shown in the following figure:
The GitHub source template properties