类hudson.model.JobProperty源码实例Demo

下面列出了怎么用hudson.model.JobProperty的API类实例代码及写法,或者点击链接到github查看源代码。

源代码1 项目: gogs-webhook-plugin   文件: GogsProjectProperty.java
public JobProperty<?> newInstance(StaplerRequest req, JSONObject formData) {
    GogsProjectProperty tpp = null;

    if (req != null) {
        tpp = req.bindJSON(
                GogsProjectProperty.class,
                formData.getJSONObject(GOGS_PROJECT_BLOCK_NAME)
        );
    }
    if (tpp != null) {
        LOGGER.finest(formData.toString());
        LOGGER.finest(tpp.gogsBranchFilter);

        gogsSecret = tpp.gogsSecret;
        gogsBranchFilter = tpp.gogsBranchFilter;
    }
    return tpp;
}
 
@Override
public JobProperty<?> newInstance(StaplerRequest request, JSONObject formData) throws FormException {
    if (formData.size() > 0 && formData.has("useTemplate")) {
        JSONObject useTemplate = formData.getJSONObject("useTemplate");

        String templateJobName = useTemplate.getString("templateJobName");
        boolean syncMatrixAxis = useTemplate.getBoolean("syncMatrixAxis");
        boolean syncDescription = useTemplate.getBoolean("syncDescription");
        boolean syncBuildTriggers = useTemplate.getBoolean("syncBuildTriggers");
        boolean syncDisabled = useTemplate.getBoolean("syncDisabled");
        boolean syncSecurity = useTemplate.getBoolean("syncSecurity");
        boolean syncScm = useTemplate.getBoolean("syncScm");
        boolean syncOwnership = useTemplate.getBoolean("syncOwnership");
        boolean syncAssignedLabel = useTemplate.getBoolean("syncAssignedLabel");

        return new TemplateImplementationProperty(templateJobName, syncMatrixAxis, syncDescription, syncBuildTriggers, syncDisabled, syncSecurity, syncScm, syncOwnership, syncAssignedLabel);
    }

    return null;
}
 
private void addGlobalProperties() {
    if (run instanceof WorkflowRun) {
        WorkflowRun workflowRun = (WorkflowRun) run;
        List<JobProperty<? super WorkflowJob>> properties = workflowRun.getParent().getAllProperties();
        for (JobProperty property : properties) {
            jobParameters.put(property.getClass().getSimpleName(), property);
        }
    }
}
 
源代码4 项目: ez-templates   文件: ProjectUtils.java
public static Collection<AbstractProject> findProjectsWithProperty(final Class<? extends JobProperty<?>> property) {
    List<AbstractProject> projects = Jenkins.getInstance().getAllItems(AbstractProject.class);
    return Collections2.filter(projects, new Predicate<AbstractProject>() {
        @Override
        public boolean apply(AbstractProject abstractProject) {
            return abstractProject.getProperty(property) != null;
        }
    });
}
 
源代码5 项目: ez-templates   文件: TemplateProperty.java
@Override
public JobProperty<?> newInstance(StaplerRequest request, JSONObject formData) throws FormException {
    if (formData.size() > 0) {
        return new TemplateProperty();
    }
    return null;
}
 
default EnvVars buildEnvVars() {
    EnvVars allOverrides = new EnvVars(EnvVars.masterEnvVars);
    // when running outside of an openshift pod, global env vars like
    // SKIP_TLS will not exist in master env vars
    if (Jenkins.getInstance().getGlobalNodeProperties() != null) {
        if (Jenkins.getInstance().getGlobalNodeProperties()
                .get(hudson.slaves.EnvironmentVariablesNodeProperty.class) != null) {
            if (Jenkins
                    .getInstance()
                    .getGlobalNodeProperties()
                    .get(hudson.slaves.EnvironmentVariablesNodeProperty.class)
                    .getEnvVars() != null) {
                allOverrides
                        .putAll(Jenkins
                                .getInstance()
                                .getGlobalNodeProperties()
                                .get(hudson.slaves.EnvironmentVariablesNodeProperty.class)
                                .getEnvVars());
            }
        }
    }
    String[] reqPieces = Stapler.getCurrentRequest().getRequestURI()
            .split("/");
    if (reqPieces != null && reqPieces.length > 2) {
        for (Job j : Jenkins.getInstance().getAllItems(Job.class)) {
            if (j.getName().equals(reqPieces[2])) {
                List<JobProperty> jps = j.getAllProperties();
                for (JobProperty jp : jps) {
                    if (jp instanceof ParametersDefinitionProperty) {
                        ParametersDefinitionProperty prop = (ParametersDefinitionProperty) jp;
                        for (ParameterDefinition param : prop
                                .getParameterDefinitions()) {
                            allOverrides.put(param.getName(), param
                                    .getDefaultParameterValue().getValue()
                                    .toString());
                        }
                    }
                }
            }
        }
    }
    return allOverrides;
}
 
源代码7 项目: gitlab-plugin   文件: GitLabConnectionProperty.java
@Override
public JobProperty<?> newInstance(StaplerRequest req, JSONObject formData) throws FormException {
    return req.bindJSON(GitLabConnectionProperty.class, formData);
}
 
源代码8 项目: DotCi   文件: DynamicSubProject.java
@Override
public <T extends JobProperty> T getProperty(final Class<T> clazz) {
    return getParent().getProperty(clazz);
}
 
 类所在包
 同包方法