I am able to create a "Pipeline" item in Jenkins where I am specifing a Jenkinsfile to use a docker container to run all the stages like this:
pipeline {
agent {
docker {
image '<registry>:<port>/<image name>'
registryUrl '<url>'
registryCredentialsId 'ARTIFACTORY_CREDS'
}
}
stages {
stage ('Environment') {
steps {
sh "env | sort"
}
}
}
}
This works fine. But since I am looking to make use of Jenkins release management process for a gradle project, I rather would like to use a "Freestyle project" item. I am not sure how to specify the docker image to use for the build process there. It seems like we cannot provide a Jenkinsfile as well. Any pointers will be helpful. I want to replicate the same behaviour as I am able to with the Jenkinsfile.
Jenkins version: 2.107.3
Take a look at this plugin - it worked for me.
If you're running Jenkins itself inside a container using -v /var/run/docker.sock:/var/run/docker.sock
there's some extra work to be done. In my case I had to:
-v /tmp:/tmp
. This is necessary because the plugin passes the build instructions via a temporary shell script written to that location.If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With