Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
fetchOptions: {
method: 'POST',
body: body,
headers: headers,
disableLoadingIndicator: disableLoadingIndicator,
},
}).then(data => {
if (data.status === 'ok') {
handler(data.data);
}
});
};
if (cache.crumb) {
useCrumb(cache.crumb);
} else {
Fetch.fetch(`${UrlConfig.getJenkinsRootURL()}/blue/rest/pipeline-metadata/crumbInfo`, {
fetchOptions: { method: 'GET', disableLoadingIndicator: disableLoadingIndicator },
}).then(response => {
if (!response.ok) {
if (window.isDevelopmentMode) console.error('An error occurred while fetching:', path);
throw response;
}
if (cache.crumb) {
useCrumb(cache.crumb);
} else {
try {
let crumb = response.text();
if (crumb.then) {
crumb
.then(c => {
cache.crumb = c;const AdminLink = props => {
const { t } = props;
const user = User.current();
const showLink = !Security.isSecurityEnabled() || (user && user.isAdministrator);
if (showLink) {
var adminCaption = t('administration', {
defaultValue: 'Administration',
});
return <a href="{`${UrlConfig.getJenkinsRootURL()}/manage`}">{adminCaption}</a>;
}
return null;
};findBranches(pipelineName) {
const path = UrlConfig.getJenkinsRootURL();
const pipelineUrl = Utils.cleanSlashes(`${path}/blue/rest/organizations/${this.organization}/pipelines/${pipelineName}/`);
return this._fetch(pipelineUrl)
.then(response => capabilityAugmenter.augmentCapabilities(response))
.then(pipeline => this._findBranchesSuccess(pipeline), error => this._findBranchesFailure(error));
}createServer(serverName, serverUrl) {
const path = UrlConfig.getJenkinsRootURL();
const createUrl = Utils.cleanSlashes(`${path}/blue/rest/organizations/${this.organization}/scm/${this.scmId}/servers`);
const requestBody = {
name: serverName,
apiUrl: serverUrl,
};
const fetchOptions = {
method: 'POST',
headers: {
'Content-Type': 'application/json',
},
body: JSON.stringify(requestBody),
};
return this._fetch(createUrl, { fetchOptions });listServers() {
const path = UrlConfig.getJenkinsRootURL();
const serversUrl = Utils.cleanSlashes(`${path}/blue/rest/organizations/${this.organization}/scm/${this.scmId}/servers`);
return this._fetch(serversUrl);
}function generateRedirectURL(pipeline) {
if (capable(pipeline, MATRIX_PIPELINE)) {
return `${UrlConfig.getJenkinsRootURL()}${pipeline._links.self.href}`;
}
return null;
}listRepositories(credentialId, apiUrl, organizationName, pageNumber = 1, pageSize = 100) {
const path = UrlConfig.getJenkinsRootURL();
let reposUrl = Utils.cleanSlashes(
`${path}/blue/rest/organizations/${this.organization}/scm/${this.scmId}/organizations/${organizationName}/repositories/` +
`?credentialId=${credentialId}&pageNumber=${pageNumber}&pageSize=${pageSize}`
);
reposUrl = GithubApiUtils.appendApiUrlParam(reposUrl, apiUrl);
return this._fetch(reposUrl).then(response => capabilityAugmenter.augmentCapabilities(response));
}const cause = run => {
const lastCause = (run && run.causes && run.causes.length > 0 && run.causes[run.causes.length - 1]) || null;
if (lastCause && lastCause.upstreamProject) {
const activityUrl = `${UrlConfig.getJenkinsRootURL()}/${lastCause.upstreamUrl}display/redirect?provider=blueocean`;
const runUrl = `${UrlConfig.getJenkinsRootURL()}/${lastCause.upstreamUrl}${lastCause.upstreamBuild}/display/redirect?provider=blueocean`;
return (
<div title="{lastCause.shortDescription}">
Started by upstream pipeline "<a href="{activityUrl}">{lastCause.upstreamProject}</a>" build{' '}
<a href="{runUrl}">#{lastCause.upstreamBuild}</a>
</div>
);
}
const causeMessage = (lastCause && lastCause.shortDescription) || null;
return (
<div title="{causeMessage}">
{causeMessage}
</div>
);
};listOrganizations(credentialId, apiUrl) {
const path = UrlConfig.getJenkinsRootURL();
let orgsUrl = Utils.cleanSlashes(
`${path}/blue/rest/organizations/${this.organization}/scm/${this.scmId}/organizations/?credentialId=${credentialId}`,
false
);
orgsUrl = GithubApiUtils.appendApiUrlParam(orgsUrl, apiUrl);
return this._fetch(orgsUrl)
.then(orgs => capabilityAugmenter.augmentCapabilities(orgs))
.then(orgs => this._listOrganizationsSuccess(orgs), error => this._listOrganizationsFailure(error));
}findExistingOrgFolder(githubOrganization) {
const path = UrlConfig.getJenkinsRootURL();
const orgFolderUrl = Utils.cleanSlashes(`${path}/blue/rest/organizations/${this.organization}/pipelines/${githubOrganization.name}`);
return this._fetch(orgFolderUrl)
.then(response => capabilityAugmenter.augmentCapabilities(response))
.then(data => this._findExistingOrgFolderSuccess(data), error => this._findExistingOrgFolderFailure(error));
}