Cheatography
https://cheatography.com
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 |
Jenkinsfile based build |
|
Nexus OSS Repository for npm, maven and docker repositories |
|
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 Repository.
|
|
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 recommended 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 significantly improve your build performance. But you can skip it to get "clean" builds. |
Examples
docker {
image mvn.jdk8()
args mvn.OPTS()
reuseNode true
}
steps {
mvn 'package -Pdocker'
}
steps {
mvn 'clean install -DskipTests'
}
|
|
Publish Artifacts
Publishing is supported for the following image formats |
|
Maven or Jar |
|
NPM components |
|
docker containers |
URL |
|
|
Roles |
Reader |
fadvrepouser. The default readonly user for your application development. Provides read of all artifacts. |
Write |
fadvciuser. The Nexus user with write permissions, mainly to be used by the CI system. |
Publishing Maven Artifacts
Sample settings.xml entry
<server>
<id>fadv-m2</id>
<username>fadvrepouser</username>
<password> contact admin </password>
</server>
Sample pom.xml entry
<repositories>
<repository>
<id>fadv-m2</id>
<url>https://cloudci.fadv.com/nexus/repository/fadv-m2/</url>
</repository>
</repositories> |
Publishing Docker Artifacts
|