Apuna12
Apuna12

Reputation: 239

Gitlab pipeline cannot do release without git

I am dealing with the issues regarding GitLab Pipelines. I have a release stage which looks like this:

release-job:  # Valid release section within the job
  stage: release
  image: registry.gitlab.com/gitlab-org/release-cli:latest        
  script:
    - | 
      echo "Getting the newest version of BIGProject."
      VERSION=$(1.5.4)
      echo "Newest version of BIGProject is: $VERSION"
  
      TAG_NAME="v$VERSION"
      echo "Tag name: $TAG_NAME"
      # Ensure the tag exists
      echo "Creating tag if it doesn't exist"
      git tag $TAG_NAME || echo "Tag $TAG_NAME already exists"

      # Push the tag to the repository
      echo "Pushing tag $TAG_NAME to the repository"
      git push origin $TAG_NAME

      echo "Getting Artifact Link"
      ARTIFACT_URL=$(cat artifact_url.txt | tr -d '\r')
      ARTIFACT_URL=${ARTIFACT_URL:2}
      echo "BIGProjectSetup.msi download URL - $ARTIFACT_URL"
      ASSETS_LINK=" 
{\"name\":\"BIGProjectSetup.msi\",\"url\":\"$ARTIFACT_URL\",\"link_type\":\"package\"}"
      echo "Assets link JSON - $ASSETS_LINK"
  
      echo "Attempting to create release"
      
      if release-cli create --name "BIGProject" --tag-name "$TAG_NAME" --description "New version of BIGProject" --assets-link "$ASSETS_LINK"; then
         echo "Release created successfully"
      else
         echo "Release with tag $TAG_NAME already exists or failed to create release."
      fi

As you can maybe see I am trying to create a release under Deploy->Releases in Gitlab. The problem is that I found out that only registry.gitlab.com/gitlab-org/release-cli:latest supports release-cli command to create a release in GitHub. Now the real issue is that when the script goes on the line git push origin $TAG_NAME it has an error which says that I do not have a git. The fix that ChatGPT gave me is that I should use:

before_script:
  - echo "https://artifactory.com/artifactory/api/nuget/di_ct_nuget" > /etc/apk/repositories
  - apk update
  - apk add --no-cache git 

where https://artifactory.com/artifactory/api/nuget/di_nuget is an alias for our only gate to the internet since the gitlab does not have internet access. We can only download through this artifactory. After using this I am getting this error:

$ apk update
fetch https://artifactory.com/artifactory/api/nuget/di_nuget/x86_64/APKINDEX.tar.gz
WARNING: updating and opening https://artifactory.com/artifactory/api/nuget/di_nuget: Protocol error
2 unavailable, 0 stale; 15 distinct packages available

Now I am not sure what to try next.

Can someone help me please with that?

Thanks a lot

Upvotes: 0

Views: 146

Answers (0)

Related Questions