惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

博客园 - 三生石上(FineUI控件)
GbyAI
GbyAI
奇客Solidot–传递最新科技情报
奇客Solidot–传递最新科技情报
cs.CV updates on arXiv.org
cs.CV updates on arXiv.org
I
InfoQ
Latest news
Latest news
H
Help Net Security
D
Darknet – Hacking Tools, Hacker News & Cyber Security
T
The Exploit Database - CXSecurity.com
雷峰网
雷峰网
Know Your Adversary
Know Your Adversary
人人都是产品经理
人人都是产品经理
C
Cisco Blogs
NISL@THU
NISL@THU
P
Proofpoint News Feed
Y
Y Combinator Blog
I
Intezer
博客园_首页
P
Proofpoint News Feed
Spread Privacy
Spread Privacy
C
CERT Recently Published Vulnerability Notes
G
Google Developers Blog
P
Privacy & Cybersecurity Law Blog
MyScale Blog
MyScale Blog
cs.CL updates on arXiv.org
cs.CL updates on arXiv.org
有赞技术团队
有赞技术团队
S
Schneier on Security
N
Netflix TechBlog - Medium
C
Cybersecurity and Infrastructure Security Agency CISA
T
The Blog of Author Tim Ferriss
K
Kaspersky official blog
博客园 - 聂微东
S
Securelist
Recent Announcements
Recent Announcements
A
About on SuperTechFans
Microsoft Azure Blog
Microsoft Azure Blog
Last Week in AI
Last Week in AI
大猫的无限游戏
大猫的无限游戏
宝玉的分享
宝玉的分享
The GitHub Blog
The GitHub Blog
博客园 - 司徒正美
Vercel News
Vercel News
WordPress大学
WordPress大学
M
MIT News - Artificial intelligence
U
Unit 42
T
Tailwind CSS Blog
云风的 BLOG
云风的 BLOG
B
Blog
aimingoo的专栏
aimingoo的专栏
H
Hackread – Cybersecurity News, Data Breaches, AI and More

博客园 - daviyoung

Windows 11 22H2 安装 .NET Framework 3.5 完整教程 System.Threading.Timer 详细讲解 Agent 开发入门(一):从零构建你的第一个智能体 用 C# 开发一个解释器语言——基于《Crafting Interpreters》的实战系列(五)表达式求值 python使用plotly绘制图表 手把手搭建OPC UA服务器 图像处理库Pillow的使用:批量裁剪图片 python-docx库的使用:图片插入到word文档里 modbus(二)用NModbus4库实现Modbus tcp从站 Streamlit实战 用pycdc批量反编译pyc文件 以ENS 的 BaseRegistrarImplementation 合约为例,用web3.py调用合约 虚拟环境下安装包后,vs code仍然有下滑波浪线及显示找不到包(运行是正常的)的解决办法 Merkle Tree 用 C# 开发一个解释器语言——基于《Crafting Interpreters》的实战系列(四)可视化 语法树 Solidity开发ERC20智能合约claim token的功能 Solidity开发ERC20智能合约demo及部署到测试网 用 C# 开发一个解释器语言——基于《Crafting Interpreters》的实战系列(三)表达式的抽象语法树设计(Expr) 用 C# 开发一个解释器语言——基于《Crafting Interpreters》的实战系列(二)词法分析器
Jenkins 容器化实践:Docker 部署与 CI/CD 流水线配置
daviyoung · 2025-08-15 · via 博客园 - daviyoung

容器启动命令

docker run -d \
  --name jenkins \
  -p 8080:8080 \
  -p 50000:50000 \
  -v /etc/config/jenkins_home:/var/jenkins_home \
  -v /var/run/docker.sock:/var/run/docker.sock \
  -v $(which docker):/usr/bin/docker \
  -e TZ=Asia/Shanghai \
  jenkins/jenkins:lts

设置权限:

# 在宿主机创建目录并设置权限
sudo mkdir -p /etc/config/jenkins_home
sudo chown -R 1000:1000 /etc/config/jenkins_home  
sudo chmod -R 755 /etc/config/jenkins_home

流水线脚本

pipeline {
    agent any
    environment {
        IMAGE_NAME = "yourimagename"
        IMAGE_TAG = "${env.BUILD_ID}"
        DOCKER_REGISTRY_CREDENTIALS = 'your key'
    }
    stages {
        stage('Checkout') {
            steps {
                git branch: 'master',
                    credentialsId: 'your key',
                    url: 'your git url'
            }
        }
        
        stage('Publish') {
            steps {
                script {
                    docker.image('mcr.microsoft.com/dotnet/sdk:6.0').inside('-u root -v /var/jenkins_home/workspace:/workspace') {
                        dir('your proj') {
                            sh 'dotnet restore'
                            sh 'dotnet publish -c Release -o publish'
                        }
                    }
                }
            }
        }
        
        stage('Docker Build & Push') {
            steps {
                script {
                    docker.withRegistry('https://registry.cn-hangzhou.aliyuncs.com', "${DOCKER_REGISTRY_CREDENTIALS}") {
                        def app = docker.build("${IMAGE_NAME}:${IMAGE_TAG}", ".")
                        app.push()
                    }
                }
            }
        }
    }
}

如果需要自动部署可以在后面继续加stage

stage('Deploy') {
    steps {
        script {
            sh """
            docker stop you_container || true
            docker rm you_container || true
            docker pull ${IMAGE_NAME}:${IMAGE_TAG}
            docker run -d \
                --name you_container \
                --restart always \
                ${IMAGE_NAME}:${IMAGE_TAG}
            """
        }
    }
}