在管道中更改文件后,将文件从 gitlab-ci 推送到存储库

时间:2021-07-14 19:32:45

标签: bash git gitlab continuous-integration

我有一个 gitlab 管道,可以从存储库中获取文件、更改值并更新此文件

此后,我需要将更改后的文件推送到 repo

这里是gitlab-ci的代码

   variables:
  NUGET_URL: **********
  

stages:
  - publish-nuget-package
   
step-publish-nuget-package:
  stage: publish-nuget-package
  image: mcr.microsoft.com/dotnet/core/sdk:3.1
  before_script:
    - dotnet tool install --global dotnet-ef
    - export PATH="$PATH:/root/.dotnet/tools"
    - dotnet tool install -g AWS.CodeArtifact.NuGet.CredentialProvider
    - dotnet codeartifact-creds install
  script:
    - x=$(awk '{print $2}' ./package-version.txt)
    - ((x++))
    - echo "${x}"
    - cd Monspire.EmailSender.Contracts
    - dotnet pack -c Release /p:Version="${x}"
    - echo "VERSION_NUMBER:\ ${x}" > package-version.txt
    - cd Monspire.EmailSender.Contracts/bin/Release/
    - dotnet nuget push Monspire.EmailSender.Contracts."${x}".0.0.nupkg --source $NUGET_URL
  environment: development
  tags:
    - monspire
  only:
    - main

在这个字符串上,我进行了更改 echo "VERSION_NUMBER:\ ${x}" > package-version.txt

现在如何将更改后的文件推送到存储库?

0 个答案:

没有答案