use of io.fabric8.openshift.api.model.BuildTriggerPolicy in project strimzi by strimzi.
the class KafkaConnectS2ICluster method generateBuildConfig.
/**
* Generate new BuildConfig
*
* @return BuildConfig resource definition
*/
public BuildConfig generateBuildConfig() {
BuildTriggerPolicy triggerConfigChange = new BuildTriggerPolicy();
triggerConfigChange.setType("ConfigChange");
BuildTriggerPolicy triggerImageChange = new BuildTriggerPolicy();
triggerImageChange.setType("ImageChange");
triggerImageChange.setImageChange(new ImageChangeTrigger());
BuildConfig build = new BuildConfigBuilder().withNewMetadata().withName(name).withLabels(getLabelsWithName()).withNamespace(namespace).endMetadata().withNewSpec().withFailedBuildsHistoryLimit(5).withNewOutput().withNewTo().withKind("ImageStreamTag").withName(image).endTo().endOutput().withRunPolicy("Serial").withNewSource().withType("Binary").withBinary(new BinaryBuildSource()).endSource().withNewStrategy().withType("Source").withNewSourceStrategy().withNewFrom().withKind("ImageStreamTag").withName(getSourceImageStreamName() + ":" + sourceImageTag).endFrom().endSourceStrategy().endStrategy().withTriggers(triggerConfigChange, triggerImageChange).endSpec().build();
return build;
}
use of io.fabric8.openshift.api.model.BuildTriggerPolicy in project fabric8 by fabric8io.
the class Builds method configureDefaultBuildConfig.
public static BuildConfig configureDefaultBuildConfig(BuildConfig buildConfig, String name, String gitUrl, boolean foundExistingGitUrl, String buildImageStream, String buildImageTag, String s2iCustomBuilderImage, String secret, String jenkinsUrl) {
BuildConfigSpec spec = buildConfig.getSpec();
if (spec == null) {
spec = new BuildConfigSpec();
buildConfig.setSpec(spec);
}
if (!foundExistingGitUrl && Strings.isNotBlank(gitUrl)) {
BuildSource source = spec.getSource();
if (source == null) {
source = new BuildSource();
spec.setSource(source);
}
source.setType("Git");
GitBuildSource git = source.getGit();
if (git == null) {
git = new GitBuildSource();
source.setGit(git);
}
git.setUri(gitUrl);
}
if (Strings.isNotBlank(buildImageStream) && Strings.isNotBlank(buildImageTag)) {
BuildStrategy strategy = spec.getStrategy();
if (strategy == null) {
strategy = new BuildStrategy();
spec.setStrategy(strategy);
}
// TODO only do this if we are using Jenkins?
strategy.setType("JenkinsPipeline");
JenkinsPipelineBuildStrategy buildStrategy = strategy.getJenkinsPipelineStrategy();
if (buildStrategy == null) {
buildStrategy = new JenkinsPipelineBuildStrategy();
strategy.setJenkinsPipelineStrategy(buildStrategy);
}
ListEnvVarBuilder envBuilder = new ListEnvVarBuilder();
if (Strings.isNotBlank(jenkinsUrl)) {
envBuilder.withEnvVar("BASE_URI", jenkinsUrl);
}
buildStrategy.setJenkinsfilePath("Jenkinsfile");
}
List<BuildTriggerPolicy> triggers = spec.getTriggers();
if (triggers == null) {
triggers = new ArrayList<>();
}
if (triggers.isEmpty()) {
triggers.add(new BuildTriggerPolicyBuilder().withType("GitHub").withNewGithub().withSecret(secret).endGithub().build());
triggers.add(new BuildTriggerPolicyBuilder().withType("Generic").withNewGeneric().withSecret(secret).endGeneric().build());
spec.setTriggers(triggers);
}
return buildConfig;
}
use of io.fabric8.openshift.api.model.BuildTriggerPolicy in project fabric8 by jboss-fuse.
the class Builds method configureDefaultBuildConfig.
public static BuildConfig configureDefaultBuildConfig(BuildConfig buildConfig, String name, String gitUrl, boolean foundExistingGitUrl, String buildImageStream, String buildImageTag, String s2iCustomBuilderImage, String secret, String jenkinsUrl) {
BuildConfigSpec spec = buildConfig.getSpec();
if (spec == null) {
spec = new BuildConfigSpec();
buildConfig.setSpec(spec);
}
if (!foundExistingGitUrl && Strings.isNotBlank(gitUrl)) {
BuildSource source = spec.getSource();
if (source == null) {
source = new BuildSource();
spec.setSource(source);
}
source.setType("Git");
GitBuildSource git = source.getGit();
if (git == null) {
git = new GitBuildSource();
source.setGit(git);
}
git.setUri(gitUrl);
}
if (Strings.isNotBlank(buildImageStream) && Strings.isNotBlank(buildImageTag)) {
BuildStrategy strategy = spec.getStrategy();
if (strategy == null) {
strategy = new BuildStrategy();
spec.setStrategy(strategy);
}
// TODO only do this if we are using Jenkins?
strategy.setType("JenkinsPipeline");
JenkinsPipelineBuildStrategy buildStrategy = strategy.getJenkinsPipelineStrategy();
if (buildStrategy == null) {
buildStrategy = new JenkinsPipelineBuildStrategy();
strategy.setJenkinsPipelineStrategy(buildStrategy);
}
ListEnvVarBuilder envBuilder = new ListEnvVarBuilder();
if (Strings.isNotBlank(jenkinsUrl)) {
envBuilder.withEnvVar("BASE_URI", jenkinsUrl);
}
buildStrategy.setJenkinsfilePath("Jenkinsfile");
}
List<BuildTriggerPolicy> triggers = spec.getTriggers();
if (triggers == null) {
triggers = new ArrayList<>();
}
if (triggers.isEmpty()) {
triggers.add(new BuildTriggerPolicyBuilder().withType("GitHub").withNewGithub().withSecret(secret).endGithub().build());
triggers.add(new BuildTriggerPolicyBuilder().withType("Generic").withNewGeneric().withSecret(secret).endGeneric().build());
spec.setTriggers(triggers);
}
return buildConfig;
}
Aggregations