小编Sri*_*osh的帖子

外部groovy脚本给出错误:groovy.lang.MissingPropertyException:无此类属性:hudson。在詹金斯中使用时

我目前在Jenkins中使用“执行系统常规脚本”。我在Jenkins的编辑器框中编写了以下代码。

import hudson.model.*
import groovy.json.JsonBuilder
import groovy.json.JsonSlurper


// Get the list of all jobs and print them
activeJobs = hudson.model.Hudson.instance.items.findAll{job -> job.isBuildable()}

//activeJobs.each{run -> println(run.name)}
println  ('total number of jobs :'+ activeJobs.size())

// find failed runs
failedRuns = activeJobs.findAll{job -> job.lastBuild != null && job.lastBuild.result == hudson.model.Result.FAILURE}
//failedRuns.each{run -> println(run.name)}
println  ('total number of jobs :'+ failedRuns.size())


// find successful runs
successfulRuns = activeJobs.findAll{job -> job.lastBuild != null && job.lastBuild.result == hudson.model.Result.SUCCESS}
//successfulRuns.each{run -> println(run.name)}
println  ('total number of jobs …
Run Code Online (Sandbox Code Playgroud)

groovy jenkins jenkins-plugins

2
推荐指数
1
解决办法
5162
查看次数

Java中从int到byte的显式转换

我试图将int转换为byte.

int i = 128;
byte b = (byte) i;
Run Code Online (Sandbox Code Playgroud)

我知道-128到127的字节范围以及将整数存储到一个字节的规则是:

byte_value = int_vale%byte_Range; (我发现在完整参考Java中)

当我将它应用于int 128时,它应该是这样的:

byte_value = 128%256 = 128;

但是,它实际上是:-128

我无法理解这背后的实际逻辑.请帮忙!!

java type-conversion

0
推荐指数
1
解决办法
1495
查看次数

如何使用同步方法?

我有这段代码.

public class Main{

    public static void main(String[] args) {
    Main1 main1 = new Main1();
    Main2 main2 = new Main2();
    Thread t1 = new Thread(main1);
    Thread t2 = new Thread(main2);
    t1.start();
    t2.start();
  }
}
public class Main1 extends Thread{
    SynchronizedCounter c = new SynchronizedCounter();
    public void run(){
        System.out.println("Entering Main1");
        c.print();
        System.out.println("Exiting Main1");
    }
}
public class Main2 extends Thread{
    SynchronizedCounter c = new SynchronizedCounter();
    public void run(){
        System.out.println("Entering Main2");
        c.print();
        System.out.println("Exiting Main2");
    }
}
public class SynchronizedCounter {
    public void …
Run Code Online (Sandbox Code Playgroud)

java synchronization

0
推荐指数
1
解决办法
71
查看次数

如何在 Eclipse RCP 应用程序中 5 秒后自动隐藏标签?

我正在尝试在 RCP 应用程序中创建一个最初不可见的标签。当我单击“保存”按钮时,它变得可见。同样,它应该在 5 秒内不可见。

为此,我编写了以下代码:

saveButton.addSelectionListener(new SelectionListener() {

            @Override
            public void widgetSelected(SelectionEvent e) {
                // TODO Auto-generated method stub
                System.out.println(textName.getText());
                String text = textName.getText();
                tree.getSelection()[0].setText(text);
                String nodeId = ((TreeStructure) tree.getSelection()[0]
                        .getData()).getNodeId();
                // update the database
                UpdateTree updateTree = new UpdateTree();
                updateTree.renameNode(text, nodeId);
                label.setBounds(xForFirstButton, yIndexForButtons
                        + Constants.BUTTON_BUFFER, Constants.BUTTON_WIDTH,
                        Constants.BUTTON_HEIGHT);
                label.setVisible(true);

                AbstractAction myAction = new AbstractAction() {

                    private static final long serialVersionUID = 1L;

                    @Override
                    public void actionPerformed(ActionEvent arg0) {
                        // TODO Auto-generated method stub
                        label.setVisible(false);
                    }
                };

                Timer myTimer = …
Run Code Online (Sandbox Code Playgroud)

java user-interface swt eclipse-rcp

0
推荐指数
1
解决办法
503
查看次数