Skip to content

Commit

Permalink
fix(artifact/bitbucket): Bitbucket Use Default Artifact (#7523)
Browse files Browse the repository at this point in the history
* fix(artifact/bitbucket): Bitbucket Use Default Artifact edit Object path field

* remove regex on event onChange for Object Path field
  • Loading branch information
jorgebee65 authored and ethanfrogers committed Oct 16, 2019
1 parent ed7c445 commit c8c06e4
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 21 deletions.
2 changes: 2 additions & 0 deletions app/scripts/modules/core/src/help/help.contents.ts
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,8 @@ const helpContents: { [key: string]: string } = {
'pipeline.config.expectedArtifact.defaultBitbucket.reference': `
<p>The Bitbucket API file url the artifact lives under. The domain name may change if you're running your own Bitbucket server. The repository and path to files must be URL encoded.</p>
<p>An example is <code>https://api.bitbucket.org/1.0/repositories/$ORG/$REPO/raw/$VERSION/$FILEPATH</code>. See <a href="https://www.spinnaker.io/reference/artifacts/types/bitbucket-file/#fields">our docs</a> for more info.</p>`,
'pipeline.config.expectedArtifact.defaultBitbucket.filepath': `
<p>The file path within your repo. path/to/file.yml is an example.</p>`,
'pipeline.config.trigger.webhook.source': `
<p>Determines the target URL required to trigger this pipeline, as well as how the payload can be transformed into artifacts.</p>
`,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,35 +42,39 @@ export const BitbucketDefault: IArtifactKindConfig = {
}

private onReferenceChanged = (reference: string) => {
const bitbucketCloudRegex = new RegExp('/1.0/repositories/[^/]*/[^/]*/raw/[^/]*/(.*)$');
const bitbucketServerRegex = new RegExp('/projects/[^/]*/repos/[^/]*/raw/([^?]*)');

const clonedArtifact = cloneDeep(this.props.artifact);
clonedArtifact.reference = reference;
this.props.onChange(clonedArtifact);
};

let results;
results = bitbucketCloudRegex.exec(reference);
if (results === null) {
results = bitbucketServerRegex.exec(reference);
}

if (results !== null) {
clonedArtifact.name = decodeURIComponent(results[1]);
}
private onFilePathChanged = (name: string) => {
const clonedArtifact = cloneDeep(this.props.artifact);
clonedArtifact.name = name;
this.props.onChange(clonedArtifact);
};

public render() {
return (
<StageConfigField label="Object path" helpKey="pipeline.config.expectedArtifact.defaultBitbucket.reference">
<SpelText
placeholder="https://api.bitbucket.com/repos/$ORG/$REPO/contents/$FILEPATH"
value={this.props.artifact.reference}
onChange={this.onReferenceChanged}
pipeline={this.props.pipeline}
docLink={true}
/>
</StageConfigField>
<>
<StageConfigField label="Object path" helpKey="pipeline.config.expectedArtifact.defaultBitbucket.reference">
<SpelText
placeholder="https://api.bitbucket.com/rest/api/1.0/$PROJECTS/$PROJECTKEY/repos/$REPONAME/raw/$FILEPATH"
value={this.props.artifact.reference}
onChange={this.onReferenceChanged}
pipeline={this.props.pipeline}
docLink={true}
/>
</StageConfigField>
<StageConfigField label="File Path" helpKey="pipeline.config.expectedArtifact.defaultBitbucket.filepath">
<SpelText
placeholder="path/to/file.yml"
onChange={this.onFilePathChanged}
value={this.props.artifact.name}
pipeline={this.props.pipeline}
docLink={true}
/>
</StageConfigField>
</>
);
}
},
Expand Down

0 comments on commit c8c06e4

Please sign in to comment.