emissary-firmware/Jenkinsfile

103 lines
3.3 KiB
Plaintext
Raw Normal View History

2023-03-31 16:02:28 +02:00
pipeline {
agent {
dockerfile {
filename 'Dockerfile'
dir 'misc/jenkins'
}
}
parameters {
persistentText(name: 'emissaryRelease', defaultValue: 'latest', description: 'Numéro de release Emissary', successfulOnly: false)
}
stages {
stage('Cancel older jobs') {
steps {
script {
def buildNumber = env.BUILD_NUMBER as int
if (buildNumber > 1) milestone(buildNumber - 1)
milestone(buildNumber)
}
}
}
stage('Update emissary release') {
when {
expression {
return params.emissaryRelease != 'latest'
}
}
steps {
script {
currentEmissaryRelease = readFile('emissary_release.txt').trim()
if (currentEmissaryRelease == params.emissaryRelease) {
currentBuild.result = 'SUCCESS'
return
}
withCredentials([
usernamePassword([
credentialsId: 'forge-jenkins',
usernameVariable: 'GIT_USERNAME',
passwordVariable: 'GIT_PASSWORD'
])
]) {
sh """
git config user.email "jenkins@cadoles.com"
git config user.name "Jenkins"
git config credential.https://forge.cadoles.com.username "\$GIT_USERNAME"
git config credential.https://forge.cadoles.com.helper '!f() { test "\$1" = get && echo "password=\$GIT_PASSWORD"; }; f'
echo '${params.emissaryRelease}' > emissary_release.txt
git add emissary_release.txt
git commit -m "feat: use emissary ${params.emissaryRelease}"
git pull --rebase
git push origin \$(git rev-parse HEAD):${env.GIT_BRANCH}
"""
}
}
}
}
stage('Build and release') {
steps {
script {
withCredentials([
usernamePassword([
credentialsId: 'forge-jenkins',
usernameVariable: 'GITEA_DOWNLOAD_USERNAME',
passwordVariable: 'GITEA_DOWNLOAD_PASSWORD'
])
]) {
sh '''
make download-emissary-release
make all
'''
}
}
}
}
stage('Release') {
steps {
withCredentials([
usernamePassword([
credentialsId: 'forge-jenkins',
usernameVariable: 'GITEA_RELEASE_USERNAME',
passwordVariable: 'GITEA_RELEASE_PASSWORD'
])
]) {
sh 'make gitea-release'
}
}
}
}
post {
always {
cleanWs()
}
}
}