从另一个管道脚本加载管道脚本时,两个管道不会在同一节点上执行:第一个在我的主节点上执行,第二个在从节点上执行.
我正在使用Jenkins管道,Pipeline Script from SCM以这种方式为很多工作提供选项:
我的每个作业都使用Poll SCM选项定义了相应的Git repo URL,以便在对我的代码进行更改(基本作业使用)时自动轮询存储库.
我的每个作业都Jenkinsfile在其存储库的根目录中定义了一个简单的内容,而内部的管道脚本基本上只能加载一个更通用的管道.
例如:
node {
// --- Load the generic pipeline ---
checkout scm: [$class: 'GitSCM', branches: [[name: '*/master']], extensions: [], submoduleCfg: [], userRemoteConfigs: [[url: 'http://github/owner/pipeline-repo.git']]]
load 'common-pipeline.groovy'
}()
Run Code Online (Sandbox Code Playgroud)
我的common-pipeline.groovy管道可以实现诸如构建,发布或部署工件之类的实际内容,例如:
{ ->
node() {
def functions = load 'common/functions.groovy'
functions.build()
functions.release()
functions.deploy()
}
}
Run Code Online (Sandbox Code Playgroud)
现在我不想强制每个作业的节点,所以两个管道都有,node("master")或者node("remote")因为我真的不想手动处理它,但是我希望一旦第一个管道在特定节点上运行(主机,slave1,slave2,slave3)第二个/加载的管道在同一个节点上执行,因为否则我的实际Git存储库代码不能从其他节点的工作区获得......
有没有什么方法可以指定我希望我的第二个管道在第一个管道的同一节点上执行,或者在使用该load步骤时可能传递一个参数?
关于Jenkins DSL,两者之间有什么区别?
def cwd = pwd()
Run Code Online (Sandbox Code Playgroud)
和
cwd = pwd()
Run Code Online (Sandbox Code Playgroud)
?
在我的代码中,我使用a IntentService来收听位置更新(GPS或网络更新),这IntentService是在收到事件时触发的,因此它是startService()从任何活动开始的.
public class AddLocationService extends IntentService implements LocationListener {
/*My code here*/
}
@Override
protected void onHandleIntent(Intent intent) {
if(getOldLoc() == null)
{
//Get a new location
this.locationManager.requestLocationUpdates(LocationManager.NETWORK_PROVIDER, TIME_INTERVAL_GPS, 0, this);
this.locationManager.requestLocationUpdates(LocationManager.GPS_PROVIDER, TIME_INTERVAL_GPS, 0, this);
Log.d(AddLocationService.TAG, "Network listener started");
this.time_start_listening = System.currentTimeMillis();
mTimerThread mTimerRunnable = new mTimerThread();
this.timerThread = new Thread(mTimerRunnable);
this.timerThread.start();
}
else
/*REUSE OLD LOCATION*/
}
Run Code Online (Sandbox Code Playgroud)
现在我的问题是:当两个事件开始这个IntentService并且第二个事件启动它而第一个事件仍在请求更新时,我希望第二个事件等到第一个完全完成(找到位置OR计时器线程完成).但是,无论何时IntentService第二次执行(第一个实例仍在运行),它都会打印日志并执行并行执行.
然而,我认为主要目标IntentService是它是连续的,所以第二个意图必须等到第一个完成...
我错过了什么吗?
好了,所以参考TestNG的文档我可以运行测试顺序(缺省在一个测试套件)或平行使用<suite parallel="tests">。
现在这是我的TestNG配置
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE suite SYSTEM "http://testng.org/testng-1.0.dtd">
<suite name="Complete test suite">
<listeners>
<listener class-name="com.uas.test.portlet.integration.util.WebDriverListener" />
<listener class-name="org.uncommons.reportng.HTMLReporter" />
</listeners>
<test name="Parallel tests" parallel="methods" thread-count="4">
<groups>
<run>
<exclude name="sequential-test"></exclude>
</run>
</groups>
<packages>
<package name="com.uas.test.portlet.integration.main" />
<package name="com.uas.test.portlet.integration.main.categorymanager" />
<package name="com.uas.test.portlet.integration.main.admin" />
</packages>
</test>
<test name="Sequential tests" parallel="false" >
<groups>
<run>
<include name="sequential-test"></include>
</run>
</groups>
<packages>
<package name="com.uas.test.portlet.integration.main" />
<package name="com.uas.test.portlet.integration.main.categorymanager" />
<package name="com.uas.test.portlet.integration.main.admin" />
</packages>
</test>
</suite>
Run Code Online (Sandbox Code Playgroud)
如您所见,我有两种测试类型:可以并行运行的测试和应顺序运行的其他测试。parallel=tests我的套件中没有属性,因此 …
我需要能够在单个直方图上显示多行,其中每一行应由参数表示.我有多个服务器,我想监视它,比如CPU使用率.我的Kibana输入数据看起来像这样:
Timestamp | Machine | Name | Value |
2015-06-15T13:31:50.831Z | 06 | CPUUsage | 26.71 |
2015-06-15T13:31:50.831Z | 04 | CPUUsage | 19.95 |
2015-06-15T13:31:50.831Z | 03 | CPUUsage | 17.54 |
2015-06-15T13:31:50.831Z | 02 | CPUUsage | 20.08 |
... 等等.
正如您将理解的,我需要将每台机器绘制为一条公共直方图的单行.目前,我有多少Kibana查询与我想要监控的机器数量一样多,因此对于上面的示例输入,我将有4个查询:
Name:"CPUUsage" AND Machine:"02" Name:"CPUUsage" AND Machine:"03" Name:"CPUUsage" AND Machine:"04" Name:"CPUUsage" AND Machine:"06"
所以它呈现如下:

