0

I have a GitLab CI/CD pipeline that builds and deploys a package into the GitLab Package Registry.

For a specific (and temporary) use case, I need the pipeline to delete the package from the registry if the same version already exists, so that the new build can be published with the same version number.

Is there a way to achieve this directly within the CI/CD pipeline or settings-ci.xml? I tried to add and remove -SNAPSHOT extension from version without success. Adding -Bin maven deploy command does not help.

gitlab-ci.yml

publish:
  stage: publish
  script:
    - echo "Deploying application..."
    - mvn clean deploy -s settings-ci.xml
    - echo "Application successfully deployed."

settings-ci.xml

<settings xmlns="http://maven.apache.org/SETTINGS/1.1.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
          xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.1.0 http://maven.apache.org/xsd/settings-1.1.0.xsd">
    <servers>
        <server>
            <id>gitlab-maven</id>
            <configuration>
                <httpHeaders>
                    <property>
                        <name>Job-Token</name>
                        <value>${CI_JOB_TOKEN}</value>
                    </property>
                </httpHeaders>
            </configuration>
        </server>
    </servers>
</settings>

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.