Validate Jenkinsfile locally without the need to push to github before
481
Jenkinsfile Runner is an experiment to package Jenkins pipeline execution as a command line tool. The intend use cases include:
Jenkinsfile locallySay you have your Git repository checked out at ~/foo that contains Jenkinsfile and your source code.
You can now run Jenkinsfile Runner like this:
$ cat ~/foo/Jenkinsfile
pipeline {
agent any
stages {
stage('Build') {
steps {
echo 'Hello world!'
sh 'ls -la'
}
}
}
}
$ docker run -v $(pwd):/workspace marcellodesales/jenkinsfile-runner
docker commands can be run as follows:docker run -v $(pwd):/workspace \
-v /var/run/docker.sock:/var/run/docker.sock \
-v $(which docker):$(which docker) marcellodesales/jenkinsfile-runner
[Pipeline] [Validate Runtime] // stage
[Pipeline] [Validate Test] // stage
[Pipeline] [Validate Runtime] }
[Pipeline] [Validate Test] }
[Pipeline] // parallel
[Pipeline] }
[Pipeline] // stage
[Pipeline] stage
[Pipeline] { (Build Test Image)
[Pipeline] script
[Pipeline] {
[Pipeline] }
[Pipeline] // script
[Pipeline] echo
Building docker image for tests from build stage null
[Pipeline] sh
[job] Running shell script
+ docker build -t tests:null -f Dockerfile --target builder .
Sending build context to Docker daemon 13.75MB
Step 1/9 : FROM maven:3.2.5-jdk-8 as builder
---> 95dd59c15f5d
Step 2/9 : MAINTAINER [email protected]
---> Using cache
---> e4edaeb48381
Step 3/9 : ADD ./pom.xml /opt/build/pom.xml
---> Using cache
---> 2ca95e0b276e
Step 4/9 : ADD ./settings.xml /opt/build/settings.xml
---> Using cache
docker pull marcellodesales/jenkinsfile-runner:latest