Since I moved to orgmode I have been trying to make this work with most of my environnment. Since I work with gitlab on a daily basis I thought I would start there first.

Libraries

Org Parse

Org Format

Convert stuff : pypandoc

Python for Gitlab

Command Line framework

Others

Gitlab Token : Docs

Scope - what are we building

Let’s automate most of the work that is redudant with gitlab.

  • Users

    • Create, update, delete, list
    • Add to specific project
    • Affect task
    • Onboard
  • Create issues based an org file.

But more specifically 2 things are a priority right now :

  • onboard users
  • publish issues from a project file

Onboarding

The way I have implemented onboarding is simply to create have an onboard project (actually 2, one for internal onboarding, and one for contractor onboarding), where users get added and affected an “Welcome” issue describing for them the onboarding process.

So a first crude version of our onboarding function will look like this :

  • identify is user is internal or external (to define which onboarding process they belong too)

  • then add the user (user was created first) to the onboarding project ( I have hard coded the project id - yeah, it’s bad, we’ll fix that later )

  • then create an issue (turn out you need to create and assign the issue, else the user does not get the email properly)

  • then make the issue confidential

    So it give something like that.

          def onboard_user(username, external, template_file):
              """onboard users"""
              project_id = 34 # TODO: move to a config file
              if external:
                  project_id = 24
    
              user = add_user_to_project(username, project_id)
    
              issue_content = org.issue_from_template('onboarding',template_file)
              issue = create_and_assign_project_issue(project_id, issue_content, username)
              issue.confidential = True
              issue.save()
    
              print("Onboarded user", username)
              return user
    

    But before we can onboard anyone we need to create the users and authorize with the API

    For now, it’s happening from the command line.

    Next step will be to migrate that interactive command line and mostly to be managed from an org file, where I can add user, save them as contacts, and batch update the creation and onboarding of anyone.

    But let’s see for now the creation of a users :

          def create_user(name, username, email, password):
              """create user"""
              user = gl.users.create({'name':name,
                                      'username':username,
                                      'email': email,
                                      'password': password})
              print("Created user:", user.username)
    

    Not too hard.

    It will notify the user of its creation and we are good.

    That’s it for now.

  • What’s next?

    It took me a while to gather all the info to get started, but once you’re there it’s pretty straightforward.

    So the next step, for an other post, will be how to dispatch a new issue from org mode