How to use the @jenkins-cd/blueocean-core-js.UrlBuilder.buildRestUrl function in @jenkins-cd/blueocean-core-js

To help you get started, we’ve selected a few @jenkins-cd/blueocean-core-js examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github jenkinsci / blueocean-plugin / blueocean-pipeline-editor / src / main / js / EditorPage.jsx View on Github external
loadBranchMetadata() {
        const { organization, pipeline, branch } = this.props.params;

        if (!branch) {
            const split = pipeline.split('/');
            const team = split[0];
            const repo = split.length > 1 ? split[1] : team;
            const { id: scmId, apiUrl } = this.state.scmSource;
            const orgRestUrl = UrlBuilder.buildRestUrl(organization);
            let repositoryUrl = `${orgRestUrl}scm/${scmId}/organizations/${team}/repositories/${repo}/`;
            if (apiUrl) {
                repositoryUrl += `?apiUrl=${apiUrl}`;
            }
            return Fetch.fetchJSON(repositoryUrl)
                .then(({ defaultBranch }) => {
                    this.defaultBranch = defaultBranch || 'master';
                })
                .catch(err => (this.defaultBranch = 'master'));
        }

        this.defaultBranch = branch;
        return new Promise(resolve => resolve(null));
    }
github jenkinsci / blueocean-plugin / blueocean-dashboard / src / main / js / credentials / git / GitPWCredentialsApi.ts View on Github external
_getCredential(credentialId) {
        const orgUrl = UrlBuilder.buildRestUrl(this.organization);
        const credentialUrl = `${orgUrl}credentials/user/domains/blueocean-git-domain/credentials/${encodeURIComponent(credentialId)}/`;

        return this._fetch(credentialUrl);
    }
github jenkinsci / blueocean-plugin / blueocean-pipeline-editor / src / main / js / api / ScmContentApi.js View on Github external
loadContent({ organization, pipeline, branch, path = 'Jenkinsfile' }) {
        const pipelineUrl = UrlBuilder.buildRestUrl(organization, pipeline);
        let contentUrl = `${pipelineUrl}scm/content?path=${path}`;
        if (branch) {
            contentUrl += `&branch=${encodeURIComponent(branch)}`;
        }
        return Fetch.fetchJSON(contentUrl)
            .then(result => result)
            .catch(error => this._loadContentErrorHandler(error));
    }
github jenkinsci / blueocean-plugin / blueocean-pipeline-editor / src / main / js / api / ScmContentApi.js View on Github external
saveContent({ organization, pipeline, repo, sourceBranch, targetBranch, sha, message, path = 'Jenkinsfile', content }) {
        const contentUrl = `${UrlBuilder.buildRestUrl(organization, pipeline)}scm/content/`;

        const body = this.buildSaveContentRequest({
            organization,
            pipeline,
            repo,
            sourceBranch,
            targetBranch,
            sha,
            message,
            path,
            content,
        });

        const fetchOptions = {
            method: 'PUT',
            headers: { 'Content-Type': 'application/json' },