Jenkins basic
jenkins docker
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
| docker network create jenkins
docker image pull docker:dind
# generate cert
su - root
mkdir /root/certs && cd /root/certs
openssl req -new -newkey rsa:4096 -x509 -sha256 -days 365 -nodes -out MyCertificate.crt -keyout MyKey.key
docker run \
--name jenkins-docker \
--rm \
--detach \
--privileged \
--network jenkins \
--network-alias docker \
--env DOCKER_TLS_CERTDIR=/certs \
--volume jenkins-docker-certs:/certs/client \
--volume jenkins-data:/var/jenkins_home \
--publish 2376:2376 \
docker:dind \
--storage-driver overlay2
|
dockerfile
创建镜像
1
2
3
4
5
6
7
8
9
10
11
| FROM jenkins/jenkins:2.480-jdk21
USER root
RUN apt-get update && apt-get install -y lsb-release
RUN curl -fsSLo /usr/share/keyrings/docker-archive-keyring.asc \
https://download.docker.com/linux/debian/gpg
RUN echo "deb [arch=$(dpkg --print-architecture) \
signed-by=/usr/share/keyrings/docker-archive-keyring.asc] \
https://download.docker.com/linux/debian \
$(lsb_release -cs) stable" > /etc/apt/sources.list.d/docker.list
RUN apt-get update && apt-get install -y docker-ce-cli
USER jenkins
|
构建镜像
1
| docker build -t myjenkins .
|
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
|
运行容器
docker run \
--name jenkins \
--restart=on-failure \
--detach \
--network jenkins \
--env DOCKER_HOST=tcp://docker:2376 \
--env DOCKER_CERT_PATH=/certs/client \
--env DOCKER_TLS_VERIFY=1 \
--publish 8080:8080 \
--volume jenkins-data:/var/jenkins_home \
--volume jenkins-docker-certs:/certs/client:ro \
jekins0
|
Jenkins setup
download jenkins.war; http://mirrors.jenkins-ci.org/war/1.432/
deploy the war to jboss(version:4.0.5.GA) or tomcat
start jboss
open url http://localhost:8080/jenkins
navigate to Manage Jenkins>Configure system
configure name and path for maven
go to jenkins > manage jenkins> manage plugins>advanced
configure proxy (optional)
click “choose file” to upload the plugin; e.g.: git plugin
restart jboss
go to jenkins>Manage Jenkins>Configure system
configure name and path for git plugin(optional)
Create a new job, jenkins>new item
input job name , select Build a free-style software project
[Source Code Management], select git, input URL of repository
[build], click “add build step”, select invoke top-level Maven targets
select maven version
input Goals. e.g. clean, install, surefire-report:report, cobertura:cobertura
**
Jenkins plugins
http://updates.jenkins-ci.org/download/plugins/
jenkins sender email address
Jenkins uses the System Admin e-mail address as the sender address for e-mail notification. You can configure this under Manage Jenkins -> Configure System. This is under the Jenkins Location header on that page
http://stackoverflow.com/questions/9693526/how-can-i-set-the-senders-address-in-jenkins