Skip to content

Instantly share code, notes, and snippets.

@aafaque33
Last active May 29, 2020 16:07
Show Gist options
  • Save aafaque33/76df63338154e350af92cfe6793c5978 to your computer and use it in GitHub Desktop.
Save aafaque33/76df63338154e350af92cfe6793c5978 to your computer and use it in GitHub Desktop.
stages:
- build
build_badges:
stage: build
tags:
- docker-build
before_script:
- chmod +x get-updated-badge-info.sh
script:
- echo "Some script to build your code"
after_script:
- ./get-updated-badge-info.sh
artifacts:
paths:
- badges.json
when: always
expire_in: 4 weeks
#!/bin/bash
echo "collecting stas for badges"
commits=`git rev-list --all --count`
latest_release_tag=$(git describe --tags `git rev-list --tags --max-count=1`)
echo "{\"commits\":\"$commits\", \"release_tag"\:\"$latest_release_tag\"}" > badges.json
@flxholle
Copy link

flxholle commented May 29, 2020

at release_tag"\
you have to change it into at release_tag\"

@flxholle
Copy link

flxholle commented May 29, 2020

Also you have to change the link to the badges.json to: @aafaque33
https://gitlab.com/<user>/<project>/-/jobs/artifacts/master/raw/badges.json?job=build_badges

https://img.shields.io/badge/dynamic/json.svg?label=Release&url=https://gitlab.com/<user>/<project>/-/jobs/artifacts/master/raw/badges.json?job=build_badges&query=release_tag&colorB=brightgreen

As you can see here:
https://docs.gitlab.com/ee/ci/pipelines/job_artifacts.html#downloading-the-latest-artifacts
The access to the artifact files has changed.

@flxholle
Copy link

I have made a sample repository here: https://gitlab.com/asdoi/gitlab_badges_sample

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment