Project

General

Profile

redmine_lib

a bash library for redmine adminsitration

Simple examples

Here is an example script to add a new version to a project
with an associated wiki file page:

#!/bin/bash

project=$1
version=$2
wikipagefile=$3

pagename="Release_$version" 

. ${REDMINE_LIB_DIR}/redmine_lib

do_login

add_version myproject $project $version $pagename "" "Upcoming release $version" 
upload_wiki_page $wikipagefile $project $pagename

Required Files

The files:

  • $REDMINE_AUTH_DIR/.redmine_lib_passfile
  • $REDMINE_AUTH_DIR/.redmine_lib_ldap_passfile
    are required for username and password for lib to use when connecting.
    $REDMINE_AUTH_DIR defaults to current directory.

Useful Routines

add_group_member group member Add a new member to a group.
Prequisites -- do_login,slurp_user_groups|slurp_groups

add_user_from_services username Look up a user in services ldap, and add them to Redmine.
Needs a site admin account.
Prequisites -- do_login

add_watcher type objid user-id-list Add watchers to things. The type is the type
of thing (i.e "issue") and the object_id is the id number. The user-id-list is the numeric
user id of a user (see slurp_users , below).
Example:

add_watcher issue 2345 500,501

Prequisites -- do_login

add_version project version pagename date descriptpion [sharing] Add a new version to a project with optional wiki page, effective date, etc.
Prequisites -- do_login

modify_version project version field-name value Update an existing version, field-names should be one of:

  • name -- version name
  • description -- description of release
  • wiki_page_title -- wiki page name associated with release
  • effective_date -- date (yyyy-mm-dd format)
  • status -- {open,locked,closed}
  • sharing -- {none,descendants,hierarchy,tree,system}

Prequisites -- do_login

cleanup Cleans out generated /tmp/files.

get_project_managers project gives list of project's manager members' user-ids.

get_project_members project gives list of project's members' user-ids.

do_login uses $user and $pass read from .redmine_pass_file to login to the site, and keep cookies for other calls.

lookup_user user_id Gives user name for user user_id.
Prequisites -- do_login, slurp_users

show_text_result Gives tag-stripped version of last page fetch. Usefull
to look for error messages/debugging.

slurp_groups Get list of groups in site.
Requires admin user.
Prequisites -- do_login

slurp_users Get list of users in site.
Requires admin user.
Prequisites -- do_login

fetch_wiki_page project_name page_name gives the source text for a wiki page to stdout.
Prequisites -- do_login

upload_wiki_page file project_name page_name add a wiki page named page_name to project project_name with
contents from file.
Prequisites -- do_login

Mid-level scraper routines

fetch_items [-2] item page scrapes links mentioning "item" from page
So fetch_items user user gets ${site}/user, and looks for tags
of the form
<a href="...user/xxx">yyy</a>and gives you a list of the xxx yyy pairs; or just the xxx items
if it is passed -2.

fetch_items_slice [-2] item page start_re end_re fetch_items with a start/end sed regexp

filter_items back-end of fetch_items, pulls out parts of tags

get_auth_token scrapes an authenticity token from a form page. Leaves a copy
of said page in /tmp/at_p$$

get_content_version scrapes a content_version from a wiki page form

low level routines

urlencode string Url encode a string

fetch_url url fetch a url from the site to stdout

post_url url var=val var=val ... post a url with data

Test routines

  • test_do_login
  • test_add_version
  • test_fetch_items
  • test_slurp_users
  • test_suite
  • test_upload_wiki_page
  • todays_test