Jenkins 流水线pipeline中SSH方式登录远程机器

本文介绍了如何在Jenkins中配置时区为北京时间,并利用SSH Pipeline Step Plugins进行远程机器操作。通过示例展示了如何定义远程服务器的详细信息,如主机名、用户名、密码等,以及执行远程shell脚本。

Jenkins时区设置为北京时间  打开 【系统管理】->【脚本命令行】运行下面的命令

System.setProperty('org.apache.commons.jelly.tags.fmt.timeZone', 'Asia/Shanghai')

1.在jenkins上安装SSHpipeline Step Plugins

2.scripts

pipeline{

   agent any

   stages {

       stage ('Pipeline configuration') {

                agent none

                steps {

                      script {

                        stage ('Pull & PushImage') {

                          def remote = [:]

                          remote.name = 'test'

                          remote.host ='192.168.248.190'

                          remote.user = 'root'

                          remote.password ='password'

                          remote.allowAnyHosts= true

                          writeFile file:'jemeter.sh', text: 'cd /ibm \n ls'

                          sshScript remote: remote,script: "jemeter.sh"

                            }

                       }

                  }   

           }

      }

}

CRON job 

TZ=Asia/Shanghai
1 8,9,10,11,12,13,14,15,16,17,18,19,20,21,22 * * 1-5



作者:sckehan
链接:https://www.jianshu.com/p/e8a4fdef1805
来源:简书
简书著作权归作者所有,任何形式的转载都请联系作者获得授权并注明出处。

评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值