User Tools

Site Tools


gitlab_satis

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
Next revisionBoth sides next revision
gitlab_satis [2018/11/09 14:05] – [Using Environment variable] admingitlab_satis [2018/11/14 15:12] – [Configuration] admin
Line 44: Line 44:
 ===== Configuration ===== ===== Configuration =====
  
-Go to User Settings -> Access Tokens, give it a name and allow api scope. Hit "Create personal access token" and copy it to your configuration (arguments -> gitlab-token). See below ...+Go to Project -> Settings -> CI/CD -> Pipeline Triggers, give it a name and allow api scope. Hit "Add Trigger" and copy it to your configuration (arguments -> gitlab-token). See below ...
 ==== Using Environment variable ==== ==== Using Environment variable ====
  
Line 118: Line 118:
  
 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
Line 125: Line 126:
  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>
gitlab_satis.txt · Last modified: 2018/11/14 16:54 by admin