本文整理汇总了Java中io.fabric8.openshift.api.model.GitBuildSource类的典型用法代码示例。如果您正苦于以下问题:Java GitBuildSource类的具体用法?Java GitBuildSource怎么用?Java GitBuildSource使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
GitBuildSource类属于io.fabric8.openshift.api.model包,在下文中一共展示了GitBuildSource类的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: BuildCause
import io.fabric8.openshift.api.model.GitBuildSource; //导入依赖的package包/类
public BuildCause(Build build, String buildConfigUid) {
this.buildConfigUid = buildConfigUid;
if (build == null || build.getMetadata() == null) {
return;
}
ObjectMeta meta = build.getMetadata();
uid = meta.getUid();
namespace = meta.getNamespace();
name = meta.getName();
if (build.getSpec() != null) {
if (build.getSpec().getSource() != null
&& build.getSpec().getSource().getGit() != null) {
GitBuildSource git = build.getSpec().getSource().getGit();
gitUri = git.getUri();
}
if (build.getSpec().getRevision() != null
&& build.getSpec().getRevision().getGit() != null) {
commit = build.getSpec().getRevision().getGit().getCommit();
}
}
}
示例2: processGitRepo
import io.fabric8.openshift.api.model.GitBuildSource; //导入依赖的package包/类
/**
* This method is public for easier unit testing
*/
public int processGitRepo(NamespaceName name, String gitUrl, String gitRef) throws IOException {
BuildConfig buildConfig = new BuildConfig();
BuildConfigSpec buildConfigSpec = new BuildConfigSpec();
buildConfig.setSpec(buildConfigSpec);
BuildSource buildSource = new BuildSource();
buildSource.setType("Git");
GitBuildSource gitSource = new GitBuildSource();
gitSource.setUri(gitUrl);
if (Strings.isNullOrBlank(gitRef)) {
gitRef = "master";
}
gitSource.setRef(gitRef);
buildSource.setGit(gitSource);
buildConfigSpec.setSource(buildSource);
return processGitRepo(name, buildConfig, gitSource, gitUrl);
}
示例3: hasEmbeddedPipelineOrValidSource
import io.fabric8.openshift.api.model.GitBuildSource; //导入依赖的package包/类
private boolean hasEmbeddedPipelineOrValidSource(BuildConfig buildConfig) {
BuildConfigSpec spec = buildConfig.getSpec();
if (spec != null) {
BuildStrategy strategy = spec.getStrategy();
if (strategy != null) {
JenkinsPipelineBuildStrategy jenkinsPipelineStrategy = strategy.getJenkinsPipelineStrategy();
if (jenkinsPipelineStrategy != null) {
if (StringUtils.isNotBlank(jenkinsPipelineStrategy.getJenkinsfile())) {
return true;
}
if (StringUtils.isNotBlank(jenkinsPipelineStrategy.getJenkinsfilePath())) {
BuildSource source = spec.getSource();
if (source != null) {
GitBuildSource git = source.getGit();
if (git != null) {
if (StringUtils.isNotBlank(git.getUri())) {
return true;
}
}
// TODO support other SCMs
}
}
}
}
}
return false;
}
示例4: gitBuildSource
import io.fabric8.openshift.api.model.GitBuildSource; //导入依赖的package包/类
public static GitBuildSource gitBuildSource(BuildConfig buildConfig) {
GitBuildSource git = null;
BuildConfigSpec spec = buildConfig.getSpec();
if (spec != null) {
BuildSource source = spec.getSource();
if (source != null) {
git = source.getGit();
}
}
return git;
}
示例5: process
import io.fabric8.openshift.api.model.GitBuildSource; //导入依赖的package包/类
@Override
public void process(NamespaceName name, BuildConfig buildConfig) throws Exception {
String uri = KubernetesHelper.getOrCreateAnnotations(buildConfig).get(GIT_CLONE_URL);
GitBuildSource git = gitBuildSource(buildConfig);
if (git != null) {
if (Strings.isNullOrBlank(uri)) {
uri = git.getUri();
}
if (Strings.isNotBlank(uri)) {
processGitRepo(name, buildConfig, git, uri);
}
}
}
示例6: mapBuildConfigToFlow
import io.fabric8.openshift.api.model.GitBuildSource; //导入依赖的package包/类
public static FlowDefinition mapBuildConfigToFlow(BuildConfig bc) throws IOException {
if (!OpenShiftUtils.isPipelineStrategyBuildConfig(bc)) {
return null;
}
BuildConfigSpec spec = bc.getSpec();
BuildSource source = null;
String jenkinsfile = null;
String jenkinsfilePath = null;
if (spec != null) {
source = spec.getSource();
BuildStrategy strategy = spec.getStrategy();
if (strategy != null) {
JenkinsPipelineBuildStrategy jenkinsPipelineStrategy = strategy.getJenkinsPipelineStrategy();
if (jenkinsPipelineStrategy != null) {
jenkinsfile = jenkinsPipelineStrategy.getJenkinsfile();
jenkinsfilePath = jenkinsPipelineStrategy.getJenkinsfilePath();
}
}
}
if (jenkinsfile == null) {
// Is this a Jenkinsfile from Git SCM?
if (source != null && source.getGit() != null && source.getGit().getUri() != null) {
if (jenkinsfilePath == null) {
jenkinsfilePath = DEFAULT_JENKINS_FILEPATH;
}
if (!isEmpty(source.getContextDir())) {
jenkinsfilePath = new File(source.getContextDir(), jenkinsfilePath).getPath();
}
GitBuildSource gitSource = source.getGit();
String branchRef = gitSource.getRef();
List<BranchSpec> branchSpecs = Collections.emptyList();
if (isNotBlank(branchRef)) {
branchSpecs = Collections.singletonList(new BranchSpec(branchRef));
}
String credentialsId = updateSourceCredentials(bc);
// if credentialsID is null, go with an SCM where anonymous has to be sufficient
GitSCM scm = new GitSCM(
Collections.singletonList(new UserRemoteConfig(gitSource.getUri(), null, null, credentialsId)),
branchSpecs, false, Collections.<SubmoduleConfig>emptyList(), null, null,
Collections.<GitSCMExtension>emptyList());
return new CpsScmFlowDefinition(scm, jenkinsfilePath);
} else {
LOGGER.warning("BuildConfig does not contain source repository information - "
+ "cannot map BuildConfig to Jenkins job");
return null;
}
} else {
return new CpsFlowDefinition(jenkinsfile, true);
}
}