I am trying to sign a JAR file using jarsigner in Jenkins Pipeline. While I can do it manually, I'm unsure about how it should work in a pipeline script. Could someone please assist me?
jarsigner -keystore keystore.jks -storepass keystore_password -keypass key_password your_app.war myalias
I would like to add the Signing Stage to the Pipeline Script. Can the /bin/sh command be used to run the jarsigner?
stage('Sign') {
steps {
sh '''#!/bin/bash
jarsigner -keystore keystore.jks -storepass keystore_password -keypass key_password your_app.war myalias
'''
} }
Thanks
You generally don't need
#!/bin/bash. Just add a script step and add the sh command:You may get an issue where
jarsignerwon't be identified as a command. In that case, follow this answer to get the command into the Jenkins path.