我有以下json文件:
{
"FOO": {
"name": "Donald",
"location": "Stockholm"
},
"BAR": {
"name": "Walt",
"location": "Stockholm"
},
"BAZ": {
"name": "Jack",
"location": "Whereever"
}
}
Run Code Online (Sandbox Code Playgroud)
我正在使用jq并希望得到'location'为'Stockholm'的对象的"名称"元素.
我知道我可以得到所有的名字
cat json | jq .[] | jq ."name"
"Jack"
"Walt"
"Donald"
Run Code Online (Sandbox Code Playgroud)
但考虑到子键的值(这里"location" : "Stockholm"),我无法弄清楚如何只打印某些对象.
我想利用Jenkins 现有的Mailer插件来Jenkinsfile定义管道构建作业.鉴于以下简单的失败脚本,我希望每个版本都有一封电子邮件.
#!groovy
stage 'Test'
node {
try {
sh 'exit 1'
} finally {
step([$class: 'Mailer', notifyEveryUnstableBuild: true, recipients: 'me@me.com', sendToIndividuals: true])
}
}
Run Code Online (Sandbox Code Playgroud)
构建的输出是:
Started by user xxxxx
[Pipeline] stage (Test)
Entering stage Test
Proceeding
[Pipeline] node
Running on master in /var/lib/jenkins/jobs/rpk-test/workspace
[Pipeline] {
[Pipeline] sh
[workspace] Running shell script
+ exit 1
[Pipeline] step
[Pipeline] }
[Pipeline] // node
[Pipeline] End of Pipeline
ERROR: script returned exit code 1
Finished: FAILURE
Run Code Online (Sandbox Code Playgroud)
正如您所看到的,它确实记录了它step …
我有詹金斯的管道工作; 它被配置为构建在BitBucket webhook调用的远程触发器上.这有效并且正在触发构建.
我还需要访问BitBucket发送的有效负载数据(此处描述)以获取有关推送的详细信息,例如特定分支.
该到位桶插件通常会分析这个有效载荷,并将其提交给工作作为一个环境变量,但我不能设置流水线作业为连接到该插件特定的回购,所以它并不能帮助.
我尝试测试以查看数据是否以几种不同的方式可用:
node {
stage 'Desperation'
echo "${params.push}"
echo "${env.BITBUCKET_PAYLOAD}"
echo "${env.push}"
}
Run Code Online (Sandbox Code Playgroud)
这些不起作用(我也没想到它们).
有没有办法得到这个有效载荷数据?我唯一能想到的就是拥有一个自由式工作并建立与BitBucket的连接,然后在重新格式化数据后调用此工作.但这看起来非常笨重.
嗨,我正在使用Voldemort来存储我的数据.我的关键是一个单词,值是单词和URL的出现次数.例如:
key :question
value: 10, www.stackoverflow.com
Run Code Online (Sandbox Code Playgroud)
我正在使用Json对象来放置我的值.我的代码看起来像这样
import org.json.JSONObject;
import com.metaparadigm.jsonrpc.JSONSerializer;
import voldemort.client.ClientConfig;
import voldemort.client.SocketStoreClientFactory;
import voldemort.client.StoreClient;
import voldemort.client.StoreClientFactory;
public class ClientExample {
public static void main (String [] args) {
String bootstrapUrl = "tcp://localhost:6666";
ClientConfig cc = new ClientConfig ();
cc.setBootstrapUrls (bootstrapUrl);
String[] valuePair = new String[2];
int val = 1;
StoreClientFactory factory = new SocketStoreClientFactory (cc);
StoreClient client = factory.getStoreClient("test");
JSONObject json = new JSONObject();
json.put("occurence",val);
json.put("url", "www.cnn.com");
client.put("foo", json);
}
}
Run Code Online (Sandbox Code Playgroud)
我的store.xml看起来像这样
<stores>
<store>
<name>test</name>
<persistence>bdb</persistence>
<routing>client</routing> …Run Code Online (Sandbox Code Playgroud)