jenkins_pipeline后端_python_docker
2021-03-09 11:29
标签:ESS passwd 镜像 nta $1 失败 doc ges shang pipeline { environment { stages { stage(‘Clean local history images‘) { stage(‘Build docker image‘) { stage(‘Push docker image‘) { stage (‘Deploy‘) { sshCommand remote: remote, command: "docker pull 仓库地址/${imagename}:${tag}" stage (‘Restart service‘) { sshCommand remote: remote, command: "docker stop ${imagename} || echo ‘DONE‘" stage (‘Clean history docker images on romote server‘) { sshCommand remote: remote, command: "docker images 仓库地址/${imagename} --filter \"before=172.17.0.4:5000/${imagename}:latest\" -q | xargs docker rmi || echo ‘DONE‘" } _________________________dockerfile______________________________________ FROM ubuntu:18.04 MAINTAINER 乂 RUN echo "deb http://mirrors.ustc.edu.cn/ubuntu/ bionic main restricted universe multiverse" > /etc/apt/sources.list && \ ENV TZ Asia/Shanghai RUN apt-get update \ RUN apt-get update -y \ ADD . /code WORKDIR /code RUN pip3 install -i https://mirrors.aliyun.com/pypi/simple/ --upgrade pip EXPOSE 5000 jenkins_pipeline后端_python_docker 标签:ESS passwd 镜像 nta $1 失败 doc ges shang 原文地址:https://www.cnblogs.com/sqbk/p/14177576.html
agent any
imagename = "镜像命名"
tag = "v${BUILD_NUMBER}"
}
stage(‘Pull code‘) {
steps {
echo "${imagename}:${tag}"
git credentialsId: ‘git_key‘, url: ‘git地址‘
}
}
steps {
sh ‘docker images | grep ${imagename} | awk \‘{print $1":"$2}\‘ | xargs docker rmi || echo "DONE"‘
}
}
steps {
sh ‘docker build --tag=${imagename}:${tag} .‘
sh ‘docker tag ${imagename}:${tag} 仓库地址/${imagename}:${tag}‘
sh ‘docker tag ${imagename}:${tag} 仓库地址/${imagename}:latest‘
}
}
steps {
sh ‘docker push 仓库地址/${imagename}:${tag}‘
sh ‘docker push 仓库地址/${imagename}:latest‘
}
}
steps {
script {
def remote = [:]
remote.name = ‘服务器命名‘
remote.host = ‘项目IP‘
remote.user = ‘user‘
remote.password = ‘passwd‘
remote.allowAnyHosts = true
sshCommand remote: remote, command: "docker pull 仓库地址/${imagename}:latest"
}
}
}
steps {
script {
def remote = [:]
remote.name = ‘服务器命名‘
remote.host = ‘项目IP‘
remote.user = ‘user‘
remote.password = ‘passwd‘
remote.allowAnyHosts = true
sshCommand remote: remote, command: "docker rm ${imagename} || echo ‘DONE‘"
sshCommand remote: remote, command: "docker run -d --name ${imagename} -p 5050:5000 仓库地址/${imagename}:latest"
}
}
}
steps {
script {
def remote = [:]
remote.name = ‘服务器命名‘
remote.host = ‘项目IP‘
remote.user = ‘user‘
remote.password = ‘passwd‘
remote.allowAnyHosts = true
}
}
}
}
#bearychat报警
post {
unstable {
bearychatSend color: ‘red‘, message: "${env.JOB_NAME},构建不稳定"
}
failure {
bearychatSend color: ‘red‘, message: "${env.JOB_NAME},构建失败"
}
}
echo "deb-src http://mirrors.ustc.edu.cn/ubuntu/ bionic main restricted universe multiverse" >> /etc/apt/sources.list&& \
echo "deb http://mirrors.ustc.edu.cn/ubuntu/ bionic-updates main restricted universe multiverse" >> /etc/apt/sources.list&& \
echo "deb-src http://mirrors.ustc.edu.cn/ubuntu/ bionic-updates main restricted universe multiverse" >> /etc/apt/sources.list&& \
echo "deb http://mirrors.ustc.edu.cn/ubuntu/ bionic-backports main restricted universe multiverse" >> /etc/apt/sources.list&& \
echo "deb-src http://mirrors.ustc.edu.cn/ubuntu/ bionic-backports main restricted universe multiverse" >> /etc/apt/sources.list&& \
echo "deb http://mirrors.ustc.edu.cn/ubuntu/ bionic-security main restricted universe multiverse" >> /etc/apt/sources.list&& \
echo "deb-src http://mirrors.ustc.edu.cn/ubuntu/ bionic-security main restricted universe multiverse" >> /etc/apt/sources.list&& \
echo "deb http://mirrors.ustc.edu.cn/ubuntu/ bionic-proposed main restricted universe multiverse" >> /etc/apt/sources.list&& \
echo "deb-src http://mirrors.ustc.edu.cn/ubuntu/ bionic-proposed main restricted universe multiverse" >> /etc/apt/sources.list
ENV PruneTreeEnv production
&& ln -snf /usr/share/zoneinfo/$TZ /etc/localtime && echo $TZ > /etc/timezone \
&& apt-get install -y tzdata \
&& apt-get clean \
&& apt-get autoclean \
&& rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/*
&& apt-get install -y \
vim \
gunicorn \
python3-dev \
python3-pip
RUN pip3 install -r requirements.txt -i https://mirrors.aliyun.com/pypi/simple/
CMD ["gunicorn", "-b 0.0.0.0:5000", "-k gevent", "app:app"]
文章标题:jenkins_pipeline后端_python_docker
文章链接:http://soscw.com/index.php/essay/62267.html