diff --git a/Jenkinsfile b/Jenkinsfile index c27ca09..bbe2d4b 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -56,18 +56,38 @@ pipeline { stage("Publish Repository") { steps { sshagent(['srv01_elordenador_org']) { - sh ''' - ssh ${APTLY_HOST} << 'EOF' - SNAPSHOT="espos-build-${BUILD_NUMBER}" - aptly snapshot create $SNAPSHOT from repo espos-unstable - aptly repo add ${APTLY_REPO} /tmp/*.deb - aptly publish switch ${APTLY_REPO} $SNAPSHOT - EOF - ''' + withCredentials([ + string( + credentialsId: 'aptly_gpg_pass', + variable: 'GPG_PASS' + ) + ]) { + + sh ''' + ssh ${APTLY_HOST} << EOF + + aptly repo add espos-unstable /tmp/*.deb + + if aptly publish list | grep -q espos-unstable + then + aptly publish switch \ + -passphrase="$GPG_PASS" \ + espos-unstable + else + aptly publish repo \ + -distribution=espos-unstable \ + -component=main \ + -passphrase="$GPG_PASS" \ + espos-unstable + fi + + EOF + ''' + } } } - } + } } post { success {