README

This plugin uses template files to automatically generate the Jenkinsfile and/or Kubernetes files necessary for building and deploying the application. This will also generate a dibr.md file that contains deployment information such as required vault variables.

ngss-filegen-maven-plugin 5.0+ generates a single Jenkinsfile for all environments. Prior releases required one per environment, but with the xref:jenkins-shared-libs, this is no longer necessary.

Plugin Setup

The following steps must be done one time in order to set up the plugin to work on all projects.

Add BitBucket Token to Maven Settings

To use the generator, you must have an account for the VA BitBucket - coderepo.mobilehealth.va.gov

Add your account credentials to the ~/.m2/settings.xml file so that it can be used during Maven builds:

    <server>
      <id>bitbucket</id>
      <username>YourUserName</username>
      <password>YourPassword or Token</password>
    </server>

NOTE: As of Release 3.0 you can use either a plain text password, or a maven encrypted password: mvn --encrypt-password <password>

Project Setup

filegen uses some metadata.yaml documentation fields for populating variables in various templates. Here is how each field is used.

documentation:
  jiraProjectKey: ckm    # (required) vv.yaml
  po: John Doe           # (optional) vv.yaml
  apigw:                 # (optional) dibr.md
    registration: both
  vault:                 # (optional) dibr.md
  - name: SECRET_PWD
    comment: The password to authenticate with.

Generate CI Files

Here are the commands to generate the corresponding files. Each "Maven Goal" is executed by running it using the standard Maven plugin syntax, mvn filegen:<goal>

Maven Goal File(s) Generated Property Source(s)

generate-skaffold-file

skaffold.yaml
scripts/
  kill-skaffold-api-server.sh
  localize.sh
  start-skaffold.sh
  stop-skaffold.sh
  validate-skaffold.sh
  version.sh
  wait.sh

templates/skaffold/skaffold.properties, pom.xml

generate-kustomize-files

kustomize/
  base
  components
  debug-all
  debug-suspend
  dev-with-dependencies
  dev-with-dependencies-vault
  prod
  sandbox
  sqa

templates/skaffold/skaffold.properties, pom.xml

generate-dibr-readme

dibr.md

templates/dibr/dibr.properties, kubernetes/base/service.yaml

generate-flyway-scripts

  wait_for_postgres.sh
  wait_for_oracle.sh
  flyway_migrate.sh
  sql/README.md
  init/db-user-and-schema.sql

templates/dibr/dibr.properties, kubernetes/base/service.yaml

generate-jenkinsfile

Jenkinsfile

N/A

jenkins-yaml

jenkins.yaml

metadata.yaml, vv.yaml, pom.xml

Maven Plugin Tiles

To provide an easy method of configuration, the NGSS Maven Tiles project defines several Maven Tile configurations (pom.xml snippets) which can be included in your project pom.xml. The examples in the following sections assume that the ngss-maven-tiles.version property is set in the pom.xml <properties> tag and that the tiles-maven-plugin is configured in the <plugins> tag.

<plugin>
    <groupId>io.repaint.maven</groupId>
    <artifactId>tiles-maven-plugin</artifactId>
    <extensions>true</extensions>
    <configuration>
        <tiles>
            <!-- include tiles -->
        </tiles>
    </configuration>
</plugin>

filegen-tile

<tile>gov.va.mobile.tools.maven:filegen-tile:${ngss-maven-tiles.version}</tile>
  • Base ngss-filegen-maven-plugin configuration, which allows you to run any of its defined Maven goals directly

vv-automation-tile

<tile>gov.va.mobile.tools.maven:vv-automation-tile:${ngss-maven-tiles.version}</tile>
  • Generates the vv.yaml on each build

  • Bound to the process-resources phase, so any higher phase (like mvn package, mvn install, etc.) will trigger its execution

dibr-readme-generator-tile

<tile>gov.va.mobile.tools.maven:dibr-readme-generator-tile:${ngss-maven-tiles.version}</tile>
  • Generates the dibr.md on each build

  • Bound to the package phase