Jenkins

How can I do string to integer conversion in a Jenkinsfile?

℡╲_俬逩灬. 提交于 2020-04-06 07:23:05
问题 I have the following in my Jenkinsfile: pipeline { agent none environment { timeout_mins = 1 } options { timeout(time: "${env.timeout_mins}", unit: 'MINUTES') } stages { stage("test print") { steps { echo "timeout_mins: ${env.timeout_mins}" sh "sleep 120" } } } } I'd like to re-use environment params such as timeout_mins in multiple places, but need to convert it to integer in certain places for certain plugins. The error I get with the above example is as follows: Processing environment for

解决Jenkins 2.0 初始化界面卡住的问题

99封情书 提交于 2020-04-06 07:02:09
***************************************** *原创博客转载请注明出处,谢谢!* **************************************** Jenkins 2.0 将要发布,但是试用alpha版本时,总是卡在初始化界面(设置插件的界面),如下图: 这个可以用浏览器的调试功能,将这个初始化界面删除,然后就可以继续执行到安装插件,重启以后初始化界面就不会出现了。但是在2016/03/13 以后更新的 jenkins 2.0用这个方法解决不了了,所以只能想其它办法。 这个界面是用来设置插件用的,jenkins在安装插件前总是尝试连接www.google.com,来判断网络是否连通。大家都知道谷歌的网站在大陆是连不上的,所以出现这个问题的原因很可能和这个有关。 开始验证猜测是否正确: 1. 下载最新的Jenkins2.0 http://mirrors.jenkins-ci.org/war-rc/2.0/jenkins.war 2. java -jar jenkins.war 3. cd $JENKINS_HOME/updates ,我这里的路径等于 $HOME/.jenkins/updates -- $JENKINS_HOME的路径不同的安装方式都是不一样的 4. vi default.json , 可以看到前面的键值对为:

Jenkins 教程:使用 Ngrok 配置(SCM)Github 触发器和 Git 轮询

依然范特西╮ 提交于 2020-04-06 03:09:04
本文首发于: Jenkins 中文社区 原文链接 作者:Kiley Nichols 译者:wenjunzhangp 教你如何在作业上配置 Github 触发器以及如何使用 Webhook 与 Github 相通 总览 Jenkins 是领先的开源自动化服务。它提供了 1500+ 个插件来支持构建,部署和自动化任何项目。在本文中,我们将研究如何在作业上配置 Github 触发器,以及如何使用 Webhook 与 Github 相通,该 Webhook 指示何时轮询作业以构建对项目进行的更改。 前提条件 您需要在 Github 中有一个项目。 您将需要启动并运行 Jenkins 服务 。 入门 安装和运行 Ngrok Ngrok 是一个反向代理,它接受公共地址上的流量,并将该流量中继到计算机上运行的 ngrok 进程,然后再中继到您指定的本地地址。 因此,通过您选择的任何一种方法,前往 Ngrok 并注册一个帐户。然后,您应该会看到下面的截图,其中显示了如何解压缩和运行它。 运行 ./ngrok http 8080 ,它将指向我们的 Jenkins 服务。 运行该命令后,您将收到代理主机名,如下所示: 转发 http://xxxxx.ngrok.io -> http://localhost:8080 转发 https://xxxxx.ngrok.io -> http:/

一个简单的连续调用脚本部署代码的案例

喜你入骨 提交于 2020-04-06 01:03:17
先简单描述一下环境,Jenkins部署在私有云,从git拉取代码并编译后会调用脚本将jar包部署到阿里云的应用服务器。 阿里云应用服务器无公网IP,通过跳板机登录。就产生了连续调用脚本,穿透跳板机部署到阿里云内网的需求。 服务器信息: 主机名称 IP git server 10.150.27.51 jenkins server 10.150.27.52 jump server 1.1.1.1/192.168.2.20 app server1 192.168.2.21 app server1 192.168.2.22 拓扑图如下: 1.部署脚本01-backend-earphone-8888.sh (Jenkins server) 主要实现功能: 将跳板机1.1.1.1上面临时目录/data/deploy/pccode/earphone内容情况 拷贝Jenkins编译生成的jar包文件(earphone-1.08888.jar)至跳板机/data/deploy/pccode/earphone目录 调用跳板机脚本进行部署/data/deploy/script/earphone.sh [root@bobo365 prod]# more backend-earphone-8888.sh #!/bin/bash . /etc/init.d/functions node="1.1.1.1"

