Config File Provider | Jenkins plugin
通过这个插件可以将配置文件直接在jenkins上进行管理,而不需要再访问服务器。
比如settings.xml管理
node ("windows") {stage ('Build') {git url: 'https://github.com/cyrille-leclerc/multi-module-maven-project'withMaven(// Maven installation declared in the Jenkins "Global Tool Configuration"maven: 'maven-3', // (1)// Use `$WORKSPACE/.repository` for local repository folder to avoid shared repositoriesmavenLocalRepo: '.repository', // (2)// Maven settings.xml file defined with the Jenkins Config File Provider Plugin// We recommend to define Maven settings.xml globally at the folder level using// navigating to the folder configuration in the section "Pipeline Maven Configuration / Override global Maven configuration"// or globally to the entire master navigating to "Manage Jenkins / Global Tools Configuration"mavenSettingsConfig: 'my-maven-settings' // (3)) {// Run the maven buildsh "mvn clean verify"} // withMaven will discover the generated Maven artifacts, JUnit Surefire & FailSafe & FindBugs & SpotBugs reports...}
}
mavenSettingsConfig选定的settings.xml对应的my-maven-settings是个id。
id展示在代码中,name展示在可视化操作选取中。
内容管理部分
流水线语法可以通过任意job进入,选取某个job的某次构建号,然后选择回放,指定红框处点击进入。
ssh-pipeline-steps
GitHub - jenkinsci/ssh-steps-plugin at ssh-steps-2.0.0
该插件提供了向部署服务器主机传文件sshPut和22端口ssh远程访问sshCommand执行脚本的能力。
考虑扩展(单个文件维护所有部署主机)和安全(密码不能明文对外展示),所以改造一下插件。
方案:jasypt.jar对密码进行加密,ssh-pipeline-steps插件密码进行解密。两边保证密钥串一致
改造后mvn clean package重新生成插件包
jenkins插件管理里面安装或替换插件,安装完成重启。
验证加密后密码能否传包和ssh访问主机
密码加密访问主机成功,不用再担心主机信息文件外泄问题。【保管好自己密钥串】