Skip to content

Commit

Permalink
feat(core): Add support for an Artifactory Trigger (#6664)
Browse files Browse the repository at this point in the history
Co-Authored-By: Ria Stein <eleftheria.kousathana@gmail.com>
  • Loading branch information
2 people authored and jkschneider committed Mar 12, 2019
1 parent bc2bf43 commit 35e82ac
Show file tree
Hide file tree
Showing 6 changed files with 96 additions and 1 deletion.
6 changes: 6 additions & 0 deletions app/scripts/modules/core/src/domain/ITrigger.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,12 @@ export interface ITrigger {
runAsUser?: string;
}

export interface IArtifactoryTrigger extends ITrigger {
artifactorySearchName: string;
artifactoryRepository: string;
type: 'artifactory';
}

export interface IGitTrigger extends ITrigger {
source: string;
project: string;
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
import * as React from 'react';
import Select, { Option } from 'react-select';

import { ITriggerConfigProps } from '@spinnaker/core';
import { IArtifactoryTrigger } from 'core/domain/ITrigger';
import { ArtifactoryReaderService } from './artifactoryReader.service';

export interface IArtifactoryTriggerConfigProps extends ITriggerConfigProps {
trigger: IArtifactoryTrigger;
}

export interface IArtifactoryTriggerConfigState {
artifactorySearchNames: string[];
}

export class ArtifactoryTriggerConfig extends React.Component<
IArtifactoryTriggerConfigProps,
IArtifactoryTriggerConfigState
> {
constructor(props: IArtifactoryTriggerConfigProps) {
super(props);
this.state = {
artifactorySearchNames: [],
};
}

public componentDidMount() {
ArtifactoryReaderService.getArtifactoryNames().then((names: string[]) => {
this.setState({
artifactorySearchNames: names,
});
});
}

private artifactorySearchNameChanged = (option: Option<string>) => {
const searchName = option.value;
Object.assign(this.props.trigger, { artifactorySearchName: searchName });
this.props.fieldUpdated();
this.setState({});
};

public render() {
const { trigger } = this.props;
const { artifactorySearchNames } = this.state;
const { artifactorySearchName } = trigger;
return (
<div className="sp-formItem">
<div className="sp-formItem__left">
<div className="sp-formLabel">Artifactory Name</div>
</div>
<div className="sp-formItem__right">
<div className="sp-form">
<span className="field">
<Select
value={artifactorySearchName}
placeholder="Select Artifactory name"
onChange={this.artifactorySearchNameChanged}
options={artifactorySearchNames.map((name: string) => ({ label: name, value: name }))}
clearable={false}
/>
</span>
</div>
</div>
</div>
);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import { IPromise } from 'angular';

import { API } from 'core/api/ApiService';

export class ArtifactoryReaderService {
public static getArtifactoryNames(): IPromise<string[]> {
return API.one('artifactory')
.one('names')
.get();
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import { ArtifactoryTriggerConfig } from './ArtifactoryTriggerConfig';
import { Registry } from '@spinnaker/core';

Registry.pipeline.registerTrigger({
label: 'Artifactory',
description: 'Executes the pipeline on an Artifactory repo update',
key: 'artifactory',
component: ArtifactoryTriggerConfig,
validators: [],
});
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
const angular = require('angular');

import { RUN_AS_USER_SELECTOR_COMPONENT } from './runAsUserSelector.component';
import './artifactory/artifactoryTrigger';
import { TRAVIS_TRIGGER } from './travis/travisTrigger.module';
import { WERCKER_TRIGGER } from './wercker/werckerTrigger.module';
import { GIT_TRIGGER } from './git/git.trigger';
Expand Down
2 changes: 1 addition & 1 deletion settings.js
Original file line number Diff line number Diff line change
Expand Up @@ -227,7 +227,7 @@ window.spinnakerSettings = {
},
pubsubProviders: ['google'], // TODO(joonlim): Add amazon once it is confirmed that amazon pub/sub works.
searchVersion: 1,
triggerTypes: ['cron', 'docker', 'git', 'jenkins', 'pipeline', 'pubsub', 'travis', 'wercker'],
triggerTypes: ['artifactory', 'cron', 'docker', 'git', 'jenkins', 'pipeline', 'pubsub', 'travis', 'wercker'],
useClassicFirewallLabels: useClassicFirewallLabels,
whatsNew: {
fileName: 'news.md',
Expand Down

0 comments on commit 35e82ac

Please sign in to comment.