Uploaded image for project: 'Jenkins'
  1. Jenkins
  2. JENKINS-73899

Plugin stuck on response via groovy script

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Unresolved
    • Icon: Minor Minor
    • active-choices-plugin
    • None
    • DEV

      i am making call to gitlab via api which runs from the bash script via curl command in it. it is working fine with 2.8.3 version. but its getting stuck when i update plugin.

      pasting my bash script below for reference.

      #!/bin/bash

      1. Replace with your GitLab personal access token and project ID
        ACCESS_TOKEN="Token"
        PROJECT_ID="some number"
      1. Initialize an empty array to hold all branches
        all_branches=()
      1. Fetch branches page by page
        page=1
        while :; do
        response=$(curl --silent --header "PRIVATE-TOKEN: $ACCESS_TOKEN" "https://gitlab.example.com/api/v4/projects/$PROJECT_ID/repository/branches?per_page=100&page=$page")
        branches=$(echo "$response" | jq '.')
      1. Break the loop if no more branches are returned
        if [ "$(echo "$branches" | jq 'length')" -eq 0 ]; then
        break
        fi
      1. Append the branches to the all_branches array
        all_branches+=("$branches")
      1. Increment the page number
        page=$((page + 1))
        done
      1. Combine all branches into a single JSON array
        combined_branches=$(echo "${all_branches[@]}" | jq -s 'add')
      1. Sort the branches by the commit date and get the latest 20 branch names
        echo "$combined_branches" | jq 'sort_by(.commit.committed_date) | reverse | .[:20] | .[].name' | sed 's/"//g'

      below is groovy script which runs in background to call bash script

      def proc ="/var/lib/jenkins/scripts/gitlab/branches.sh ${PROJECT_ID}".execute()
      proc.waitFor()

      def output = proc.in.text
      def exitcode= proc.exitValue()
      def error = proc.err.text

      if (error) {
      println "Std Err: ${error}"
      println "Process exit code: ${exitcode}"
      return exitcode
      }
      return output.tokenize()

            kinow Bruno P. Kinoshita
            chiranjivshetye chiranjiv
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated: