hudson.model.AbstractBuild#getUrl ( )源码实例Demo

下面列出了hudson.model.AbstractBuild#getUrl ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。

public BuildBeginInfo(String projectName, AbstractBuild<?, ?> build, NotificationConfig config){
    //获取请求参数
    List<ParametersAction> parameterList = build.getActions(ParametersAction.class);
    if(parameterList!=null && parameterList.size()>0){
        for(ParametersAction p : parameterList){
            for(ParameterValue pv : p.getParameters()){
                this.params.put(pv.getName(), pv.getValue());
            }
        }
    }
    //预计时间
    if(build.getProject().getEstimatedDuration()>0){
        this.durationTime = build.getProject().getEstimatedDuration();
    }
    //控制台地址
    StringBuilder urlBuilder = new StringBuilder();
    String jenkinsUrl = NotificationUtil.getJenkinsUrl();
    if(StringUtils.isNotEmpty(jenkinsUrl)){
        String buildUrl = build.getUrl();
        urlBuilder.append(jenkinsUrl);
        if(!jenkinsUrl.endsWith("/")){
            urlBuilder.append("/");
        }
        urlBuilder.append(buildUrl);
        if(!buildUrl.endsWith("/")){
            urlBuilder.append("/");
        }
        urlBuilder.append("console");
    }
    this.consoleUrl = urlBuilder.toString();
    //工程名称
    this.projectName = projectName;
    //环境名称
    if(config.topicName!=null){
        topicName = config.topicName;
    }
}
 
/**
 * Abort running builds when new build referencing same revision is scheduled to run
 */
@Override
public void preCheckout(AbstractBuild build, Launcher launcher, BuildListener listener) throws IOException,
        InterruptedException {
    String abortOnRevisionId = getAbortOnRevisionId(build);
    // If ABORT_ON_REVISION_ID is available
    if (!CommonUtils.isBlank(abortOnRevisionId)) {
        // Create a cause of interruption
        PhabricatorCauseOfInterruption causeOfInterruption =
                new PhabricatorCauseOfInterruption(build.getUrl());
        Run upstreamRun = getUpstreamRun(build);

        // Get the running builds that were scheduled before the current one
        RunList<AbstractBuild> runningBuilds = (RunList<AbstractBuild>) build.getProject().getBuilds();
        for (AbstractBuild runningBuild : runningBuilds) {
            Executor executor = runningBuild.getExecutor();
            Run runningBuildUpstreamRun = getUpstreamRun(runningBuild);

            // Ignore builds that were triggered by the same upstream build
            // Find builds triggered with the same ABORT_ON_REVISION_ID_FIELD
            if (runningBuild.isBuilding()
                    && runningBuild.number < build.number
                    && abortOnRevisionId.equals(getAbortOnRevisionId(runningBuild))
                    && (upstreamRun == null
                    || runningBuildUpstreamRun == null
                    || !upstreamRun.equals(runningBuildUpstreamRun))
                    && executor != null) {
                // Abort the builds
                executor.interrupt(Result.ABORTED, causeOfInterruption);
            }
        }
    }
}
 
源代码3 项目: gitlab-plugin   文件: TestUtility.java
@SuppressWarnings("ConstantConditions")
static String formatNote(AbstractBuild build, String note) {
    String buildUrl = Jenkins.getInstance().getRootUrl() + build.getUrl();
    return MessageFormat.format(note, build.getResult(), build.getParent().getDisplayName(), BUILD_NUMBER, buildUrl);
}