Show Menu
Cheatography

First Advantage Jenkins Cheat Sheet (DRAFT) by

This is a cheatsheet to building simple Jenkinsfile that leverages all FADV Shared Libraries and Services.

This is a draft cheat sheet. It is a work in progress and is not finished yet.

Getting Started

Services
Jenkin­sfile based build
 
Nexus OSS Repository for npm, maven and docker reposi­tories
 
Shared Library DSL for mvn, nexus and docker
URLs
 
 
 
Agents
any
 
Use any by default. Other modes to be available soon.
 
E.g. pipeline { agent any ... }

Sample 1 - Maven Library Project

pipeline {
    agent any

    stages {
        stage('Build') {
            agent { 
              docker {
                image mvn.jdk8()
                args  mvn.OPTS()
                reuseNode true
              }
            }

            steps {
                mvn 'clean install'
            }
        }
        
        stage('Publish') {
            steps {
                publish 'maven'
            }
        }    
    }
}
Builds a Java 8 Project and Publishes the artifact to Nexus.

Sample 2 - Maven Service Project

pipeline {
    agent any

    stages {
        stage('Build') {
            agent { 
              docker {
                image mvn.jdk8()
                args  mvn.OPTS()
                reuseNode true
              }
            }

            steps {
                mvn 'clean install'
            }
        }
        
        stage('Publish') {
            steps {
                publish 'maven'
            }
        }    
    }
}
Builds a Maven Java 8 Project and Publishes the artifact to Nexus and Generates a docker image and pushes it to FADV Image Reposi­tory.
 

Maven DSL

mvn
goals
The default DSL for maven args and sub commands. E.g., mvn 'clean install'
 
.jdk8()
Returns the JDK8 Maven Docker image to use.
   
maven:­3.6.0-­jdk­-8-­alpine
   
To be used whenever you need the recomm­ended JDK 8 maven container. Mostly in agent docker sections.
 
.jdk11()
Returns the JDK 11 Maven Docker image to use.
   
maven:­3.6.0-­jdk-11
 
.OPTS()
Returns docker options to mount standard m2 repository and other defaults. Use this to signif­icantly improve your build perfor­mance. But you can skip it to get "­cle­an" builds.
Examples

docker {
 ­ ­image mvn.jdk8()
 ­ args mvn.OPTS()
 ­ ­reu­seNode true
}

steps {
 ­ mvn 'package -Pdocker'
}

steps {
 ­ mvn 'clean install -Dskip­Tests'
}
 

Publish Artifacts

Publishing is supported for the following image formats
 
Maven or Jar
 
NPM components
 
docker containers
URL
 
Roles
Reader
fadvre­pouser. The default readonly user for your applic­ation develo­pment. Provides read of all artifacts.
Write
fadvciuser. The Nexus user with write permis­sions, mainly to be used by the CI system.

Publishing Maven Artifacts

Sample settin­gs.xml entry

<se­rve­r>
 ­ ­ ­<id­>fa­dv-­m2<­/id>
 ­ ­ ­<us­ern­ame­>fa­dvr­epo­use­r</­use­rna­me>
 ­ ­ ­<pa­ssw­ord> contact admin </p­ass­wor­d>
</s­erv­er>


Sample pom.xml entry

<re­pos­ito­rie­s>
 ­ ­<re­pos­ito­ry>
 ­ ­ ­ ­<id­>fa­dv-­m2<­/id>
 ­ ­ ­ ­<ur­l>h­ttp­s:/­/cl­oud­ci.f­ad­v.c­om/­nex­us/­rep­osi­tor­y/f­adv­-m2­/</­url>
 ­ ­</r­epo­sit­ory>
</r­epo­sit­ori­es>

Publishing NPM Artifacts

TBD

Publishing Docker Artifacts

TBD