Skip to content

Instantly share code, notes, and snippets.

@egeneralov
Created June 25, 2019 00:07
Show Gist options
  • Save egeneralov/8d52e799bb9f28b42b4eb721cf952463 to your computer and use it in GitHub Desktop.
Save egeneralov/8d52e799bb9f28b42b4eb721cf952463 to your computer and use it in GitHub Desktop.
Jenkinsfile examples
/*
Example Jenkinsfile for build docker images.
Just place inside VCS and use multibranch project.
*/
node('master') {
checkout scm
stage("build") {
/* build it */
def customImage = docker.build(
"my-image:${env.BUILD_ID}",
"./Dockerfile.non-standart"
)
}
stage("test") {
/* test it */
customImage.inside {
sh 'make test'
}
}
stage("test") {
/* use registry with plain auth, like "gitlab registry"/"docker hub" */
docker.withRegistry('https://registry.example.com', 'credentials-id') {
/* push it */
customImage.push()
/* and push with custom tag */
customImage.push('latest')
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment