Louay Gourrida
Louay Gourrida

Reputation: 131

Error parsing reference: is not a valid repository/tag: invalid reference format

Im trying to make a jenkins pipline that clones code from git and build a docker image then push it to nexus registry so thats what in my jenkins file :

pipeline{
    agent any

    environment{
        DOCKERHUB_CREDENTIALS=credentials('docker_hub')
        NEXUS_CREDENTIALS = credentials('nexus')
        
    }

    stages{
        
        stage('Build'){

            steps{
                sh 'docker build -t my-app .'
            }

        }

        stage('Login'){
            steps{
                sh 'echo $NEXUS_CREDENTIALS_PSW | docker login -u $NEXUS_CREDENTIALS_USR --password-stdin http://localhost:8095/repository/docker-private-repo/'
            }

        }
        stage('Push'){

            steps{
                sh 'docker tag my-app:latest http://localhost:8095/docker-private-repo/my-app:latest'
                sh 'docker push http://localhost:8095/docker-private-repo/my-app:latest'
            }

        }
    }
    post{
        always{
            sh 'docker logout'
        }
    }
}

for cloning the git code im using pipeline SCM , anyway the build stage and login stage are working fine but for the pushing stage i get this error "Error parsing reference: "http://localhost:8095/docker-private-repo/my-app:latest" is not a valid repository/tag: invalid reference format" i dont know what wrong with the tag command ? how can i solve this ?

Upvotes: 2

Views: 14929

Answers (2)

thvs86
thvs86

Reputation: 1528

This might be a more niche answer but in our case the problem was related to this change, which is a breaking change (but the only thing is that you need to update the variables to their current equivalents): Remove deprecated predefined CI_BUILD_ variables* in GitLab.

In our exact case, in the previous version 8.x we had CI_BUILD_TAG, while in our current version 9.0+ we have CI_COMMIT_TAG.

More details here: Backend: Remove deprecated predefined CI_BUILD_* variables

Upvotes: 1

Louay Gourrida
Louay Gourrida

Reputation: 131

I Had to remove https:// from the url now it works fine

Upvotes: 10

Related Questions