Both sides previous revisionPrevious revisionNext revision | Previous revisionNext revisionBoth sides next revision |
gitlab_satis [2018/09/14 12:35] – [Using Environment variable] admin | gitlab_satis [2018/11/14 13:59] – [Optional] admin |
---|
====== Using Gitlab and Satis to generate private composer Repository ====== | ====== Using Gitlab and Satis to generate private composer Repository ====== |
| |
[[https://github.com/ochorocho/gitlab-pages-satis|This]] is mainly a wrapper for [[https://github.com/mborne/satis-gitlab|mborne/satis-gitlab]] intended to make it easy to use with minimal and simple configuration. Best used together with Gitlab. I'm using Gitlab Pages behind **Apache**, nginx is the default/recommended way to use Gitlab Pages with. | [[https://github.com/ochorocho/gitlab-pages-satis|This]] is mainly a wrapper for [[https://github.com/mborne/satis-gitlab|mborne/satis-gitlab]] intended to make it easy to use with minimal and simple configuration. Best used together with Gitlab. <del>I'm using Gitlab Pages behind **Apache**,</del> NGINX is the default/recommended way to use Gitlab Pages with. |
| |
**Idea** | **Idea** |
* <del>Download zips in Satis ??? So no key auth is required??!?!?</del> add ''archive: true'' and *.tar-Files for Tags will be saved in ''./dist/'' Folder. Branches still point to Git Repo. | * <del>Download zips in Satis ??? So no key auth is required??!?!?</del> add ''archive: true'' and *.tar-Files for Tags will be saved in ''./dist/'' Folder. Branches still point to Git Repo. |
* <del>Multiple packages, which one is preferred?</del> Depends on the loading order of your defined repositories in composer.json | * <del>Multiple packages, which one is preferred?</del> Depends on the loading order of your defined repositories in composer.json |
| * FIXME Run pipeline only if it is not already running, pile up all requests and run it only once. |
| |
**Features** | **Features** |
homepage: "https://satis.example.org" | homepage: "https://satis.example.org" |
output: "satis.json" | output: "satis.json" |
use-file-to-include: '.satisinclude' | include-if-has-file: '.satisinclude' |
template: '/path/to/satis-template.example.json' | template: '/path/to/satis-template.example.json' |
archive: true | archive: true |
| |
payload = JSON.parse(STDIN.read) | payload = JSON.parse(STDIN.read) |
| |
| |
# Only run this code in case we are dealing with tag_push event | # Only run this code in case we are dealing with tag_push event |
shaFile = "#{temp}/gitlab-trigger.sha" | shaFile = "#{temp}/gitlab-trigger.sha" |
| |
# Get hash values to compare | # Get refs to compare |
payloadHash = "#{payload['before']} #{payload['after']}" | payloadCurrent = "#{payload['ref']}" |
payloadHashBefore = File.read(shaFile) if File.exist?(shaFile) | payloadBefore = File.read(shaFile) if File.exist?(shaFile) |
| |
# Save before and after hash to compare | # Save refs to compare on next run ... |
File.delete(shaFile) if File.exist?(shaFile) | File.delete(shaFile) if File.exist?(shaFile) |
File.write(shaFile, "#{payload['before']} #{payload['after']}") | File.write(shaFile, "#{payload['ref']}") |
| |
# Trigger Pipeline | # Trigger Pipeline |
if payloadHashBefore != payloadHash | if payloadBefore != payloadCurrent |
exec('curl --request POST --form "token=XXXXXXX" --form ref=master https://gitlab.example.org/api/v4/projects/36/trigger/pipeline') | exec('curl --request POST --form "token=XXXXXXXXX" --form ref=master https://gitlab.domain.com/api/v4/projects/{YOUR_SATIS_PROJECT_ID}/trigger/pipeline') |
end | end |
| |
end | end |
</code> | </code> |