1

I am trying to sign the docker image using cosign in jenkins pipeline. I got this error

"cosign version
/home/jenkins/workspace/eVisl-import-dev-cicd@tmp/durable-63e86c1b/script.sh: line 1: cosign: command not found"

Jenkinsfile:

stage('sign the container image') {
            steps {
                sh 'cosign version'
                sh 'cosign sign --key $COSIGN_PRIVATE_KEY hub.docker.com/hamzanasir6886/evsil-dev:latest-3'
      }
    }
ycr
  • 12,828
  • 2
  • 25
  • 45

1 Answers1

0

Try setting your PATH variable to add cosign executable.

environment {
   PATH = "/cosign_location/bin:${env.PATH}"
}

or something like the below.

  withEnv(["PATH+COSIGN=/cosign_location/bin"]) {
    sh 'cosign version'
    sh 'cosign sign --key $COSIGN_PRIVATE_KEY hub.docker.com/hamzanasir6886/evsil-dev:latest-3'
  }
ycr
  • 12,828
  • 2
  • 25
  • 45