小公司和大公司对编写unit test的要求有哪些区别?

大城市里の小女人 提交于 2020-04-05 21:52:22
开发系统的时候公司都会要求开发人员编写unit test,但是不同的公司对编写unit test的要求不尽相同。这里记录一下遇到过的编写unit test的一些写法。 1、创建项目,引入unit test相关的jar包 <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-test</artifactId> <scope>test</scope> </dependency> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-web</artifactId> </dependency> 项目中会自动生成一个*ApplicationTests.java类 @SpringBootTest(classes = SpringbootUnitTestDemoApplication.class, webEnvironment = SpringBootTest.WebEnvironment.DEFINED_PORT) public class SpringbootUnitTestDemoApplicationTests { @Test void

jenkins Euleros镜像打包

时光毁灭记忆、已成空白 提交于 2020-04-05 21:50:25
一、下载需要的软件 mkdir jenkins_software && cd jenkins_software wget --no-check-certificate -q https://mirrors.huaweicloud.com/epel/RPM-GPG-KEY-EPEL-7 -O RPM-GPG-KEY-EPEL-7 curl -fsSL http://raw.githubusercontent.com/jenkinsci/docker/master/tini_pub.gpg -o tini_pub.gpg export TINI_VERSION=v0.18.0 && curl -fsSL https://github.com/krallin/tini/releases/download/${TINI_VERSION}/tini-static-$(dpkg --print-architecture) -o tini-static-$(dpkg --print-architecture) export TINI_VERSION=v0.18.0 && curl -fsSL https://github.com/krallin/tini/releases/download/${TINI_VERSION}/tini-static-$(dpkg --print

k8s如何部署分布式jenkins

梦想的初衷 提交于 2020-04-05 18:58:19
Kubernetes是一个开源的,用于管理云平台中多个主机上的容器化的应用,Kubernetes的目标是让部署容器化的应用简单并且高效(powerful),Kubernetes提供了应用部署,规划,更新,维护的一种机制。 前提条件是,有storageclass,利用pvc 创建持久化存储 创建kube-ops namespace 这里创建opspvc 另外把accessmode 换成readwritemany,因为会有多个pod 进行读写 然后部署jenkins master deployment如下 --- apiVersion: extensions/v1beta1 kind: Deployment metadata: name: jenkins namespace: kube-ops spec: template: metadata: labels: app: jenkins spec: terminationGracePeriodSeconds: 10 serviceAccountName: jenkins containers: - name: jenkins image: jenkins/jenkins:lts imagePullPolicy: IfNotPresent ports: - containerPort: 8080 name: web protocol:

Jenkins加速镜像

丶灬走出姿态 提交于 2020-04-05 16:51:02
Jenkins配置国内加速镜像 1. 进入中文社区 页面右下角点击 中文社区 更新镜像地址 复制镜像地址,粘贴到升级站点 2. 国内镜像源 jenkins中文社区 https://mirrors.tuna.tsinghua.edu.cn/jenkins/ https://mirrors.huaweicloud.com/jenkins/ https://mirrors.cloud.tencent.com/jenkins/ http://mirror.bit.edu.cn/jenkins/ http://mirrors.ustc.edu.cn/jenkins/ 来源: oschina 链接: https://my.oschina.net/teddyIH/blog/3216596

How can I write a Jenkins email-ext template to display test results like the standard test report

大憨熊 提交于 2020-04-05 07:42:17
问题 I have tweaked the standard jelly template to display the current test results in a table, however I really want to be able to display diffs as seen in Jenkins own test results page. For example: JUnit Tests: 0 failures (±0) , 1 skipped (+1) Package Duration Fail (diff) Skip (diff) Total (diff) foo.bar.baz 89 ms 0 0 1 +1 5 +2 回答1: Write a Groovy template for Email Ext plugin instead of Jelly template. In Groovy template you'll have access to Build object for your build. You can then call

How can I write a Jenkins email-ext template to display test results like the standard test report

二次信任 提交于 2020-04-05 07:41:09
问题 I have tweaked the standard jelly template to display the current test results in a table, however I really want to be able to display diffs as seen in Jenkins own test results page. For example: JUnit Tests: 0 failures (±0) , 1 skipped (+1) Package Duration Fail (diff) Skip (diff) Total (diff) foo.bar.baz 89 ms 0 0 1 +1 5 +2 回答1: Write a Groovy template for Email Ext plugin instead of Jelly template. In Groovy template you'll have access to Build object for your build. You can then call