Hamza Nasir
Hamza Nasir

Reputation: 35

unable to sign the image using jenkins pipeline

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'
      }
    }

Upvotes: 1

Views: 539

Answers (1)

ycr
ycr

Reputation: 14604

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'
  }

Upvotes: 0

Related Questions