Giter Site home page Giter Site logo

jenkins-slave's Introduction

jenkins-slave

About

Most complete Jenkins slave Docker image that can be used for building other docker images

Build args

DOCKER_VERSION

Use latest docker client version

DOCKER_GID

GID for docker group has to be exactly the same as one on the host, otherwise docker client won't be able to communicate with dockerd (running on the host) over docker socket (/var/run/docker.sock)

Build commands

Use local Dockerfile

docker build --no-cache --build-arg DOCKER_VERSION=17.06.0 --build-arg DOCKER_GID=997 -t psyhomb/jenkins-slave .

Use URL to access Dockerfile

docker build --no-cache --build-arg DOCKER_VERSION=17.06.0 --build-arg DOCKER_GID=997 -t psyhomb/jenkins-slave 'https://github.com/psyhomb/jenkins-slave/raw/master/Dockerfile'

Run command

WARN: Use this command only for testing, Jenkins will automatically start this container when build process starts

docker run -d -it --name jenkins-slave -v /var/run/docker.sock:/var/run/docker.sock -p 22 psyhomb/jenkins-slave

Jenkins

You can use this custom shell code in the Jenkins job Build section => build type 'Execute shell'

### Custom and override environment vars
# override
export DOCKER_HOST="unix:///var/run/docker.sock"
# custom
export DOCKER_REGISTRY_URL="registry.example.com"
export DOCKER_IMAGE_NAME="${DOCKER_REGISTRY_URL}/${JOB_BASE_NAME}"

### This way you can discover all the environment vars injected by Jenkins during runtime
#env

### Build and push image
docker build -t ${DOCKER_IMAGE_NAME}:${BUILD_NUMBER} .
docker tag ${DOCKER_IMAGE_NAME}:${BUILD_NUMBER} ${DOCKER_IMAGE_NAME}:latest
docker push ${DOCKER_IMAGE_NAME}:latest

### Do some cleanup
#for BN in ${BUILD_NUMBER} latest; do
#  docker rmi -f ${DOCKER_IMAGE_NAME}:${BN}
#done

### Show all Docker images for the current project
docker images | grep ${DOCKER_IMAGE_NAME}

jenkins-slave's People

Contributors

psyhomb avatar

Stargazers

 avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.