现在渲染很棒,但我的问题是我必须为我想监视的每台机器添加一个查询,这既麻烦又根本不可扩展,特别是因为要监控的机器数量在不断变化.
最后,我想要实现的是只声明一个想要这样的查询:
Name:"CPUUsage"
这个查询与机器无关,但为此我需要能够告诉Kibana 使用我的参数" 机器 " 将我的查询拆分为N行......是甚么可能吗?
注意:我目前正在使用Kibana 3.1.0.
我有一个处理模板文件(例如XML文件)的管道作业,需要在使用渲染文件之前用作业参数替换文件中的一些变量,但我现在似乎无法找到任何干净的东西,现在我只是使用shell脚本和sed逐个替换每个变量.
这是一个示例XML模板文件:
<?xml version='1.0' encoding='UTF-8'?>
<rootNode>
<properties>
<property1>${property1}</property1>
<property2>${property2}</property2>
<property3>${property3}</property3>
</properties>
</rootNode>
Run Code Online (Sandbox Code Playgroud)
我希望我的模板文件中的"变量"替换为我的作业参数$property1,$property2并且$property3.这就是我今天要做的事情:
sh "sed -i 's/@property1@/${property1}/' '${templateFile}'" +
"sed -i 's/@property2@/${property2}/' '${templateFile}'" +
"sed -i 's/@property3@/${property3}/' '${templateFile}'"
Run Code Online (Sandbox Code Playgroud)
...但我觉得它很难看......詹金斯有什么东西用来模板文件,例如Jinja2(或任何模板框架)会做什么吗?
有没有办法使用 Jenkins 管道在 Nifi 流上自动运行回归/功能测试?
搜索了一下,没有成功。
谢谢你的帮助。
我有一个使用带有空格的 git URL 的管道脚本https://username:password@project-teamprojects.visualstudio.com/defaultcollection/_git/Core - Stream:
node ("master") {
bat([script: "git push https://username:password@project-teamprojects.visualstudio.com/defaultcollection/_git/Core%20-%20Stream", encoding: "UTF-8" ])
}
Run Code Online (Sandbox Code Playgroud)
当执行此 jenkins 作业时,它会失败,因为'%20'被替换为'0'. 日志说:
git push https://username:password@project-teamprojects.visualstudio.com/defaultcollection/_git/Core0-0Stream
remote: TF401019: The Git repository with name or identifier Core0-0Stream does not exist or you do not have permissions for the operation you are attempting.
fatal: repository 'https://username:password@project-teamprojects.visualstudio.com/defaultcollection/_git/Core0-0Stream/' not found
Run Code Online (Sandbox Code Playgroud)
如何在 jenkins 管道脚本中使用bat 任务正确编码 git url
我可以在CentOS linux服务器中使用hyperledger composer部署业务网络,但是在使用composer-rest-server生成REST api时却出现连接错误?
[root@bctlpblockchain03 ~]#composer network ping -c admin@tutorial-network
The connection to the network was successfully tested: tutorial-network
version: 0.15.2
participant: org.hyperledger.composer.system.NetworkAdmin#admin
Command succeeded
[root@bctlpblockchain03 ~]# composer-rest-server
? Enter the name of the business network card to use: admin@tutorial-network
? Specify if you want namespaces in the generated REST API: never use namespaces
? Specify if you want to enable authentication for the REST API using Passport:
No
? Specify if you want to enable event publication over WebSockets: …Run Code Online (Sandbox Code Playgroud) jenkins ×5
groovy ×2
android ×1
apache-nifi ×1
blockchain ×1
centos ×1
git ×1
hyperledger ×1
jenkinsfile ×1
kibana ×1
linux ×1
sed ×1
service ×1
templates ×1
testing ×1
testng ×1