title | theme | revealOptions | todo | ||||
---|---|---|---|---|---|---|---|
Docker & Jenkins |
white |
|
add process of how docker slaves are being setup remix types in scale out |
- Mans Matulewicz
- Dev Engineer
|
- Ordina (employer)
- ING (assignment)
- Anything in this presentation is solely my opinion, it doesn't have to reflect the opinions of ING or Ordina
- What is Docker/Jenkins
- Running Jenkins in a container
- Using Dockerized build slaves
- Pipelines
- Docker is a tool for building and running containers
- Containers are like a vm without an OS
- Multiple containers can run on a server
- Lightweight
- Continuous integration
- Orchestrator
- Plugin based
- Pipelines as code (key feature of Jenkins 2)
|
FROM jenkins:2.7.3
RUN /usr/local/bin/install-plugins.sh \
workflow-aggregator git token-macro docker-plugin:0.16.0
#config
COPY jobs/buildslavedemo-jenkinsfile.xml \
/usr/share/jenkins/ref/jobs/buildslavedemo/config.xml
COPY config.xml /usr/share/jenkins/ref/config.xml
COPY credentials.xml /usr/share/jenkins/ref/credentials.xml
USER root
#Adding Jenkins to correct user groups
RUN usermod -a -G users,staff jenkins
RUN usermod -a -G 100 jenkins
USER jenkins
- For everything there is a plugin
- Today we are talking about:
- Pipeline/workflow
- Docker-cloud
- Plugin dependencies can be tricky
- Not a really good method for credentials
- New job -> new build
- Build numbers are reset on new container (at ING we circumvent this by versioning packages with git-tag numbers)
- Jenkins in a Container
|
- Building on a different machine
- Spinning up a Docker container as buildslave
- Building for multiple platforms
- Don't overload your buildmachine
- Use a cluster of build slaves for use by multiple projects
- Different OS (EL6 or EL7)
- Different programming language (C/Java/Go/Puppet)
- Vendor code base + additional code
- Testing tools
FROM centos:7
RUN yum update -y && yum install -y \
openssh-server sudo git java-1.8.0-openjdk-headless && \
yum clean all
#configuring sshd
RUN sed 's/UsePAM yes/UsePAM no/' -i /etc/ssh/sshd_config
RUN ssh-keygen -t rsa -f /etc/ssh/ssh_host_rsa_key
RUN mkdir -p /var/run/sshd && chmod -rx /var/run/sshd
#jenkins user
RUN useradd -u 1000 -m -s /bin/bash jenkins && \
echo "jenkins:jenkins" | chpasswd && \
mkdir -p /home/jenkins && chown -R jenkins:jenkins /home/jenkins
EXPOSE 22
- Docker-cloud
- Kubernetes-cloud
- Nomad-cloud
- Mesos-cloud
- Swarm-cloud
- Docker buildslaves
- Old: clicking everything together
- Jenkinsfile
- Can be in your Git repo with your code
- Project evolves, buildsteps as well
- Versioning Everything Rocks!™
- Crash, no more AAAAARRGGGHHHHHHHH
node() {
stage ('git clone'){
checkout scm
sh 'BNUMBER=$(git tag | awk -F- \'{print $NF} END { if (NR==0) print "0"}\' | sort -V | tail -1) ; echo $BNUMBER > .bnumber'
def BNUMBER = readFile('.bnumber').trim()
env.BNUMBER = BNUMBER
}
stage ('centos6'){
node('uildslave-centos6') {
checkout scm
withCredentials([[$class: 'UsernamePasswordMultiBinding', credentialsId: 'Other_User', usernameVariable: 'OTHER_USERNAME', passwordVariable: 'OTHER_PASSWORD']]) {
sh "sed -i \"s#CHANGEME#${env.OTHER_PASSWORD}#g\" somefile.json"
sh "./do_something_centos_sixish.sh"
}
}
}
stage ('centos7'){
node('uildslave-centos7') {
checkout scm
withCredentials([[$class: 'UsernamePasswordMultiBinding', credentialsId: 'Other_User', usernameVariable: 'OTHER_USERNAME', passwordVariable: 'OTHER_PASSWORD']]) {
sh "sed -i \"s#CHANGEME#${env.OTHER_PASSWORD}#g\" somefile.json"
sh "./do_something_centos_sevenish.sh"
}
}
}
}
- Original used for maintaining lots of puppet modules
- I use it to sync Jenkinsfile (and other files) to multiple repo’s
- Same Jenkinsfile for lots of repo’s (by example standardized RPM builds)