Daily usage Jenkins Pipeline utilities covered by JUnit tests.
In your Jenkninsfile
#!groovy
node {
def docker
String version
stage("checkout code") {
// checkout your code here or there ...
// and then:
checkout([$class : 'GitSCM',
extensions : [[$class : 'RelativeTargetDirectory',
relativeTargetDir: 'jenkins-pipeline-goodness'],
[$class : 'CleanCheckout']],
userRemoteConfigs : [[url: 'git@github.com:doublescoring/jenkins-pipeline-goodness.git']], // Jenkins Pipeline Goodness url
branches : [[name: 'refs/tags/1.1.1']]]) // Jenkins Pipeline Goodness version
}
docker = load "jenkins-pipeline-goodness/src/main/groovy/docker.groovy" // attach docker module
try {
stage("build image") {
dir('path/to/your/dockerfile/') {
def dockerFileContent = readFile('Dockerfile')
version = docker.readVersion(dockerFileContent)
echo "Found version in Dockerfile ${version}"
docker.imageBuildPush("organization/name", version, "latest", "our-private-registry:12345")
}
}
} finally {
if (something_exists_that_we_must_clean) {
docker.stopById(dockerContainerId);
docker.removeImage("organization/name", version);
}
}
}
exec
- Execute command inside docker imageimageBuildPush
- Build a docker image, tag it, and push to reporun
- Run a docker image, wait the TCP port to be ready, return container IdremoveImage
- Remove image from repostopById
- Stop docker container.readVersion
- Read LABEL version="n.n.n" from DockerfiletemporaryFile
- Get temporary file
Simple airflow integration. Support for DAG triggering passing config from Jenkins.
trigger
- Trigger DAGgetState
- Return DAG state (running/failed/...)waitFor
- Wait for DAG finish, i.e. success or failed state
Important: getState
and waitFor
require Airflow version 1.10.3 or higher
mvn test - for all tests
mvn -Dtest=environmentTest test - for environment tests
This project follow Apache rules of semantic versioning. Use git tags of the current project.
- Alexey Aksenov
- Pavel Shuvalov
The Jenkins Pipeline Goodness Project is licensed to you under the terms of the Apache License, version 2.0, a copy of which has been included in the LICENSE file. Please check the individual source files for details.
Copyright © 2016-2020 DoubleData Ltd. All rights reserved.