Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
A `bash` function for running the Jenkins CI LTS image as a docker process.
function jenkinsondocker() {
if [ $(ps -elf | grep docker | wc -l) -gt 0 ];
echo -n $(docker stop jenkins 2>&1) | sed 's/Error response from daemon://'
echo -n $(docker rm jenkins 2>&1) | sed 's/Error response from daemon://'
docker pull jenkins/jenkins:lts
docker run --detach --publish 49000:8080 --name jenkins jenkins/jenkins:lts
echo -n "Waiting for Jenkins process to start ."
until [ $(curl -o /dev/null --silent --head --write-out '%{http_code}\n' -eq 403 ]; do echo -n '.'; sleep 1; done
echo -n "Here's the admin password! "
docker exec jenkins cat /var/jenkins_home/secrets/initialAdminPassword
echo "Browse to http://localhost:49000"
echo "Can't find any docker processes. Is Docker really running? :/"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment