Skip to content

Commit

Permalink
BEAM-4687 create JIRA client
Browse files Browse the repository at this point in the history
  • Loading branch information
Yifan Zou committed Jul 13, 2018
1 parent 6c0e433 commit be42aba
Show file tree
Hide file tree
Showing 2 changed files with 84 additions and 29 deletions.
62 changes: 62 additions & 0 deletions .test-infra/jenkins/jira/jira_client.py
@@ -0,0 +1,62 @@
#
# Licensed to the Apache Software Foundation (ASF) under one or more
# contributor license agreements. See the NOTICE file distributed with
# this work for additional information regarding copyright ownership.
# The ASF licenses this file to You under the Apache License, Version 2.0
# (the "License"); you may not use this file except in compliance with
# the License. You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#

from jira import JIRA



class JiraClient:
def __init__(self, options, basic_auth, project):
self.jira = JIRA(options, basic_auth=basic_auth)
self.project = self.jira.project(project)


def get_issues_all(self):
# TODO
pass


def get_issue(self, key):
try:
issue = self.jira.issue(key)
except Exception, e:
raise
return issue


def create_issue(self, summary, components, description='', issuetype='Bug', assignee=None, parent_key=None):
issue_dict = {
'project': {'key': self.project},
'summary': summary,
'description': description,
'issuetype': {'name': issuetype},
'components': [{'name': components}],
}
if assignee is not None:
issue_dict['assignee'] = {'name': assignee}
if parent_key is not None:
issue_dict['parent'] = {'key': parent_key}
new_issue = self.jira.create_issue(fields = issue_dict)


def comment_issue(self):
#TODO:
pass

def close_issue(self):
#TODO:
pass
51 changes: 22 additions & 29 deletions .test-infra/jenkins/job_Dependency_Check.groovy
Expand Up @@ -36,39 +36,32 @@ job('beam_Dependency_Check') {
'0 12 * * 1')

steps {
// gradle {
// rootBuildScriptDir(common_job_properties.checkoutDir)
// tasks(':runBeamDependencyCheck')
// common_job_properties.setGradleSwitches(delegate)
// switches('-Drevision=release')
// }
//
// shell('cd ' + common_job_properties.checkoutDir +
// ' && bash .test-infra/jenkins/dependency_check/generate_report.sh')
shell('echo \'Test Jenkins JIRA plugin \'')
gradle {
rootBuildScriptDir(common_job_properties.checkoutDir)
tasks(':runBeamDependencyCheck')
common_job_properties.setGradleSwitches(delegate)
switches('-Drevision=release')
}

shell('cd ' + common_job_properties.checkoutDir +
' && bash .test-infra/jenkins/dependency_check/generate_report.sh')
}

def date = new Date().format('yyyy-MM-dd')
publishers {
// extendedEmail {
// triggers {
// always {
// recipientList('dev@beam.apache.org')
// contentType('text/html')
// subject("Beam Dependency Check Report (${date})")
// content('''${FILE, path="src/build/dependencyUpdates/beam-dependency-check-report.html"}''')
// }
// }
// }
// archiveArtifacts {
// pattern('src/build/dependencyUpdates/beam-dependency-check-report.html')
// onlyIfSuccessful()
// }
createJiraIssue {
projectKey('BEAM')
testDescription('Jenkins JIRA Plugin Test')
assignee('yifanzou')
component('dependencies')
extendedEmail {
triggers {
always {
recipientList('dev@beam.apache.org')
contentType('text/html')
subject("Beam Dependency Check Report (${date})")
content('''${FILE, path="src/build/dependencyUpdates/beam-dependency-check-report.html"}''')
}
}
}
archiveArtifacts {
pattern('src/build/dependencyUpdates/beam-dependency-check-report.html')
onlyIfSuccessful()
}
}
}

0 comments on commit be42aba

Please sign in to comment.