Use GitLab API from a GitLabCI build script
<p>I have a GitLab CI build script like this:</p>

<pre><code>create release:
  stage: deploy
  tags:
    - basic
  only:
    - tags
  script:
    - GITLOG=$(echo "# Changes Log"; git log `git tag | tail -2 | head -1`..${CI_BUILD_TAG} --pretty=format:" - %s")
    - curl -X POST -d "private_token=$CI_BUILD_TOKEN&amp;description=$GITLOG" "http://git.example.com/api/v3/projects/${CI_PROJECT_ID}/repository/tags/${CI_BUILD_TAG}/release"
</code></pre>

<p>The purpose of this step is to automatically add a Changes Log from Git in the GitLab Releases section.</p>

<p>That works if I manually run this on the command line and put in the variables... </p>

<p>The problem is that the value of <code>CI_BUILD_TOKEN</code> in the build runner isn't a valid GitLab Private Token - it's only a token to connect to the Docker Registry - as per the documentation.</p>

<p>Is there a way to get a valid GitLab API token that the build runner can use to access the API for the project it's running a build for? Seems like this should be possible.</p>

<p>GitLab Runner:</p>

<pre><code>gitlab-runner -v
Version:      1.2.0
Git revision: 3a4fcd4
Git branch:   HEAD
GO version:   go1.6.2
Built:        Sun, 22 May 2016 20:05:30 +0000
OS/Arch:      linux/amd64
</code></pre>