403Webshell
Server IP : 188.151.22.197  /  Your IP : 216.73.217.74
Web Server : Apache/2.4.62 (Rocky Linux) OpenSSL/3.5.5
System : Linux wsten.se 5.14.0-687.30.1.el9_8.x86_64 #1 SMP PREEMPT_DYNAMIC Mon Jul 27 13:09:21 UTC 2026 x86_64
User : apache ( 48)
PHP Version : 8.1.32
Disable Function : NONE
MySQL : OFF  |  cURL : ON  |  WGET : ON  |  Perl : ON  |  Python : OFF  |  Sudo : ON  |  Pkexec : ON
Directory :  /opt/gitlab/embedded/service/gitlab-rails/scripts/database/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


[ Back ]     

Current File : /opt/gitlab/embedded/service/gitlab-rails/scripts/database/mark_pipeline_comments.rb
# frozen_string_literal: true

require 'net/http'
require 'uri'
require 'json'
require 'time'
require 'gitlab'

unless ENV['CI']
  puts 'Necessary environment variable CI not defined.'
  exit(-1)
end

ENDPOINT = ENV.fetch('CI_API_V4_URL')
PROJECT_PATH = ENV.fetch('CI_PROJECT_PATH')

TOKEN = ENV.fetch('DATABASE_PROJECT_TOKEN')
DB_PIPELINE_NOTE_TAG = 'gitlab-org/database-team/gitlab-com-database-testing:identifiable-note'
INVALIDATED_RESULTS_MSG_TAG = 'gitlab-org/database-team/gitlab-com-database-testing:identifiable-note-invalidated'

INVALIDATED_RESULTS_MSG = <<~MSG.freeze
  ## ⚠️

  Please note that the database testing pipeline results in this comment
  are no longer valid due to a commit being added to the merge request that has
  changed one or more files.

  Please run another database testing pipeline for the most accurate results.

  <!-- #{INVALIDATED_RESULTS_MSG_TAG} -->
  ***

MSG

merge_request_id = ARGV[0]
most_recent_commit_timestamp = Time.at(ARGV[1].to_i)

client = Gitlab.client(endpoint: ENDPOINT, private_token: TOKEN)

puts "Fetching discussions on merge request #{merge_request_id}"
client.merge_request_notes(PROJECT_PATH, merge_request_id).auto_paginate.each do |discussion|
  next unless discussion.body.include?(DB_PIPELINE_NOTE_TAG)
  next if discussion.body.include? INVALIDATED_RESULTS_MSG_TAG

  puts "Found discussion #{discussion.id} which was created at #{discussion.created_at}"
  puts "Last committed timestamp is #{most_recent_commit_timestamp}"
  next unless Time.iso8601(discussion.created_at) < most_recent_commit_timestamp

  puts "Annotating body of #{discussion.id}"
  annotated_body = "#{INVALIDATED_RESULTS_MSG}#{discussion.body}"

  client.edit_merge_request_note(PROJECT_PATH, merge_request_id, discussion.id, annotated_body)
end

Youez - 2016 - github.com/yon3zu
LinuXploit