diff --git a/JenkinsJobs/Builds/FOLDER.groovy b/JenkinsJobs/Builds/FOLDER.groovy index 8dc57010458..8fe4484c756 100644 --- a/JenkinsJobs/Builds/FOLDER.groovy +++ b/JenkinsJobs/Builds/FOLDER.groovy @@ -54,3 +54,26 @@ pipelineJob('Builds/Build-Docker-images'){ } } } + +pipelineJob('Builds/mark-build'){ + displayName("Mark build") + description("Mark a build as stable or unstable.") + parameters { + stringParam('buildId', null, "ID of the build to be marked.") + choiceParam('markAs', [ + 'STABLE', + 'UNSTABLE', + ], 'The kind of marker to apply to (respectively remove from) the specified build.') + stringParam('issueURL', null, 'URL of the causing Github issue or PR (only relevant if the build is marked as unstable).') + } + + definition { + cpsScm { + lightweight(true) + scm { + github('eclipse-platform/eclipse.platform.releng.aggregator', 'master') + } + scriptPath('JenkinsJobs/Builds/markBuild.jenkinsfile') + } + } +} diff --git a/JenkinsJobs/Builds/markBuild.groovy b/JenkinsJobs/Builds/markBuild.groovy deleted file mode 100644 index 8b6016512e9..00000000000 --- a/JenkinsJobs/Builds/markBuild.groovy +++ /dev/null @@ -1,88 +0,0 @@ -for (marker in [ 'stable', 'unstable' ]) { - pipelineJob("Builds/mark${marker.capitalize()}"){ - displayName("Mark ${marker.capitalize()}") - description("Mark a build as ${marker}.") - parameters { - stringParam('buildId', null, "ID of the build to be marked ${marker}.") - if(marker == 'unstable') { - stringParam('issueUrl', null, 'URL of the causing Github issue or PR.') - } - } - definition { - cps { - sandbox() - script('''\ -pipeline { - options { - timestamps() - buildDiscarder(logRotator(numToKeepStr:'5')) - } - agent { - label 'basic' - } - stages { - stage('Mark ''' + marker + ''''){ - environment { - RELEASE_VER = readBuildProperty('RELEASE_VER') - } - steps { - sshagent(['projects-storage.eclipse.org-bot-ssh']) { - sh \'''#!/bin/bash -xe - # this function executes command passed as command line parameter and - # if that command fails it exit with the same error code as the failed command - - # Strip spaces from the buildId and eclipseStream - buildId=$(echo $buildId|tr -d ' ') - issueUrl=$(echo $issueUrl|tr -d ' ') - - if [ -z "$buildId" ]; then - echo "BuildId is empty! Exiting." - exit 1 - fi''' + (marker == 'unstable' ? ''' - if [ -z $issueUrl ]; then - echo "IssueUrl is empty! Exiting." - exit 1 - fi''' : '') + ''' - epDownloadDir=/home/data/httpd/download.eclipse.org/eclipse - buildDir="${epDownloadDir}/downloads/drops4/${buildId}" - ''' + { switch (marker) { - case 'stable': return ''' - #Remove hidden attribute and unstable tags - ssh genie.releng@projects-storage.eclipse.org rm -f ${buildDir}/buildHidden - ssh genie.releng@projects-storage.eclipse.org rm -f ${buildDir}/buildUnstable - ''' - case 'unstable': return ''' - # Convert URL of GH issue or PR into: 'organization/repository#number' - label=$(echo "${issueUrl##'https://github.com/'}" | sed 's/\\\\/issues\\\\//#/g' | sed 's/\\\\/pull\\\\//#/g') - #add unstable tags - ssh genie.releng@projects-storage.eclipse.org rm -f ${buildDir}/buildUnstable - echo "

This build is marked unstable due to ${label}.

" > buildUnstable - scp buildUnstable genie.releng@projects-storage.eclipse.org:${buildDir}/buildUnstable - ''' - default : throw new IllegalArgumentException("Unknown marker: ${marker}") - } }() + ''' - \''' - } - build job: 'Releng/updateIndex', wait: false - build job: 'Releng/modifyP2CompositeRepository', wait: true, propagate: true, parameters: [ - string(name: 'repositoryPath', value: "eclipse/updates/${RELEASE_VER}-I-builds"), - string(name: \'''' + { switch (marker) { - case 'stable': return 'add' - case 'unstable': return 'remove' - default : throw new IllegalArgumentException("Unknown marker: ${marker}") - } }() + '''\', value: "${buildId}") - ] - } - } - } -} - -def readBuildProperty(String name) { - def value = sh(script: """curl https://download.eclipse.org/eclipse/downloads/drops4/${buildId}/buildproperties.properties | grep "^${name}" | cut -d'=' -f2""", returnStdout: true).trim() - return value.startsWith('"') && value.endsWith('"') ? value.substring(1, value.length() - 1) : value -} - ''') - } - } - } -} \ No newline at end of file diff --git a/JenkinsJobs/Builds/markBuild.jenkinsfile b/JenkinsJobs/Builds/markBuild.jenkinsfile new file mode 100644 index 00000000000..bad07256aa0 --- /dev/null +++ b/JenkinsJobs/Builds/markBuild.jenkinsfile @@ -0,0 +1,63 @@ +pipeline { + options { + skipDefaultCheckout() + timestamps() + timeout(time: 5, unit: 'MINUTES') + buildDiscarder(logRotator(numToKeepStr:'5')) + } + agent { + label 'basic' + } + stages { + stage('Mark build'){ + environment { + // Download Server locations (would very seldom change) + EP_BUILD_DROP = "/home/data/httpd/download.eclipse.org/eclipse/downloads/drops4/${buildId}" + RELEASE_VER = readBuildProperty('RELEASE_VER') + } + steps { + sshagent(['projects-storage.eclipse.org-bot-ssh']) { + sh '''#!/bin/bash -xe + # Strip spaces from the buildId and eclipseStream + buildId=$(echo $buildId|tr -d ' ') + issueURL=$(echo $issueURL|tr -d ' ') + + if [ -z "$buildId" ]; then + echo "BuildId is empty! Exiting." + exit 1 + fi + if [ "$markAs" == 'UNSTABLE' ] && [ -z "$issueURL" ]; then + echo "Required issueURL parameter is empty! Exiting." + exit 1 + fi + + case ${markAs} in + STABLE) + #Remove unstable tag + ssh genie.releng@projects-storage.eclipse.org rm -f ${EP_BUILD_DROP}/buildUnstable + ;; + UNSTABLE) + # Convert URL of GH issue or PR into: 'organization/repository#number' + label=$(echo "${issueURL##'https://github.com/'}" | sed 's/\\/issues\\//#/g' | sed 's/\\/pull\\//#/g') + #Add unstable tag + echo "

This build is marked unstable due to ${label}.

" > buildUnstable + scp buildUnstable genie.releng@projects-storage.eclipse.org:${EP_BUILD_DROP}/buildUnstable + ;; + esac + ''' + } + build job: 'Releng/updateIndex', wait: false + build job: 'Releng/modifyP2CompositeRepository', wait: true, propagate: true, parameters: [ + string(name: 'repositoryPath', value: "eclipse/updates/${RELEASE_VER}-I-builds"), + string(name: "${params.markAs == 'STABLE' ? 'add' : 'remove'}", value: "${buildId}") + ] + } + } + } +} + +def readBuildProperty(String name) { + def buildPropertiesURL = "https://download.eclipse.org/eclipse/downloads/drops4/${buildId}/buildproperties.properties" + def buildProperties = readProperties(text: sh(script: "curl --fail ${buildPropertiesURL}", returnStdout: true)) + return buildProperties[name].replace('"','') // Remove surrounding quotes +}