提交 8c6d6383 编写于 作者: LinuxSuRen's avatar LinuxSuRen

deploy

上级 c53d79f2
......@@ -166,6 +166,7 @@
<section class="flex-ns flex-wrap justify-between w-100">
<div class="relative weight-100">
<div class="bg-white mb2 pa3 pa4-l gray">
......@@ -190,7 +191,9 @@
</div>
</div>
<div class="relative weight-0">
<div class="bg-white mb2 pa3 pa4-l gray">
......@@ -215,7 +218,9 @@
</div>
</div>
<div class="relative weight-0">
<div class="bg-white mb2 pa3 pa4-l gray">
......@@ -240,7 +245,9 @@
</div>
</div>
<div class="relative weight-0">
<div class="bg-white mb2 pa3 pa4-l gray">
......@@ -265,7 +272,9 @@
</div>
</div>
<div class="relative weight-0">
<div class="bg-white mb2 pa3 pa4-l gray">
......@@ -290,6 +299,7 @@
</div>
</div>
</section>
</div>
......
......@@ -216,7 +216,7 @@
</style>
<div class="topic">
<div>
<img src="/images/meetup/hacktberfest.jpg" alt>
<img width="320px" height="160px" src="/images/meetup/hacktberfest.jpg" alt>
</div>
<div class="detail">
<h4>Jenkins 社区的 Hacktoberfest</h4>
......
......@@ -216,7 +216,7 @@
</style>
<div class="topic">
<div>
<img src="" alt>
<img width="320px" height="160px" src="/images/meetup/hangzhou.jpeg" alt>
</div>
<div class="detail">
<h4>主题</h4>
......
......@@ -247,6 +247,25 @@
</td>
</tr>
<tr>
<td>武汉</td>
<td>待定</td>
<td>待定</td>
<td>
敬请期待
</td>
<td>
<a href="https://github.com/jenkins-zh/jenkins-zh/edit/master/content/event/wuhang.md"
class="f6 ph3 pv1 br2 dib tc ttu mv3 bg-primary-color white hover-bg-green link"
target="_blank">
立即申请
</a>
</td>
</tr>
</tbody>
</table>
</div>
......
......@@ -58,5 +58,14 @@
<description></description>
</item>
<item>
<title></title>
<link>https://jenkins-zh.github.io/event/wuhang/</link>
<pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate>
<guid>https://jenkins-zh.github.io/event/wuhang/</guid>
<description></description>
</item>
</channel>
</rss>
\ No newline at end of file
......@@ -216,7 +216,7 @@
</style>
<div class="topic">
<div>
<img src="" alt>
<img width="320px" height="160px" src="/images/meetup/shanghai.jpeg" alt>
</div>
<div class="detail">
<h4>主题</h4>
......
......@@ -216,7 +216,7 @@
</style>
<div class="topic">
<div>
<img src="" alt>
<img width="320px" height="160px" src="/images/meetup/shenzhen.jpeg" alt>
</div>
<div class="detail">
<h4>主题</h4>
......
<!DOCTYPE html>
<html class="no-js" lang="zh-CN">
<head>
<meta charset="utf-8">
<link rel="preload" href="https://jenkins-zh.github.io/files/muli-latin-200.woff2" as="font" type="font/woff2" crossorigin>
<link rel="preload" href="https://jenkins-zh.github.io/files/muli-latin-400.woff2" as="font" type="font/woff2" crossorigin>
<link rel="preload" href="https://jenkins-zh.github.io/files/muli-latin-800.woff2" as="font" type="font/woff2" crossorigin>
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<title>Jenkins 中文社区</title>
<meta name="HandheldFriendly" content="True">
<meta name="MobileOptimized" content="320">
<meta name="viewport" content="width=device-width,minimum-scale=1">
<meta name="generator" content="Hugo 0.52" />
<META NAME="ROBOTS" CONTENT="NOINDEX, NOFOLLOW">
<link href='/dist/main.css' rel='stylesheet' type="text/css" /><script src="/js/chart.js"></script>
<style>
img.avatar {
width: 32px;
display: inline;
}
</style>
<meta property="og:title" content="" />
<meta property="og:description" content="" />
<meta property="og:type" content="article" />
<meta property="og:url" content="https://jenkins-zh.github.io/event/wuhang/" />
<meta itemprop="name" content="">
<meta itemprop="description" content="">
<meta itemprop="wordCount" content="0">
<meta itemprop="keywords" content="" />
<meta name="twitter:card" content="summary"/>
<meta name="twitter:title" content=""/>
<meta name="twitter:description" content=""/>
</head>
<body class="ma0 sans-serif bg-primary-color-light">
<nav class="bg-primary-color-dark pv4 w-100" role="navigation">
<div class="center flex-ns flex-wrap items-center justify-start mw9">
<h1 class="dim f3 lh-solid ml0-ns mr0 mr4-l mv0 pl3 pl4-ns">
<a href="https://jenkins-zh.github.io/" class="link white">
Jenkins 中文社区
</a>
</h1>
<ul class="list ma0 pa0 dn dib-l">
<li class="f5 dib mr4" role="menuitem">
<a href="/wechat/" class="dim link light-silver"
>
微信
</a>
</li>
<li class="f5 dib mr4" role="menuitem">
<a href="/event/" class="dim link light-silver"
>
活动
</a>
</li>
<li class="f5 dib mr4" role="menuitem">
<a href="/about/" class="dim link light-silver"
>
关于我们
</a>
</li>
<li class="f5 dib mr4" role="menuitem">
<a href="http://jenkins.io/zh" class="dim link light-silver"
target="_blank">
Jenkins 官网
<svg version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" width="10" height="10" viewBox="0 0 32 32" class="fill-current v-base" aria-label="External Link">
<path d="M25.152 16.576v5.696q0 2.144-1.504 3.648t-3.648 1.504h-14.848q-2.144 0-3.648-1.504t-1.504-3.648v-14.848q0-2.112 1.504-3.616t3.648-1.536h12.576q0.224 0 0.384 0.16t0.16 0.416v1.152q0 0.256-0.16 0.416t-0.384 0.16h-12.576q-1.184 0-2.016 0.832t-0.864 2.016v14.848q0 1.184 0.864 2.016t2.016 0.864h14.848q1.184 0 2.016-0.864t0.832-2.016v-5.696q0-0.256 0.16-0.416t0.416-0.16h1.152q0.256 0 0.416 0.16t0.16 0.416zM32 1.152v9.12q0 0.48-0.352 0.8t-0.8 0.352-0.8-0.352l-3.136-3.136-11.648 11.648q-0.16 0.192-0.416 0.192t-0.384-0.192l-2.048-2.048q-0.192-0.16-0.192-0.384t0.192-0.416l11.648-11.648-3.136-3.136q-0.352-0.352-0.352-0.8t0.352-0.8 0.8-0.352h9.12q0.48 0 0.8 0.352t0.352 0.8z"></path>
</svg>
</a>
</li>
</ul>
<div class="db dib-ns pl3"><form id="site-search-form" action="" role="search">
<fieldset class="bn ma0 pa0">
<label class="clip" for="email-address">Search</label>
<input type="search" id="search-input" class="needs-js bg-left bg-transparent bn f5 input-reset lh-solid mt3 mt0-ns pl4 pv2 w5 white"
placeholder="搜索文档" type="text"
name="email-address" value="" style="background-image:url('/images/icon-search.png');background-size:16px 16px;">
</fieldset>
</form>
</div>
<div class="list ma0 pa0 dn dib-l"></div>
<span class="absolute mt1 mt2-l pr3 right-0 top-0">
<a class="github-button needs-js link primary-color-dark" href="https://github.com/jenkins-zh/jenkins-zh/" data-size="large" data-show-count="false" aria-label="Star Jenkins WeChat GitHub">Star</a>
</span>
</div>
</nav>
<main role="main" class="content-with-sidebar min-vh-100 pb7 pb0-ns">
<main style="background: #f5f5f5">
<style>
.topic {
display: flex;
margin: 20px auto;
max-width: 1000px;
padding: 20px;
background-color: #fff;
}
.topic .detail {
margin-left: 20px;
display: flex;
flex-direction: column;
}
.topic .detail .title {
color: #898989;
}
.topic-detail {
margin: 20px auto;
max-width: 1000px;
padding: 20px;
background-color: #fff;
}
.topic-title {
border-bottom: 1px solid #ddd;
padding: 10px;
display: flex;
border-left: 5px solid #1b809e;
}
.guest {
display: flex;
}
.guest img {
width: 100px;
height: 100px;
}
.guest-detail {
margin: 0 20px
}
.job-title {
color: #777;
font-size: 12px;
}
.schedule-content::after {
position: absolute;
top: 10px;
left: 2px;
content: '';
display: block;
width: 2px;
height: 100%;
background-color: rgba(31,99,175,0.5);
z-index: 0;
}
.schedule-content {
padding-bottom: 32px;
position: relative;
display: table;
clear: both;
width: 100%;
padding-left: 20px;
}
.schedule-timeline::after {
position: absolute;
left: 0;
top:8px;
content: '';
display: block;
width: 7px;
height: 7px;
border-radius: 1px;
-ms-transform: rotate(45deg);
transform: rotate(45deg);
background-color: #1b809e;
z-index: 1;
}
</style>
<div class="topic">
<div>
<img width="320px" height="160px" src="/images/meetup/hacktberfest.jpg" alt>
</div>
<div class="detail">
<h4></h4>
<div>
<span class="title">状态:</span>
<span></span>
</div>
<div>
<span class="title">时间:</span>
<span></span>
</div>
<div>
<span class="title">地点:</span>
<span></span>
</div>
<div>
<span class="title">费用:</span>
<span></span>
</div>
</div>
</div>
<div class="topic-detail">
<h4 class="topic-title">主题介绍</h4>
<div>
</div>
</div>
<div class="topic-detail">
<h4 class="topic-title">嘉宾介绍</h4>
<div>
</div>
</div>
<div class="topic-detail">
<h4 class="topic-title">活动安排</h4>
<div>
敬请期待
</div>
</div>
<div class="topic-detail">
<h4 class="topic-title">注意事项</h4>
<div>
</div>
</div>
</main>
</main>
<footer class="bg-primary-color-dark ph4-ns pt4 relative w-100" role="contentinfo">
<div class="center flex-ns flex-wrap justify-between mw9 w-90">
<div class="pb3 pt4 w-100 w-50-ns">
<div class="b f3 light-gray mb3 nested-links tc">
<a href="https://github.com/jenkins-zh/jenkins-zh/graphs/contributors" target="_blank" class="link">Jenkins 社区贡献者</a> 维护<br/>
</div>
<ul class="center f6 list ma0 mv3 pa0 tc" style="display:none"><li class="dib mr3"><a href="https://github.com/jenkins-zh/jenkins-zh/issues/new" class="dim link light-gray pv2">File an Issue</a></li></ul>
<ul class="center f6 list ma0 mv4 pa0 tc">
<li class="dib mr3">
<a href="https://twitter.com/suren69811254" target="_blank" class="dim link light-gray pv2">@suren69811254</a>
</li>
<li class="dib mr3">
<a href="https://www.youtube.com/channel/UC63xz3pq26BBgwB3cnwCoqQ" target="_blank" class="dim link light-gray pv2">YouTube</a>
</li>
</ul>
</div>
<div>
<a href="https://mp.weixin.qq.com/s/vifdduC3kRGSIMpyL03yVA" target="_blank">
<img src="https://jenkins.io/images/jenkins-wechat.png" with="100" height="100">
</a>
</div>
</div>
<div class="f7 gray mb5 mb0-ns ph3 w-100" style="display:none"> 
<p class="dib mr4">Jenkins&reg; is a registered trademark of <a href="https://www.spi-inc.org/" class="link">Software in the Public Interest, Inc.</a></p>
<p class="dib">Copyright 2018–2019 the original authors.</p>
</div>
<div class="bg-primary-color-dark bottom-0 left-0 right-0 dn-l fixed pb3 ph3 w-100"><div class="globalmenu mobilemenu pb3 dn">
<ul class="list hidden dib ph0 ma0 scrolling-touch tc">
<li class="tl dib ma0 hover-bg-black w-100">
<a href="/wechat/" class="ttu f6 link primary-color-light overflow hover-white db brand-font ma0 w-100 pv3 ph4">
微信
</a>
</li>
<li class="tl dib ma0 hover-bg-black w-100">
<a href="/event/" class="ttu f6 link primary-color-light overflow hover-white db brand-font ma0 w-100 pv3 ph4">
活动
</a>
</li>
<li class="tl dib ma0 hover-bg-black w-100">
<a href="/about/" class="ttu f6 link primary-color-light overflow hover-white db brand-font ma0 w-100 pv3 ph4">
关于我们
</a>
</li>
<li class="tl dib ma0 hover-bg-black w-100">
<a href="http://jenkins.io/zh" class="ttu f6 link primary-color-light overflow hover-white db brand-font ma0 w-100 pv3 ph4">
Jenkins 官网
</a>
</li>
</ul>
</div>
<div class="docsmenu mobilemenu pb3 dn">
<ul class="list dib ph0 ma0 scrolling-touch tc">
</ul>
</div>
<div class="flex dn-l justify-between">
<button class="js-toggle flex-auto dib dn-l f6 tc db mt4-ns ph3 pv2 link mr2 white bg-primary-color-dark hover-bg-primary-color ba b--white-40 w-auto" data-target=".globalmenu">Menu</button>
<button class="js-toggle flex-auto dib dn-l f6 tc db mt4-ns ph3 pv2 link white bg-primary-color-dark hover-bg-primary-color ba b--white-40 w-auto" data-target=".docsmenu">Docs Menu</button>
</div>
</div>
</footer>
<link href="/dist/auto-complete.css" rel="stylesheet">
<script type="text/javascript">
var baseurl = "https:\/\/jenkins-zh.github.io\/";
</script>
<script src="/dist/lunr.js"></script>
<script src="/dist/autocomplete.js"></script>
<script src="/dist/jquery-3.2.1.min.js"></script>
<script src="/dist/search.js"></script>
<script async defer src="https://buttons.github.io/buttons.js"></script>
</body>
</html>
......@@ -33,7 +33,7 @@
<meta property="og:description" content="" />
<meta property="og:type" content="website" />
<meta property="og:url" content="https://jenkins-zh.github.io/" />
<meta property="og:updated_time" content="2019-02-20T00:00:00&#43;00:00"/>
<meta property="og:updated_time" content="2019-02-27T00:00:00&#43;00:00"/>
<meta itemprop="name" content="Jenkins 中文社区">
<meta itemprop="description" content="">
......@@ -156,7 +156,7 @@
<main role="main" class="content-with-sidebar min-vh-100 pb7 pb0-ns">
<section class="w-100 min-vh-100 ph4 ph5-ns pt4 pb5 mid-gray bg-primary-color-light bb bt b--light-gray "><div class="w-100 center pt5">
<section class="w-100 ph4 ph5-ns pt4 pb5 mid-gray bg-primary-color-light bb bt b--light-gray "><div class="w-100 center pt5">
<div class="w-100 w-40-l tc center">
<img src="/images/GitHub-Mark-64px.png" alt="Github Logo" class="tc center">
</div>
......@@ -231,6 +231,59 @@
</div>
</section>
<section class="w-100 ph4 ph5-ns pt4 pb5 mid-gray bg-primary-color-light bb bt b--light-gray "><section class="bg-near-white mid-gray pb5 ph4 ph5-ns pt4 w-100">
<h3 class="black f1 fw4 lh-title ma0 pb3 pt0-l pt4">最新活动</h3>
<div class="w-100">
<div class="w-100 overflow-x-scroll">
<div class="row nowrap mv2 pb1">
<a href="/event/shenzhen/" class="tile lazyload cover dib f4 ml1 mr4 bg-black relative mw-100 shadow-5">
<img width="400px" height="200px" src="/images/meetup/shenzhen.jpeg"></img>
</a>
<a href="/event/wuhang/" class="tile lazyload cover dib f4 ml1 mr4 bg-black relative mw-100 shadow-5">
<img width="400px" height="200px" src="/images/meetup/hacktberfest.jpg"></img>
</a>
<a href="/event/hangzhou-2019-05/" class="tile lazyload cover dib f4 ml1 mr4 bg-black relative mw-100 shadow-5">
<img width="400px" height="200px" src="/images/meetup/hangzhou.jpeg"></img>
</a>
<a href="/event/shanghai-2019-06/" class="tile lazyload cover dib f4 ml1 mr4 bg-black relative mw-100 shadow-5">
<img width="400px" height="200px" src="/images/meetup/shanghai.jpeg"></img>
</a>
<a href="/event/beijing-2019-11/" class="tile lazyload cover dib f4 ml1 mr4 bg-black relative mw-100 shadow-5">
<img width="400px" height="200px" src="/images/meetup/hacktberfest.jpg"></img>
</a>
</div>
</div>
</div>
<div class="flex w-100 mt4 justify-end">
<a href="/event/" class="br2 f6 bg-primary-color-dark hover-bg-primary-color link ph3 pv2 ttu white">查看全部</a>
</div>
</section>
</section>
</main>
<footer class="bg-primary-color-dark ph4-ns pt4 relative w-100" role="contentinfo">
......
......@@ -6,6 +6,13 @@
"description": "行为规范",
"content": " 留言 留言之前需要使用 GitHub 账号登陆。大家要注意文明用语,严禁攻击、诋毁、灌水、广告等无关的话。对于违反人,一经发现将会被拉入黑名单。\n提问 欢迎每一位朋友在这里提出与 Jenkins 或相关领域的技术问题,但是,在提问之前建议先在搜索引擎和本站中进行搜索。\n问题至少要包含如下部分:\n 场景以及问题是如何发生的,方便阅读的人复现 软件、环境相关版本信息 日志、截图等(建议使用附件的方式) 出于对回答问题者的尊重,请得到解决方案后及时表示感谢,或者从其他地方得到答案后添加相关链接以及说明。\nGitHub 请您使用同一个 GitHub 账号来与大家交流,不欢迎使用所谓的“小号”。\n"
},
{
"uri": "https://jenkins-zh.github.io/wechat/articles/2019-02-27-jenkins-script-console-in-practice/",
"title": "批量修改 Jenkins 任务的技巧",
"tags": ["Jenkins"],
"description": "Jenkins 脚本命令行的一种实践",
"content": " 通过脚本命令行批量修改 Jenkins 任务 最近,笔者所在团队的 Jenkins 所在的服务器经常报硬盘空间不足。经查发现很多任务没有设置“丢弃旧的构建”。通知所有的团队检查自己的 Jenkins 任务有没有设置丢弃旧的构建,有些不现实。\n一开始想到的是使用 Jenkins 的 API 来实现批量修改所有的 Jenkins 任务。笔者对这个解决方案不满意,经 Google 发现有同学和我遇到了同样的问题。他使用的更“技巧”的方式:在 Jenkins 脚本命令行中,通过执行 Groovy 代码操作 Jenkins 任务。\n总的来说,就两步:\n 进入菜单:系统管理 \u0026ndash;\u0026gt; 脚本命令行 在输入框中,粘贴如下代码:\nimport jenkins.model.Jenkins import hudson.model.Job import jenkins.model.BuildDiscarderProperty import hudson.tasks.LogRotator // 遍历所有的任务 Jenkins.instance.allItems(Job).each { job -\u0026gt; if ( job.isBuildable() \u0026amp;\u0026amp; job.supportsLogRotator() \u0026amp;\u0026amp; job.getProperty(BuildDiscarderProperty) == null) { println \u0026quot; \\\u0026quot;${job.fullDisplayName}\\\u0026quot; 处理中\u0026quot; job.addProperty(new BuildDiscarderProperty(new LogRotator (2, 10, 2, 10))) println \u0026quot;$job.name 已更新\u0026quot; } } return; /** LogRotator构造参数分别为: daysToKeep: If not -1, history is only kept up to this days. numToKeep: If not -1, only this number of build logs are kept. artifactDaysToKeep: If not -1 nor null, artifacts are only kept up to this days. artifactNumToKeep: If not -1 nor null, only this number of builds have their artifacts kept. **/ 脚本命令行介绍 脚本命令行(Jenkins Script Console),它是 Jenkins 的一个特性,允许你在 Jenkins master 和 Jenkins agent 的运行时环境执行任意的 Groovy 脚本。这意味着,我们可以在脚本命令行中做任何的事情,包括关闭 Jenkins,执行操作系统命令 rm -rf /(所以不能使用 root 用户运行 Jenkins agent)等危险操作。\n除了上文中的,使用界面来执行 Groovy 脚本,还可以通过 Jenkins HTTP API:/script执行。具体操作,请参考 官方文档。\n问题:代码执行完成后,对任务的修改有没有被持久化? 当我们代码job.addProperty(new BuildDiscarderProperty(new LogRotator (2, 10, 2, 10)))执行后,这个修改到底有没有持久化到文件系统中呢(Jenkins 的所有配置默认都持久化在文件系统中)?我们看下 hudson.model.Job 的源码,在addProperty方法背后是有进行持久化的:\npublic void addProperty(JobProperty\u0026lt;? super JobT\u0026gt; jobProp) throws IOException { ((JobProperty)jobProp).setOwner(this); properties.add(jobProp); save(); } 小结 本文章只介绍了批量修改“丢弃旧的构建”的配置,如果还希望修改其它配置,可以参考 hudson.model.Job 源码。\n不得不提醒读者朋友,Jenkins 脚本命令行是一把双刃剑,大家操作前,请考虑清楚影响范围。如果有必要,请提前做好备份。\n"
},
{
"uri": "https://jenkins-zh.github.io/wechat/articles/2019-02-20-java11-preview-availability/",
"title": "Java 11 预览支持已在 Jenkins 2.155+ 中可用",
......@@ -83,6 +90,13 @@
"description": "",
"content": ""
},
{
"uri": "https://jenkins-zh.github.io/event/wuhang/",
"title": "",
"tags": [],
"description": "",
"content": ""
},
{
"uri": "https://jenkins-zh.github.io/sponsor/alauda/",
"title": "",
......
......@@ -6,7 +6,7 @@
<description>Recent content on Jenkins 中文社区</description>
<generator>Hugo -- gohugo.io</generator>
<language>zh-CN</language>
<lastBuildDate>Wed, 20 Feb 2019 00:00:00 +0000</lastBuildDate>
<lastBuildDate>Wed, 27 Feb 2019 00:00:00 +0000</lastBuildDate>
<atom:link href="https://jenkins-zh.github.io/index.xml" rel="self" type="application/rss+xml" />
......@@ -24,6 +24,19 @@
GitHub 请您使用同一个 GitHub 账号来与大家交流,不欢迎使用所谓的“小号”。</description>
</item>
<item>
<title>批量修改 Jenkins 任务的技巧</title>
<link>https://jenkins-zh.github.io/wechat/articles/2019-02-27-jenkins-script-console-in-practice/</link>
<pubDate>Wed, 27 Feb 2019 00:00:00 +0000</pubDate>
<guid>https://jenkins-zh.github.io/wechat/articles/2019-02-27-jenkins-script-console-in-practice/</guid>
<description>通过脚本命令行批量修改 Jenkins 任务 最近,笔者所在团队的 Jenkins 所在的服务器经常报硬盘空间不足。经查发现很多任务没有设置“丢弃旧的构建”。通知所有的团队检查自己的 Jenkins 任务有没有设置丢弃旧的构建,有些不现实。
一开始想到的是使用 Jenkins 的 API 来实现批量修改所有的 Jenkins 任务。笔者对这个解决方案不满意,经 Google 发现有同学和我遇到了同样的问题。他使用的更“技巧”的方式:在 Jenkins 脚本命令行中,通过执行 Groovy 代码操作 Jenkins 任务。
总的来说,就两步:
进入菜单:系统管理 &amp;ndash;&amp;gt; 脚本命令行 在输入框中,粘贴如下代码:
import jenkins.model.Jenkins import hudson.model.Job import jenkins.model.BuildDiscarderProperty import hudson.tasks.LogRotator // 遍历所有的任务 Jenkins.instance.allItems(Job).each { job -&amp;gt; if ( job.isBuildable() &amp;amp;&amp;amp; job.supportsLogRotator() &amp;amp;&amp;amp; job.getProperty(BuildDiscarderProperty) == null) { println &amp;quot; \&amp;quot;${job.fullDisplayName}\&amp;quot; 处理中&amp;quot; job.addProperty(new BuildDiscarderProperty(new LogRotator (2, 10, 2, 10))) println &amp;quot;$job.name 已更新&amp;quot; } } return; /** LogRotator构造参数分别为: daysToKeep: If not -1, history is only kept up to this days.</description>
</item>
<item>
<title>Java 11 预览支持已在 Jenkins 2.155&#43; 中可用</title>
<link>https://jenkins-zh.github.io/wechat/articles/2019-02-20-java11-preview-availability/</link>
......@@ -127,6 +140,15 @@ Jenkins 的 简体中文语言插件 也热切地期待你的 Pull Request 。
<description></description>
</item>
<item>
<title></title>
<link>https://jenkins-zh.github.io/event/wuhang/</link>
<pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate>
<guid>https://jenkins-zh.github.io/event/wuhang/</guid>
<description></description>
</item>
<item>
<title></title>
<link>https://jenkins-zh.github.io/sponsor/alauda/</link>
......
......@@ -6,6 +6,11 @@
<loc>https://jenkins-zh.github.io/about/code-of-conduct/</loc>
</url>
<url>
<loc>https://jenkins-zh.github.io/wechat/articles/2019-02-27-jenkins-script-console-in-practice/</loc>
<lastmod>2019-02-27T00:00:00+00:00</lastmod>
</url>
<url>
<loc>https://jenkins-zh.github.io/wechat/articles/2019-02-20-java11-preview-availability/</loc>
<lastmod>2019-02-20T00:00:00+00:00</lastmod>
......@@ -55,6 +60,10 @@
<loc>https://jenkins-zh.github.io/event/shenzhen/</loc>
</url>
<url>
<loc>https://jenkins-zh.github.io/event/wuhang/</loc>
</url>
<url>
<loc>https://jenkins-zh.github.io/sponsor/alauda/</loc>
</url>
......@@ -122,6 +131,7 @@
<url>
<loc>https://jenkins-zh.github.io/tags/jenkins/</loc>
<lastmod>2019-02-27T00:00:00+00:00</lastmod>
<priority>0</priority>
</url>
......@@ -140,7 +150,7 @@
<url>
<loc>https://jenkins-zh.github.io/</loc>
<lastmod>2019-02-20T00:00:00+00:00</lastmod>
<lastmod>2019-02-27T00:00:00+00:00</lastmod>
<priority>0</priority>
</url>
......@@ -246,7 +256,7 @@
<url>
<loc>https://jenkins-zh.github.io/wechat/</loc>
<lastmod>2019-02-20T00:00:00+00:00</lastmod>
<lastmod>2019-02-27T00:00:00+00:00</lastmod>
<priority>0</priority>
</url>
......
......@@ -162,6 +162,7 @@
<section class="flex-ns flex-wrap justify-between w-100">
<div class="relative weight-0">
<div class="bg-white mb2 pa3 pa4-l gray">
......@@ -186,7 +187,9 @@
</div>
</div>
<div class="relative weight-0">
<div class="bg-white mb2 pa3 pa4-l gray">
......@@ -211,7 +214,9 @@
</div>
</div>
<div class="relative weight-0">
<div class="bg-white mb2 pa3 pa4-l gray">
......@@ -236,6 +241,7 @@
</div>
</div>
</section>
</div>
......
......@@ -163,6 +163,7 @@
<section class="flex-ns flex-wrap justify-between w-100">
<div class="relative weight-0">
<div class="bg-white mb2 pa3 pa4-l gray">
......@@ -187,7 +188,9 @@
</div>
</div>
<div class="relative weight-0">
<div class="bg-white mb2 pa3 pa4-l gray">
......@@ -212,7 +215,9 @@
</div>
</div>
<div class="relative weight-0">
<div class="bg-white mb2 pa3 pa4-l gray">
......@@ -237,6 +242,7 @@
</div>
</div>
</section>
</div>
......
......@@ -162,6 +162,7 @@
<section class="flex-ns flex-wrap justify-between w-100">
<div class="relative weight-0">
<div class="bg-white mb2 pa3 pa4-l gray">
......@@ -186,6 +187,7 @@
</div>
</div>
</section>
</div>
......
......@@ -163,6 +163,7 @@
<section class="flex-ns flex-wrap justify-between w-100">
<div class="relative weight-0">
<div class="bg-white mb2 pa3 pa4-l gray">
......@@ -187,7 +188,9 @@
</div>
</div>
<div class="relative weight-0">
<div class="bg-white mb2 pa3 pa4-l gray">
......@@ -212,7 +215,9 @@
</div>
</div>
<div class="relative weight-0">
<div class="bg-white mb2 pa3 pa4-l gray">
......@@ -237,6 +242,7 @@
</div>
</div>
</section>
</div>
......
......@@ -163,6 +163,7 @@
<section class="flex-ns flex-wrap justify-between w-100">
<div class="relative weight-0">
<div class="bg-white mb2 pa3 pa4-l gray">
......@@ -187,6 +188,7 @@
</div>
</div>
</section>
</div>
......
......@@ -162,6 +162,7 @@
<section class="flex-ns flex-wrap justify-between w-100">
<div class="relative weight-0">
<div class="bg-white mb2 pa3 pa4-l gray">
......@@ -186,7 +187,9 @@
</div>
</div>
<div class="relative weight-0">
<div class="bg-white mb2 pa3 pa4-l gray">
......@@ -211,6 +214,7 @@
</div>
</div>
</section>
</div>
......
......@@ -162,6 +162,7 @@
<section class="flex-ns flex-wrap justify-between w-100">
<div class="relative weight-0">
<div class="bg-white mb2 pa3 pa4-l gray">
......@@ -186,6 +187,7 @@
</div>
</div>
</section>
</div>
......
......@@ -331,6 +331,12 @@
</a>
</h2>
<h3>
<a href="https://jenkins-zh.github.io/wechat/articles/2019-02-27-jenkins-script-console-in-practice/" class="link blue">
批量修改 Jenkins 任务的技巧
</a>
</h3>
<h3>
<a href="https://jenkins-zh.github.io/wechat/articles/2019-01-16-webhook-firewalls/" class="link blue">
在安全防火墙内通过 WebHook 触发构建
......
......@@ -86,7 +86,7 @@
<item>
<title>Jenkins</title>
<link>https://jenkins-zh.github.io/tags/jenkins/</link>
<pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate>
<pubDate>Wed, 27 Feb 2019 00:00:00 +0000</pubDate>
<guid>https://jenkins-zh.github.io/tags/jenkins/</guid>
<description></description>
......
......@@ -163,6 +163,7 @@
<section class="flex-ns flex-wrap justify-between w-100">
<div class="relative weight-0">
<div class="bg-white mb2 pa3 pa4-l gray">
......@@ -187,6 +188,7 @@
</div>
</div>
</section>
</div>
......
......@@ -162,6 +162,7 @@
<section class="flex-ns flex-wrap justify-between w-100">
<div class="relative weight-0">
<div class="bg-white mb2 pa3 pa4-l gray">
......@@ -186,6 +187,7 @@
</div>
</div>
</section>
</div>
......
......@@ -32,6 +32,7 @@
<meta property="og:description" content="" />
<meta property="og:type" content="website" />
<meta property="og:url" content="https://jenkins-zh.github.io/tags/jenkins/" />
<meta property="og:updated_time" content="2019-02-27T00:00:00&#43;00:00"/>
<meta itemprop="name" content="Jenkins">
<meta itemprop="description" content="">
......@@ -162,6 +163,9 @@
<section class="flex-ns flex-wrap justify-between w-100">
<div class="relative weight-0">
<div class="bg-white mb2 pa3 pa4-l gray">
......@@ -186,6 +190,7 @@
</div>
</div>
</section>
</div>
......
......@@ -6,10 +6,24 @@
<description>Recent content in Jenkins on Jenkins 中文社区</description>
<generator>Hugo -- gohugo.io</generator>
<language>zh-CN</language>
<lastBuildDate>Wed, 27 Feb 2019 00:00:00 +0000</lastBuildDate>
<atom:link href="https://jenkins-zh.github.io/tags/jenkins/index.xml" rel="self" type="application/rss+xml" />
<item>
<title>批量修改 Jenkins 任务的技巧</title>
<link>https://jenkins-zh.github.io/wechat/articles/2019-02-27-jenkins-script-console-in-practice/</link>
<pubDate>Wed, 27 Feb 2019 00:00:00 +0000</pubDate>
<guid>https://jenkins-zh.github.io/wechat/articles/2019-02-27-jenkins-script-console-in-practice/</guid>
<description>通过脚本命令行批量修改 Jenkins 任务 最近,笔者所在团队的 Jenkins 所在的服务器经常报硬盘空间不足。经查发现很多任务没有设置“丢弃旧的构建”。通知所有的团队检查自己的 Jenkins 任务有没有设置丢弃旧的构建,有些不现实。
一开始想到的是使用 Jenkins 的 API 来实现批量修改所有的 Jenkins 任务。笔者对这个解决方案不满意,经 Google 发现有同学和我遇到了同样的问题。他使用的更“技巧”的方式:在 Jenkins 脚本命令行中,通过执行 Groovy 代码操作 Jenkins 任务。
总的来说,就两步:
进入菜单:系统管理 &amp;ndash;&amp;gt; 脚本命令行 在输入框中,粘贴如下代码:
import jenkins.model.Jenkins import hudson.model.Job import jenkins.model.BuildDiscarderProperty import hudson.tasks.LogRotator // 遍历所有的任务 Jenkins.instance.allItems(Job).each { job -&amp;gt; if ( job.isBuildable() &amp;amp;&amp;amp; job.supportsLogRotator() &amp;amp;&amp;amp; job.getProperty(BuildDiscarderProperty) == null) { println &amp;quot; \&amp;quot;${job.fullDisplayName}\&amp;quot; 处理中&amp;quot; job.addProperty(new BuildDiscarderProperty(new LogRotator (2, 10, 2, 10))) println &amp;quot;$job.name 已更新&amp;quot; } } return; /** LogRotator构造参数分别为: daysToKeep: If not -1, history is only kept up to this days.</description>
</item>
<item>
<title>在安全防火墙内通过 WebHook 触发构建</title>
<link>https://jenkins-zh.github.io/wechat/articles/2019-01-16-webhook-firewalls/</link>
......
......@@ -162,6 +162,7 @@
<section class="flex-ns flex-wrap justify-between w-100">
<div class="relative weight-0">
<div class="bg-white mb2 pa3 pa4-l gray">
......@@ -186,7 +187,9 @@
</div>
</div>
<div class="relative weight-0">
<div class="bg-white mb2 pa3 pa4-l gray">
......@@ -211,7 +214,9 @@
</div>
</div>
<div class="relative weight-0">
<div class="bg-white mb2 pa3 pa4-l gray">
......@@ -236,7 +241,9 @@
</div>
</div>
<div class="relative weight-0">
<div class="bg-white mb2 pa3 pa4-l gray">
......@@ -261,6 +268,7 @@
</div>
</div>
</section>
</div>
......
......@@ -162,6 +162,7 @@
<section class="flex-ns flex-wrap justify-between w-100">
<div class="relative weight-0">
<div class="bg-white mb2 pa3 pa4-l gray">
......@@ -186,7 +187,9 @@
</div>
</div>
<div class="relative weight-0">
<div class="bg-white mb2 pa3 pa4-l gray">
......@@ -211,7 +214,9 @@
</div>
</div>
<div class="relative weight-0">
<div class="bg-white mb2 pa3 pa4-l gray">
......@@ -236,7 +241,9 @@
</div>
</div>
<div class="relative weight-0">
<div class="bg-white mb2 pa3 pa4-l gray">
......@@ -261,6 +268,7 @@
</div>
</div>
</section>
</div>
......
......@@ -162,6 +162,7 @@
<section class="flex-ns flex-wrap justify-between w-100">
<div class="relative weight-0">
<div class="bg-white mb2 pa3 pa4-l gray">
......@@ -186,6 +187,7 @@
</div>
</div>
</section>
</div>
......
......@@ -163,6 +163,7 @@
<section class="flex-ns flex-wrap justify-between w-100">
<div class="relative weight-0">
<div class="bg-white mb2 pa3 pa4-l gray">
......@@ -187,6 +188,7 @@
</div>
</div>
</section>
</div>
......
......@@ -163,6 +163,7 @@
<section class="flex-ns flex-wrap justify-between w-100">
<div class="relative weight-0">
<div class="bg-white mb2 pa3 pa4-l gray">
......@@ -187,6 +188,7 @@
</div>
</div>
</section>
</div>
......
......@@ -162,6 +162,7 @@
<section class="flex-ns flex-wrap justify-between w-100">
<div class="relative weight-0">
<div class="bg-white mb2 pa3 pa4-l gray">
......@@ -186,6 +187,7 @@
</div>
</div>
</section>
</div>
......
......@@ -162,6 +162,7 @@
<section class="flex-ns flex-wrap justify-between w-100">
<div class="relative weight-0">
<div class="bg-white mb2 pa3 pa4-l gray">
......@@ -186,6 +187,7 @@
</div>
</div>
</section>
</div>
......
......@@ -163,6 +163,7 @@
<section class="flex-ns flex-wrap justify-between w-100">
<div class="relative weight-0">
<div class="bg-white mb2 pa3 pa4-l gray">
......@@ -187,6 +188,7 @@
</div>
</div>
</section>
</div>
......
......@@ -162,6 +162,7 @@
<section class="flex-ns flex-wrap justify-between w-100">
<div class="relative weight-0">
<div class="bg-white mb2 pa3 pa4-l gray">
......@@ -186,6 +187,7 @@
</div>
</div>
</section>
</div>
......
......@@ -162,6 +162,7 @@
<section class="flex-ns flex-wrap justify-between w-100">
<div class="relative weight-0">
<div class="bg-white mb2 pa3 pa4-l gray">
......@@ -186,6 +187,7 @@
</div>
</div>
</section>
</div>
......
......@@ -162,6 +162,7 @@
<section class="flex-ns flex-wrap justify-between w-100">
<div class="relative weight-0">
<div class="bg-white mb2 pa3 pa4-l gray">
......@@ -186,7 +187,9 @@
</div>
</div>
<div class="relative weight-0">
<div class="bg-white mb2 pa3 pa4-l gray">
......@@ -211,6 +214,7 @@
</div>
</div>
</section>
</div>
......
......@@ -162,6 +162,7 @@
<section class="flex-ns flex-wrap justify-between w-100">
<div class="relative weight-0">
<div class="bg-white mb2 pa3 pa4-l gray">
......@@ -186,6 +187,7 @@
</div>
</div>
</section>
</div>
......
......@@ -162,6 +162,7 @@
<section class="flex-ns flex-wrap justify-between w-100">
<div class="relative weight-0">
<div class="bg-white mb2 pa3 pa4-l gray">
......@@ -186,6 +187,7 @@
</div>
</div>
</section>
</div>
......
......@@ -162,6 +162,7 @@
<section class="flex-ns flex-wrap justify-between w-100">
<div class="relative weight-0">
<div class="bg-white mb2 pa3 pa4-l gray">
......@@ -186,6 +187,7 @@
</div>
</div>
</section>
</div>
......
......@@ -425,6 +425,19 @@ f6 ph3 pv1 br2 dib tc ttu mv3 bg-primary-color white hover-bg-green link
<li class="db dib-l mb2 mr3">
<a href="/wechat/articles/2019-02-27-jenkins-script-console-in-practice/" class="link">
批量修改 Jenkins 任务的技巧
</a>
</li>
<li class="db b mt4 mb2 mr2">
Related entries:
</li>
</ul>
</div>
......
......@@ -186,6 +186,14 @@
</a>
<a href="https://jenkins-zh.github.io/wechat/articles/2019-02-27-jenkins-script-console-in-practice/" class="dib f6 pl1 hover-bg-light-gray br-100" title="批量修改 Jenkins 任务的技巧 ">
<svg class="fill-current" height="30px" viewBox="0 0 24 24" width="30px" xmlns="http://www.w3.org/2000/svg">
<path d="M15.41 7.41L14 6l-6 6 6 6 1.41-1.41L10.83 12z"/>
<path d="M0 0h24v24H0z" fill="none"/>
</svg>
</a>
<a href="https://jenkins-zh.github.io/wechat/articles/2019-02-13-outreachy-audit-log-plugin/" class="dib f6 pr1 hover-bg-light-gray br-100" title="Jenkins 对审计日志的支持">
......
<!DOCTYPE html>
<html class="no-js" lang="zh-CN">
<head>
<meta charset="utf-8">
<link rel="preload" href="https://jenkins-zh.github.io/files/muli-latin-200.woff2" as="font" type="font/woff2" crossorigin>
<link rel="preload" href="https://jenkins-zh.github.io/files/muli-latin-400.woff2" as="font" type="font/woff2" crossorigin>
<link rel="preload" href="https://jenkins-zh.github.io/files/muli-latin-800.woff2" as="font" type="font/woff2" crossorigin>
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<title>批量修改 Jenkins 任务的技巧 | Jenkins 中文社区</title>
<meta name="HandheldFriendly" content="True">
<meta name="MobileOptimized" content="320">
<meta name="viewport" content="width=device-width,minimum-scale=1">
<meta name="generator" content="Hugo 0.52" />
<META NAME="ROBOTS" CONTENT="NOINDEX, NOFOLLOW">
<link href='/dist/main.css' rel='stylesheet' type="text/css" /><script src="/js/chart.js"></script>
<style>
img.avatar {
width: 32px;
display: inline;
}
</style>
<meta property="og:title" content="批量修改 Jenkins 任务的技巧" />
<meta property="og:description" content="Jenkins 脚本命令行的一种实践" />
<meta property="og:type" content="article" />
<meta property="og:url" content="https://jenkins-zh.github.io/wechat/articles/2019-02-27-jenkins-script-console-in-practice/" /><meta property="article:published_time" content="2019-02-27T00:00:00&#43;00:00"/>
<meta property="article:modified_time" content="2019-02-27T00:00:00&#43;00:00"/>
<meta itemprop="name" content="批量修改 Jenkins 任务的技巧">
<meta itemprop="description" content="Jenkins 脚本命令行的一种实践">
<meta itemprop="datePublished" content="2019-02-27T00:00:00&#43;00:00" />
<meta itemprop="dateModified" content="2019-02-27T00:00:00&#43;00:00" />
<meta itemprop="wordCount" content="184">
<meta itemprop="keywords" content="Jenkins," />
<meta name="twitter:card" content="summary"/>
<meta name="twitter:title" content="批量修改 Jenkins 任务的技巧"/>
<meta name="twitter:description" content="Jenkins 脚本命令行的一种实践"/>
</head>
<body class="ma0 sans-serif bg-primary-color-light">
<nav class="bg-primary-color-dark pv4 w-100" role="navigation">
<div class="center flex-ns flex-wrap items-center justify-start mw9">
<h1 class="dim f3 lh-solid ml0-ns mr0 mr4-l mv0 pl3 pl4-ns">
<a href="https://jenkins-zh.github.io/" class="link white">
Jenkins 中文社区
</a>
</h1>
<ul class="list ma0 pa0 dn dib-l">
<li class="f5 dib mr4" role="menuitem">
<a href="/wechat/" class="dim link light-silver"
>
微信
</a>
</li>
<li class="f5 dib mr4" role="menuitem">
<a href="/event/" class="dim link light-silver"
>
活动
</a>
</li>
<li class="f5 dib mr4" role="menuitem">
<a href="/about/" class="dim link light-silver"
>
关于我们
</a>
</li>
<li class="f5 dib mr4" role="menuitem">
<a href="http://jenkins.io/zh" class="dim link light-silver"
target="_blank">
Jenkins 官网
<svg version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" width="10" height="10" viewBox="0 0 32 32" class="fill-current v-base" aria-label="External Link">
<path d="M25.152 16.576v5.696q0 2.144-1.504 3.648t-3.648 1.504h-14.848q-2.144 0-3.648-1.504t-1.504-3.648v-14.848q0-2.112 1.504-3.616t3.648-1.536h12.576q0.224 0 0.384 0.16t0.16 0.416v1.152q0 0.256-0.16 0.416t-0.384 0.16h-12.576q-1.184 0-2.016 0.832t-0.864 2.016v14.848q0 1.184 0.864 2.016t2.016 0.864h14.848q1.184 0 2.016-0.864t0.832-2.016v-5.696q0-0.256 0.16-0.416t0.416-0.16h1.152q0.256 0 0.416 0.16t0.16 0.416zM32 1.152v9.12q0 0.48-0.352 0.8t-0.8 0.352-0.8-0.352l-3.136-3.136-11.648 11.648q-0.16 0.192-0.416 0.192t-0.384-0.192l-2.048-2.048q-0.192-0.16-0.192-0.384t0.192-0.416l11.648-11.648-3.136-3.136q-0.352-0.352-0.352-0.8t0.352-0.8 0.8-0.352h9.12q0.48 0 0.8 0.352t0.352 0.8z"></path>
</svg>
</a>
</li>
</ul>
<div class="db dib-ns pl3"><form id="site-search-form" action="" role="search">
<fieldset class="bn ma0 pa0">
<label class="clip" for="email-address">Search</label>
<input type="search" id="search-input" class="needs-js bg-left bg-transparent bn f5 input-reset lh-solid mt3 mt0-ns pl4 pv2 w5 white"
placeholder="搜索文档" type="text"
name="email-address" value="" style="background-image:url('/images/icon-search.png');background-size:16px 16px;">
</fieldset>
</form>
</div>
<div class="list ma0 pa0 dn dib-l"></div>
<span class="absolute mt1 mt2-l pr3 right-0 top-0">
<a class="github-button needs-js link primary-color-dark" href="https://github.com/jenkins-zh/jenkins-zh/" data-size="large" data-show-count="false" aria-label="Star Jenkins WeChat GitHub">Star</a>
</span>
</div>
</nav>
<main role="main" class="content-with-sidebar min-vh-100 pb7 pb0-ns">
<main>
<article class="w-100 ph4 pb5 pb6-ns pt1 pt5-ns">
<div class="flex-l">
<div class="order-2 w-100 w-20-l ph5-m ph0-l mb4 sticky">
<aside class="mw5 br3 mv3 nested-links">
<h3 class="f4 dib">
翟志军
</h3>
<p class="lh-copy measure center mt0 f6 black-60">
show me the code
</p>
<a href="https://github.com/zacker330" target="_blank" class="link dim v-mid dib">
<svg version="1.1" fill="gray" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" width="16" height="18" viewBox="0 0 27 32">
<path d="M9.28 21.44q0.064-0.128-0.064-0.256-0.16-0.128-0.256-0.032-0.064 0.128 0.064 0.224 0.16 0.128 0.256 0.064zM8.768 20.704q-0.096-0.128-0.224-0.096-0.096 0.096 0 0.224 0.128 0.16 0.224 0.096t0-0.224zM8.032 19.968q0.032-0.064-0.096-0.128-0.128-0.032-0.128 0.032-0.064 0.096 0.064 0.16 0.16 0.032 0.16-0.064zM8.416 20.384q0.032 0 0.032-0.064t-0.064-0.096q-0.128-0.128-0.192-0.064t0.032 0.192q0.096 0.096 0.192 0.032zM9.952 21.728q0.032-0.128-0.16-0.192-0.16-0.064-0.224 0.064t0.16 0.192q0.16 0.064 0.224-0.064zM10.688 21.792q0-0.16-0.192-0.16t-0.192 0.16 0.192 0.128 0.192-0.128zM11.392 21.664q-0.032-0.128-0.224-0.096t-0.16 0.16q0.032 0.16 0.192 0.096t0.192-0.16zM22.848 16q0-3.776-2.656-6.464t-6.464-2.688-6.464 2.688-2.688 6.464q0 2.976 1.76 5.376t4.48 3.296q0.32 0.064 0.48-0.096t0.16-0.352q0-0.928-0.032-1.696-0.096 0.032-0.256 0.064t-0.64 0.032-0.864-0.096-0.768-0.352-0.544-0.736q-0.416-1.056-1.024-1.312-0.032-0.032-0.064-0.064l-0.16-0.16t-0.096-0.16 0.064-0.128 0.352-0.064q0.096 0 0.256 0.032t0.544 0.288 0.576 0.64q0.288 0.48 0.672 0.736t0.768 0.256 0.704-0.064 0.512-0.16q0.128-0.864 0.608-1.248-0.896-0.096-1.536-0.32t-1.312-0.704-0.992-1.344-0.352-2.144q0-1.408 0.96-2.464-0.448-1.088 0.096-2.4 0.32-0.128 0.96 0.128t1.088 0.512l0.448 0.288q1.056-0.288 2.304-0.288t2.272 0.288q0.192-0.128 0.512-0.32t0.992-0.448 1.024-0.16q0.512 1.312 0.096 2.4 0.928 1.056 0.928 2.464 0 1.024-0.256 1.792t-0.64 1.248-0.928 0.8-1.12 0.448-1.216 0.224q0.608 0.544 0.608 1.696 0 0.704 0 1.6t-0.032 0.896q0 0.224 0.16 0.352t0.48 0.096q2.752-0.928 4.512-3.296t1.728-5.376zM27.424 7.424v17.152q0 2.112-1.504 3.616t-3.648 1.536h-17.12q-2.144 0-3.648-1.536t-1.504-3.616v-17.152q0-2.112 1.504-3.616t3.648-1.536h17.12q2.144 0 3.648 1.536t1.504 3.616z"></path>
</svg>
</a>
</aside>
<aside class="fixed-lTK mw5-l right-0 f6 bl-l b--moon-gray pv4 pv0-ns ph4-l nested-list-reset nested-links nested-copy-line-height">
<div date-pref>
<a href=".." class="dib f6 pl1 hover-bg-light-gray br-100">
<svg class="fill-current" height="30px" viewBox="0 0 24 24" width="30px" xmlns="http://www.w3.org/2000/svg">
<path transform="rotate(90 11.704999923706055,12.000000000000002) " d="m15.41,7.41l-1.41,-1.41l-6,6l6,6l1.41,-1.41l-4.58,-4.59l4.58,-4.59z" id="svg_1"/>
<path d="M0 0h24v24H0z" fill="none"/>
</svg>
</a>
<a href="https://jenkins-zh.github.io/wechat/articles/2019-02-20-java11-preview-availability/" class="dib f6 pr1 hover-bg-light-gray br-100" title="Java 11 预览支持已在 Jenkins 2.155&#43; 中可用">
<svg class="fill-current" height="30px" viewBox="0 0 24 24" width="30px" xmlns="http://www.w3.org/2000/svg">
<path d="M10 6L8.59 7.41 13.17 12l-4.58 4.59L10 18l6-6z"/>
<path d="M0 0h24v24H0z" fill="none"/>
</svg>
</a>
</div>
</aside>
</div>
<div class="order-1 w-60-l mw7 ph0 ph5-ns mid-gray nested-copy-line-height no-underline nested-links nested-img nested-copy-seperator nested-blockquote mt0-ns" style="flex-grow:1;">
<div class="documentation-copy center measure-wide-l">
<div id="readout" class="fixed right-0 bottom-0">
</div>
<header class="flex-none w-100">
<h1 class="lh-title mb3 mv0 pt3 primary-color-dark">批量修改 Jenkins 任务的技巧</h1>
</header>
<aside class="bt bw1 pt3 mt2 mid-gray b--mid-gray fn w-100">
<div class="f4 fw4 lh-copy">
Jenkins 脚本命令行的一种实践
</div>
</aside>
<div class="prose" id="prose">
<h3 id="通过脚本命令行批量修改-jenkins-任务">通过脚本命令行批量修改 Jenkins 任务</h3>
<p>最近,笔者所在团队的 Jenkins 所在的服务器经常报硬盘空间不足。经查发现很多任务没有设置“丢弃旧的构建”。通知所有的团队检查自己的 Jenkins 任务有没有设置丢弃旧的构建,有些不现实。</p>
<p>一开始想到的是使用 Jenkins 的 API 来实现批量修改所有的 Jenkins 任务。笔者对这个解决方案不满意,经 Google 发现有同学和我遇到了同样的问题。他使用的更“技巧”的方式:在 Jenkins 脚本命令行中,通过执行 Groovy 代码操作 Jenkins 任务。</p>
<p>总的来说,就两步:</p>
<ol>
<li>进入菜单:<em>系统管理 &ndash;&gt; 脚本命令行</em></li>
<li><p>在输入框中,粘贴如下代码:</p>
<pre><code class="language-groovy">import jenkins.model.Jenkins
import hudson.model.Job
import jenkins.model.BuildDiscarderProperty
import hudson.tasks.LogRotator
// 遍历所有的任务
Jenkins.instance.allItems(Job).each { job -&gt;
if ( job.isBuildable() &amp;&amp; job.supportsLogRotator() &amp;&amp; job.getProperty(BuildDiscarderProperty) == null) {
println &quot; \&quot;${job.fullDisplayName}\&quot; 处理中&quot;
job.addProperty(new BuildDiscarderProperty(new LogRotator (2, 10, 2, 10)))
println &quot;$job.name 已更新&quot;
}
}
return;
/**
LogRotator构造参数分别为:
daysToKeep: If not -1, history is only kept up to this days.
numToKeep: If not -1, only this number of build logs are kept.
artifactDaysToKeep: If not -1 nor null, artifacts are only kept up to this days.
artifactNumToKeep: If not -1 nor null, only this number of builds have their artifacts kept.
**/
</code></pre></li>
</ol>
<h3 id="脚本命令行介绍">脚本命令行介绍</h3>
<p>脚本命令行(Jenkins Script Console),它是 Jenkins 的一个特性,允许你在 Jenkins master 和 Jenkins agent 的运行时环境执行任意的 Groovy 脚本。这意味着,我们可以在脚本命令行中做任何的事情,包括关闭 Jenkins,执行操作系统命令 <code>rm -rf /</code>(所以不能使用 root 用户运行 Jenkins agent)等危险操作。</p>
<p>除了上文中的,使用界面来执行 Groovy 脚本,还可以通过 Jenkins HTTP API:<code>/script</code>执行。具体操作,请参考 <a href="https://wiki.jenkins.io/display/JENKINS/Jenkins+Script+Console">官方文档</a></p>
<h3 id="问题-代码执行完成后-对任务的修改有没有被持久化">问题:代码执行完成后,对任务的修改有没有被持久化?</h3>
<p>当我们代码<code>job.addProperty(new BuildDiscarderProperty(new LogRotator (2, 10, 2, 10)))</code>执行后,这个修改到底有没有持久化到文件系统中呢(Jenkins 的所有配置默认都持久化在文件系统中)?我们看下 hudson.model.Job 的源码,在<code>addProperty</code>方法背后是有进行持久化的:</p>
<pre><code class="language-groovy">public void addProperty(JobProperty&lt;? super JobT&gt; jobProp) throws IOException {
((JobProperty)jobProp).setOwner(this);
properties.add(jobProp);
save();
}
</code></pre>
<h3 id="小结">小结</h3>
<p>本文章只介绍了批量修改“丢弃旧的构建”的配置,如果还希望修改其它配置,可以参考 hudson.model.Job <a href="https://github.com/jenkinsci/jenkins/blob/master/core/src/main/java/hudson/model/Job.java">源码</a></p>
<p>不得不提醒读者朋友,Jenkins 脚本命令行是一把双刃剑,大家操作前,请考虑清楚影响范围。如果有必要,请提前做好备份。</p>
</div>
<aside class="bt bw1 pt3 mt2 mid-gray b--mid-gray fn w-100">
</aside>
<script src="https://utteranc.es/client.js"
repo="jenkins-zh/jenkins-zh.github.io"
issue-term="pathname"
theme="github-light"
crossorigin="linuxsuren"
async>
</script>
</div>
</div>
<div class="order-0 w-20 dn db-l">
<nav role="navigation">
<ul class="list pa0 nl2">
</ul>
</nav>
</div>
</div>
</article>
<div class="w-100 bg-light-gray">
<div class="mw7 pa4 center nested-lh-copy lh-copy">
<h6 class="f4 dark-gray mb2">
<a href="https://jenkins-zh.github.io/wechat/articles/2019-02-27-jenkins-script-console-in-practice/" class="hide-child link primary-color">
<span class="nl3 child"><svg class="grow" fill="" height="14px" viewBox="0 0 24 24" width="14px" xmlns="http://www.w3.org/2000/svg"><path d="M0 0h24v24H0z" fill="none"/><path d="M3.9 12c0-1.71 1.39-3.1 3.1-3.1h4V7H7c-2.76 0-5 2.24-5 5s2.24 5 5 5h4v-1.9H7c-1.71 0-3.1-1.39-3.1-3.1zM8 13h8v-2H8v2zm9-6h-4v1.9h4c1.71 0 3.1 1.39 3.1 3.1s-1.39 3.1-3.1 3.1h-4V17h4c2.76 0 5-2.24 5-5s-2.24-5-5-5z"/></svg>
</span>
“批量修改 Jenkins 任务的技巧”
</a> was last updated: February 27, 2019
</h6>
<a href="https://github.com/jenkins-zh/jenkins-zh/edit/master/content/wechat/articles/2019-02-27-jenkins-script-console-in-practice.md" class="
f6 ph3 pv1 br2 dib tc ttu mv3 bg-primary-color white hover-bg-green link
" target="_blank">改善此页</a>
<div class="nested-lh-copy">
<ul class="list dib nested-links ml0 pl0">
<li class="db mb2 b">
Tags:
</li>
<li class="db dib-l mr3">
<a class="tag" href="/tags/jenkins">
Jenkins
</a>
</li>
<li class="db b mt4 mb2 mr2">
Related entries:
</li>
<li class="db dib-l mb2 mr3">
<a href="/wechat/articles/2019-01-16-webhook-firewalls/" class="link">
在安全防火墙内通过 WebHook 触发构建
</a>
</li>
</ul>
</div>
</div>
</div>
</main>
</main>
<footer class="bg-primary-color-dark ph4-ns pt4 relative w-100" role="contentinfo">
<div class="center flex-ns flex-wrap justify-between mw9 w-90">
<div class="pb3 pt4 w-100 w-50-ns">
<div class="b f3 light-gray mb3 nested-links tc">
<a href="https://github.com/jenkins-zh/jenkins-zh/graphs/contributors" target="_blank" class="link">Jenkins 社区贡献者</a> 维护<br/>
</div>
<ul class="center f6 list ma0 mv3 pa0 tc" style="display:none"><li class="dib mr3"><a href="https://github.com/jenkins-zh/jenkins-zh/issues/new" class="dim link light-gray pv2">File an Issue</a></li></ul>
<ul class="center f6 list ma0 mv4 pa0 tc">
<li class="dib mr3">
<a href="https://twitter.com/suren69811254" target="_blank" class="dim link light-gray pv2">@suren69811254</a>
</li>
<li class="dib mr3">
<a href="https://www.youtube.com/channel/UC63xz3pq26BBgwB3cnwCoqQ" target="_blank" class="dim link light-gray pv2">YouTube</a>
</li>
</ul>
</div>
<div>
<a href="https://mp.weixin.qq.com/s/vifdduC3kRGSIMpyL03yVA" target="_blank">
<img src="https://jenkins.io/images/jenkins-wechat.png" with="100" height="100">
</a>
</div>
</div>
<div class="f7 gray mb5 mb0-ns ph3 w-100" style="display:none"> 
<p class="dib mr4">Jenkins&reg; is a registered trademark of <a href="https://www.spi-inc.org/" class="link">Software in the Public Interest, Inc.</a></p>
<p class="dib">Copyright 2018–2019 the original authors.</p>
</div>
<div class="bg-primary-color-dark bottom-0 left-0 right-0 dn-l fixed pb3 ph3 w-100"><div class="globalmenu mobilemenu pb3 dn">
<ul class="list hidden dib ph0 ma0 scrolling-touch tc">
<li class="tl dib ma0 hover-bg-black w-100">
<a href="/wechat/" class="ttu f6 link primary-color-light overflow hover-white db brand-font ma0 w-100 pv3 ph4">
微信
</a>
</li>
<li class="tl dib ma0 hover-bg-black w-100">
<a href="/event/" class="ttu f6 link primary-color-light overflow hover-white db brand-font ma0 w-100 pv3 ph4">
活动
</a>
</li>
<li class="tl dib ma0 hover-bg-black w-100">
<a href="/about/" class="ttu f6 link primary-color-light overflow hover-white db brand-font ma0 w-100 pv3 ph4">
关于我们
</a>
</li>
<li class="tl dib ma0 hover-bg-black w-100">
<a href="http://jenkins.io/zh" class="ttu f6 link primary-color-light overflow hover-white db brand-font ma0 w-100 pv3 ph4">
Jenkins 官网
</a>
</li>
</ul>
</div>
<div class="docsmenu mobilemenu pb3 dn">
<ul class="list dib ph0 ma0 scrolling-touch tc">
</ul>
</div>
<div class="flex dn-l justify-between">
<button class="js-toggle flex-auto dib dn-l f6 tc db mt4-ns ph3 pv2 link mr2 white bg-primary-color-dark hover-bg-primary-color ba b--white-40 w-auto" data-target=".globalmenu">Menu</button>
<button class="js-toggle flex-auto dib dn-l f6 tc db mt4-ns ph3 pv2 link white bg-primary-color-dark hover-bg-primary-color ba b--white-40 w-auto" data-target=".docsmenu">Docs Menu</button>
</div>
</div>
</footer>
<link href="/dist/auto-complete.css" rel="stylesheet">
<script type="text/javascript">
var baseurl = "https:\/\/jenkins-zh.github.io\/";
</script>
<script src="/dist/lunr.js"></script>
<script src="/dist/autocomplete.js"></script>
<script src="/dist/jquery-3.2.1.min.js"></script>
<script src="/dist/search.js"></script>
<script async defer src="https://buttons.github.io/buttons.js"></script>
</body>
</html>
......@@ -32,7 +32,7 @@
<meta property="og:description" content="" />
<meta property="og:type" content="website" />
<meta property="og:url" content="https://jenkins-zh.github.io/wechat/" />
<meta property="og:updated_time" content="2019-02-20T00:00:00&#43;00:00"/>
<meta property="og:updated_time" content="2019-02-27T00:00:00&#43;00:00"/>
<meta itemprop="name" content="Wechats">
<meta itemprop="description" content="">
......@@ -163,6 +163,9 @@
<section class="flex-ns flex-wrap justify-between w-100">
<div class="relative weight-0">
<div class="bg-white mb2 pa3 pa4-l gray">
......@@ -187,7 +190,9 @@
</div>
</div>
<div class="relative weight-0">
<div class="bg-white mb2 pa3 pa4-l gray">
......@@ -212,7 +217,9 @@
</div>
</div>
<div class="relative weight-0">
<div class="bg-white mb2 pa3 pa4-l gray">
......@@ -237,7 +244,9 @@
</div>
</div>
<div class="relative weight-0">
<div class="bg-white mb2 pa3 pa4-l gray">
......@@ -262,7 +271,9 @@
</div>
</div>
<div class="relative weight-0">
<div class="bg-white mb2 pa3 pa4-l gray">
......@@ -287,7 +298,9 @@
</div>
</div>
<div class="relative weight-0">
<div class="bg-white mb2 pa3 pa4-l gray">
......@@ -312,7 +325,9 @@
</div>
</div>
<div class="relative weight-0">
<div class="bg-white mb2 pa3 pa4-l gray">
......@@ -337,7 +352,9 @@
</div>
</div>
<div class="relative weight-0">
<div class="bg-white mb2 pa3 pa4-l gray">
......@@ -362,7 +379,9 @@
</div>
</div>
<div class="relative weight-0">
<div class="bg-white mb2 pa3 pa4-l gray">
......@@ -387,31 +406,7 @@
</div>
</div>
<div class="relative weight-0">
<div class="bg-white mb2 pa3 pa4-l gray">
<h1 class="near-black f3">
<a href="/wechat/articles/2018-12-26-security-updates/" class="link primary-color dim">Jenkins 的重要安全更新</a>
</h1>
<div class="lh-copy links">
重要安全更新
<a href="/wechat/articles/2018-12-26-security-updates/" class="f6 mt2 db link primary-color dim">
查看更多 &raquo;
</a>
</div>
</div>
</div>
</section>
</div>
......
......@@ -6,11 +6,24 @@
<description>Recent content in Wechats on Jenkins 中文社区</description>
<generator>Hugo -- gohugo.io</generator>
<language>zh-CN</language>
<lastBuildDate>Wed, 20 Feb 2019 00:00:00 +0000</lastBuildDate>
<lastBuildDate>Wed, 27 Feb 2019 00:00:00 +0000</lastBuildDate>
<atom:link href="https://jenkins-zh.github.io/wechat/index.xml" rel="self" type="application/rss+xml" />
<item>
<title>批量修改 Jenkins 任务的技巧</title>
<link>https://jenkins-zh.github.io/wechat/articles/2019-02-27-jenkins-script-console-in-practice/</link>
<pubDate>Wed, 27 Feb 2019 00:00:00 +0000</pubDate>
<guid>https://jenkins-zh.github.io/wechat/articles/2019-02-27-jenkins-script-console-in-practice/</guid>
<description>通过脚本命令行批量修改 Jenkins 任务 最近,笔者所在团队的 Jenkins 所在的服务器经常报硬盘空间不足。经查发现很多任务没有设置“丢弃旧的构建”。通知所有的团队检查自己的 Jenkins 任务有没有设置丢弃旧的构建,有些不现实。
一开始想到的是使用 Jenkins 的 API 来实现批量修改所有的 Jenkins 任务。笔者对这个解决方案不满意,经 Google 发现有同学和我遇到了同样的问题。他使用的更“技巧”的方式:在 Jenkins 脚本命令行中,通过执行 Groovy 代码操作 Jenkins 任务。
总的来说,就两步:
进入菜单:系统管理 &amp;ndash;&amp;gt; 脚本命令行 在输入框中,粘贴如下代码:
import jenkins.model.Jenkins import hudson.model.Job import jenkins.model.BuildDiscarderProperty import hudson.tasks.LogRotator // 遍历所有的任务 Jenkins.instance.allItems(Job).each { job -&amp;gt; if ( job.isBuildable() &amp;amp;&amp;amp; job.supportsLogRotator() &amp;amp;&amp;amp; job.getProperty(BuildDiscarderProperty) == null) { println &amp;quot; \&amp;quot;${job.fullDisplayName}\&amp;quot; 处理中&amp;quot; job.addProperty(new BuildDiscarderProperty(new LogRotator (2, 10, 2, 10))) println &amp;quot;$job.name 已更新&amp;quot; } } return; /** LogRotator构造参数分别为: daysToKeep: If not -1, history is only kept up to this days.</description>
</item>
<item>
<title>Java 11 预览支持已在 Jenkins 2.155&#43; 中可用</title>
<link>https://jenkins-zh.github.io/wechat/articles/2019-02-20-java11-preview-availability/</link>
......
......@@ -162,6 +162,34 @@
<section class="flex-ns flex-wrap justify-between w-100">
<div class="relative weight-0">
<div class="bg-white mb2 pa3 pa4-l gray">
<h1 class="near-black f3">
<a href="/wechat/articles/2018-12-26-security-updates/" class="link primary-color dim">Jenkins 的重要安全更新</a>
</h1>
<div class="lh-copy links">
重要安全更新
<a href="/wechat/articles/2018-12-26-security-updates/" class="f6 mt2 db link primary-color dim">
查看更多 &raquo;
</a>
</div>
</div>
</div>
<div class="relative weight-0">
<div class="bg-white mb2 pa3 pa4-l gray">
......@@ -186,7 +214,9 @@
</div>
</div>
<div class="relative weight-0">
<div class="bg-white mb2 pa3 pa4-l gray">
......@@ -211,7 +241,9 @@
</div>
</div>
<div class="relative weight-0">
<div class="bg-white mb2 pa3 pa4-l gray">
......@@ -236,7 +268,9 @@
</div>
</div>
<div class="relative weight-0">
<div class="bg-white mb2 pa3 pa4-l gray">
......@@ -261,7 +295,9 @@
</div>
</div>
<div class="relative weight-0">
<div class="bg-white mb2 pa3 pa4-l gray">
......@@ -286,7 +322,9 @@
</div>
</div>
<div class="relative weight-0">
<div class="bg-white mb2 pa3 pa4-l gray">
......@@ -311,6 +349,7 @@
</div>
</div>
</section>
</div>
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册