Working with Jenkins and GHCR; can a github app authenticate to push a docker image?

641 Views Asked by At

We are trying to setup a workflow using Jenkins to build docker images using code that is onto github and push it back onto it.

We have setup a github app for jenkins to use to access the code repository/branches/PR, but it seems although i have given the github app the 'package' permission, i am incapable of using the same credentials to push a package. I have not managed to do a 'docker login' using the credentials, nor using the 'withRegistry' wrapper in the jenkins file.

We do set the GHCR_Credentials in the environment

pipeline {
  agent any
  environment {
    GHCR_CREDENTIALS=credentials('github-app-creds')
  }

And then we try pushing the built image using :

docker.withRegistry('https://ghcr.io', GHCR_CREDENTIALS) {
  dockerImageBuild.push()
}

It fails and i get an error :

Error response from daemon: Get "https://ghcr.io/v2/": denied: denied

Is it possible to use credentials to push docker images? If so, how? Otherwise i will have to default using a PAT, but it'll be bound to my account and not the organisation, which isn't practical.

0

There are 0 best solutions below