Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
C
configuration
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
OpenEdx
configuration
Commits
ce4988a4
Commit
ce4988a4
authored
Dec 12, 2013
by
Feanil Patel
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add logic to be able to monitor RCs from jenkins.
parent
5621dbd0
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
55 additions
and
17 deletions
+55
-17
util/jenkins/monitor_repos.py
+55
-17
No files found.
util/jenkins/monitor_repos.py
View file @
ce4988a4
import
argparse
import
json
import
logging
as
log
import
pickle
import
requests
import
yaml
from
datetime
import
datetime
from
git
import
*
from
git
import
Repo
from
os
import
path
from
pprint
import
pformat
from
pprint
import
pprint
from
pymongo
import
MongoClient
,
DESCENDING
from
stage_release
import
flip_repos
,
uri_from
def
release_hashes
(
repo
):
for
ref
in
repo
.
remotes
.
origin
.
refs
:
def
releases
(
repo
):
for
ref
in
repo
.
refs
:
if
ref
.
name
.
startswith
(
'origin/rc/'
):
yield
ref
.
commit
.
hexsha
yield
ref
def
c
heck_all
(
args
):
config
=
yaml
.
safe_load
(
open
(
args
.
config
))
client
=
MongoClient
(
uri_from
(
config
[
'DOC_STORE_CONFIG'
])
)
repos
=
[
Repo
(
repo_dir
)
for
repo_dir
in
config
[
'repos'
]]
configuration_repo
=
Repo
(
config
[
'configuration_repo'
])
configuration_secure
=
Repo
(
config
[
'configuration_secure'
])
def
c
andidates_since
(
repo
,
time
):
for
rc
in
releases
(
repo
):
last_update
=
datetime
.
utcfromtimestamp
(
rc
.
commit
.
committed_date
)
if
last_update
>
time
:
# New RC or updated RC
yield
rc
for
repo
in
repos
:
for
git_hash
in
release_hashes
(
repo
):
pass
def
stage_release
(
url
,
token
,
repo
,
rc
):
params
=
[]
params
.
append
({
'name'
:
"{}_REF"
.
format
(
repo
),
'value'
:
True
})
params
.
append
({
'name'
:
repo
,
'value'
:
rc
.
commit
.
hexsha
})
build_params
=
{
'parameter'
:
params
}
log
.
info
(
"New rc found{}, staging new release."
.
format
(
rc
.
name
))
r
=
requests
.
post
(
url
,
data
=
{
"token"
,
token
},
params
=
{
"json"
:
json
.
dumps
(
build_params
)})
if
r
.
status_code
!=
201
:
msg
=
"Failed to submit request with params: {}"
raise
Exception
(
msg
.
format
(
pformat
(
build_params
)))
if
__name__
==
"__main__"
:
parser
=
argparse
.
ArgumentParser
(
description
=
"Monitor git repos for new rc branches."
)
parser
.
add_argument
(
'-c'
,
'--config'
,
required
=
True
,
parser
.
add_argument
(
'-c'
,
'--config'
,
required
=
True
,
help
=
"Config file."
)
parser
.
add_argument
(
'-p'
,
'--pickle'
,
default
=
"data.pickle"
,
help
=
"Pickle of presistent data."
)
args
=
parser
.
parse_args
()
check_all
(
args
)
config
=
yaml
.
safe_load
(
open
(
args
.
config
))
if
path
.
exists
(
args
.
pickle
):
data
=
pickle
.
load
(
open
(
args
.
pickle
))
else
:
data
=
{}
if
'last_check'
not
in
data
:
last_check
=
datetime
.
utcnow
()
else
:
last_check
=
data
[
'last_check'
]
data
[
'last_check'
]
=
datetime
.
utcnow
()
all_plays
=
flip_repos
(
config
[
'repos'
])
# Find plays that are affected by this repo.
repos_with_changes
=
{}
for
repo
in
config
[
'repos'
]:
# Check for new rc candidates.
for
rc
in
candidates_since
(
Repo
(
repo
),
last_check
):
# Notify stage-release to build for the new repo.
stage_release
(
config
[
'abby_url'
],
config
[
'abby_token'
],
repo
,
rc
)
pickle
.
dump
(
data
,
open
(
args
.
pickle
,
'w'
))
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment