# jenkins-scripts **Repository Path**: xewsk/jenkins-scripts ## Basic Information - **Project Name**: jenkins-scripts - **Description**: jenkins运维使用的groovy脚本开发项目 - **Primary Language**: Unknown - **License**: Apache-2.0 - **Default Branch**: master - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 0 - **Forks**: 0 - **Created**: 2021-06-25 - **Last Updated**: 2021-06-25 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README # jenkins运维使用的groovy脚本开发项目 本项目搭建了开发环境,为了编写脚本时实现代码提示。 ## 特性 - 可在jenkins界面编写执行脚本([jenkins_service_url]/script/】) - 可在任意agent上执行脚本 - 在master执行脚本时,可交给agent来执行指定内容 - 可通过调用rest接口执行脚本,如curl或python调用 - 执行脚本是高级功能注意权限管理。可以通过它操作所在的操作系统,尽量使用低权限系统用户。 - 注意因为脚本执行直接调用了jenkins代码,需要考虑版本问题,有严重的代码过时风险。 ## 实现的功能 - 清理全部job的构建记录 - 在保留最新的n条构建记录前提下,清理所有已完成的构建记录 ## 参考资料 - [官方文档](https://www.jenkins.io/doc/book/managing/script-console/) ## 参考脚本仓库 - [CloudBees jenkins-scripts repository](https://github.com/cloudbees/jenkins-scripts). - [Jenkins CI jenkins-scripts repository under the `scriptler/` directory](https://github.com/jenkinsci/jenkins-scripts) (scripts for the [Scriptler Plugin](https://plugins.jenkins.io/scriptler)). - [Sam Gleske’s jenkins-script-console-scripts repository](https://github.com/samrocketman/jenkins-script-console-scripts). - [Sam Gleske’s jenkins-bootstrap-shared repository under the `scripts/` directory](https://github.com/samrocketman/jenkins-bootstrap-shared). - [Some scripts at JBoss.org](http://community.jboss.org/wiki/HudsonHowToDebug). # 开发 ## 开发环境 ### 代码提示 将项目转换为maven项目或增加groovy支持:右键点击项目,选中Add framework support…,选择Maven并点击ok 可以在ide中编写groovy脚本,使用自动完成功能,需要引入jenkins包。 [参考资料](https://www.mdoninger.de/2011/11/07/write-groovy-scripts-for-jenkins-with-code-completion.html)