diff --git a/Jenkinsfile b/Jenkinsfile index 395cdb8..c49d8c5 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -24,6 +24,8 @@ def zluxParameters = [ "PR_ZLUX_BUILD" : "" ] +DEFAULT_BRANCH = "staging" + properties([ parameters(zluxParameters) ]) @@ -45,7 +47,6 @@ ZLUX_CORE_PLUGINS = [ "zlux-server-framework", "zlux-shared" ] -DEFAULT_BRANCH = "staging" ZOWE_MANIFEST_URL = \ "https://raw.githubusercontent.com/zowe/zowe-install-packaging/staging/manifest.json.template" ARTIFACTORY_SERVER = "zoweArtifactory" @@ -109,27 +110,33 @@ node(JENKINS_NODE) { stage("Prepare") { zoweVersion = getZoweVersion() - zluxbuildpr = env.BRANCH_NAME - if (zluxbuildpr.startsWith("PR-")){ - pullRequests['zlux-build'] = getPullRequest(GITHUB_TOKEN, 'zlux-build', zluxbuildpr.drop(3)) - } else { - echo "building staging" - } - - zluxParameters.each { - key, value -> - if (key.startsWith("PR_")) { - if (value) { - def repoName = key[3..-1].toLowerCase().replaceAll('_', '-') - pullRequests[repoName] = getPullRequest(GITHUB_TOKEN, repoName, value) - } - + zluxbuildpr = env.BRANCH_NAME + if (zluxbuildpr.startsWith("PR-")){ + pullRequests['zlux-build'] = getPullRequest(GITHUB_TOKEN, 'zlux-build', zluxbuildpr.drop(3)) + }else if (env.BRANCH_NAME.toLowerCase() == 'rc') { + currentBuild.result = 'ABORTED' + } else if (params.'BUILD_DEFAULT'){ + DEFAULT_BRANCH = params.'REPO_NAME' + echo "building ${DEFAULT_BRANCH}" + } else { + DEFAULT_BRANCH = env.BRANCH_NAME.toLowerCase() + echo "building ${DEFAULT_BRANCH}" + } + + zluxParameters.each { + key, value -> + if (key.startsWith("PR_")) { + if (value) { + def repoName = key[3..-1].toLowerCase().replaceAll('_', '-') + pullRequests[repoName] = getPullRequest(GITHUB_TOKEN, repoName, value) } + } - + } + setGithubStatus(GITHUB_TOKEN, pullRequests, "pending", "This commit is being built") - } + sshagent(credentials: [GITHUB_SSH_KEY]) { stage("Checkout") { sh \ @@ -149,14 +156,23 @@ node(JENKINS_NODE) { } pullRequests.each { repoName, pullRequest -> - sh \ - """ - cd zlux/${repoName} - git fetch origin pull/${pullRequest['number']}/head:pr - git merge pr - """ + sh \ + """ + cd zlux/${repoName} + git fetch origin pull/${pullRequest['number']}/head:pr + git merge pr + """ + } + if (params.'STARTED_JOB'){ + sh \ + """ + cd zlux/${params.'REPO_NAME'} + git fetch origin pull/${params.'PR_NUMBER'}/head:pr + git merge pr + """ } } + stage("Set version") { def (majorVersion, minorVersion, microVersion) = zoweVersion.tokenize(".") sh \ @@ -184,21 +200,23 @@ node(JENKINS_NODE) { fi """ } + stage("Build") { sh "bash -c 'cd zlux/zlux-build && set -o pipefail && ant testing 2>&1 | grep -vE \"^\\s+\\[exec\\]\\s+0\\% compiling\"'" } + stage("Test") { pullRequests.each { repoName, pullRequest -> if (repoName != "zlux-app-server") { sh \ """ - cd dist - packages=\$(find ./${repoName} -name package.json | { grep -v node_modules || true; }) - for package in \$packages - do - sh -c "cd `dirname \$package` && npm run test --if-present" - done + cd dist + packages=\$(find ./${repoName} -name package.json | { grep -v node_modules || true; }) + for package in \$packages + do + sh -c "cd `dirname \$package` && npm run test --if-present" + done """ } } @@ -206,90 +224,90 @@ node(JENKINS_NODE) { sh "cd zlux/zlux-build && ant -Dcapstone=../../dist removeSource" } stage("Package") { - sh \ + sh \ + """ + chmod +x dist/zlux-build/*.sh + cd dist + tar cf ../zlux.tar -H ustar * + cd .. + git clone -b feature/tag-script https://github.com/1000TurquoisePogs/zowe-install-packaging.git + """ + withCredentials([usernamePassword( + credentialsId: PAX_CREDENTIALS, + usernameVariable: "PAX_USERNAME", + passwordVariable: "PAX_PASSWORD" + )]) { + def PAX_SERVER = [ + name : PAX_HOSTNAME, + host : PAX_HOSTNAME, + port : PAX_SSH_PORT, + user : PAX_USERNAME, + password : PAX_PASSWORD, + allowAnyHosts: true + ] + sshCommand remote: PAX_SERVER, command: \ + "rm -rf ${paxPackageDir} && mkdir -p ${paxPackageDir}" + sshPut remote: PAX_SERVER, from: "zlux.tar", into: "${paxPackageDir}/" + sshPut remote: PAX_SERVER, from: "zowe-install-packaging/scripts/tag-files.sh", into: "${paxPackageDir}/" + sshCommand remote: PAX_SERVER, command: \ """ - chmod +x dist/zlux-build/*.sh - cd dist - tar cf ../zlux.tar -H ustar * + export _BPXK_AUTOCVT=ON && + cd ${paxPackageDir} && + chtag -tc iso8859-1 tag-files.sh && + chmod +x tag-files.sh && + mkdir -p zlux/share && cd zlux && + mkdir bin && cd share && + tar xpoUf ../../zlux.tar && + ../../tag-files.sh . && + cd zlux-server-framework && + rm -rf node_modules && + ${NODE_ENV_VARS} PATH=${NODE_HOME}/bin:$PATH npm install && + cd .. && + iconv -f iso8859-1 -t 1047 zlux-app-server/defaults/serverConfig/server.json > zlux-app-server/defaults/serverConfig/server.json.1047 && + mv zlux-app-server/defaults/serverConfig/server.json.1047 zlux-app-server/defaults/serverConfig/server.json && + chtag -tc 1047 zlux-app-server/defaults/serverConfig/server.json && + cd zlux-app-server/bin && + cp start.sh configure.sh ../../../bin && + if [ -e "validate.sh" ]; then + cp validate.sh ../../../bin + fi cd .. - git clone -b feature/tag-script https://github.com/1000TurquoisePogs/zowe-install-packaging.git - """ - withCredentials([usernamePassword( - credentialsId: PAX_CREDENTIALS, - usernameVariable: "PAX_USERNAME", - passwordVariable: "PAX_PASSWORD" - )]) { - def PAX_SERVER = [ - name : PAX_HOSTNAME, - host : PAX_HOSTNAME, - port : PAX_SSH_PORT, - user : PAX_USERNAME, - password : PAX_PASSWORD, - allowAnyHosts: true - ] - sshCommand remote: PAX_SERVER, command: \ - "rm -rf ${paxPackageDir} && mkdir -p ${paxPackageDir}" - sshPut remote: PAX_SERVER, from: "zlux.tar", into: "${paxPackageDir}/" - sshPut remote: PAX_SERVER, from: "zowe-install-packaging/scripts/tag-files.sh", into: "${paxPackageDir}/" - sshCommand remote: PAX_SERVER, command: \ - """ - export _BPXK_AUTOCVT=ON && - cd ${paxPackageDir} && - chtag -tc iso8859-1 tag-files.sh && - chmod +x tag-files.sh && - mkdir -p zlux/share && cd zlux && - mkdir bin && cd share && - tar xpoUf ../../zlux.tar && - ../../tag-files.sh . && - cd zlux-server-framework && - rm -rf node_modules && - ${NODE_ENV_VARS} PATH=${NODE_HOME}/bin:$PATH npm install && - cd .. && - iconv -f iso8859-1 -t 1047 zlux-app-server/defaults/serverConfig/server.json > zlux-app-server/defaults/serverConfig/server.json.1047 && - mv zlux-app-server/defaults/serverConfig/server.json.1047 zlux-app-server/defaults/serverConfig/server.json && - chtag -tc 1047 zlux-app-server/defaults/serverConfig/server.json && - cd zlux-app-server/bin && - cp start.sh configure.sh ../../../bin && - if [ -e "validate.sh" ]; then - cp validate.sh ../../../bin - fi - cd .. - if [ -e "manifest.yaml" ]; then - cp manifest.yaml ../../ - fi - cd ../../ - pax -x os390 -pp -wf ../zlux.pax * - """ - sshGet remote: PAX_SERVER, from: "${paxPackageDir}/zlux.pax", into: "zlux.pax" - if (mergedComponent) { - sshCommand remote: PAX_SERVER, command: \ - """ - cd ${paxPackageDir} && - cd zlux && - pax -x os390 -pp -wf ../${mergedComponent}.pax ${mergedComponent} - """ - sshGet remote: PAX_SERVER, from: "${paxPackageDir}/${mergedComponent}.pax", into: "${mergedComponent}.pax" - } - sshCommand remote: PAX_SERVER, command: "rm -rf ${paxPackageDir}" - } - + if [ -e "manifest.yaml" ]; then + cp manifest.yaml ../../ + fi + cd ../../ + pax -x os390 -pp -wf ../zlux.pax * + """ + sshGet remote: PAX_SERVER, from: "${paxPackageDir}/zlux.pax", into: "zlux.pax" + sshCommand remote: PAX_SERVER, command: "rm -rf ${paxPackageDir}" + } } + stage("Deploy") { def artifactoryServer = Artifactory.server ARTIFACTORY_SERVER def timestamp = (new Date()).format("yyyyMMdd.HHmmss") def target = null - if (mergedComponent) { - target = "${ARTIFACTORY_REPO}/${mergedComponent}/" + - "${zoweVersion}${branchName.toUpperCase()}/" + - "${mergedComponent}-${zoweVersion}-${timestamp}" - ["tar", "pax"].each { - def uploadSpec = """{"files": [{"pattern": "${mergedComponent}.${it}", "target": "${target}.${it}"}]}""" - def buildInfo = Artifactory.newBuildInfo() - artifactoryServer.upload spec: uploadSpec, buildInfo: buildInfo - artifactoryServer.publishBuildInfo buildInfo - } + if (zluxbuildpr.startsWith("PR-") && !params.'STARTED_JOB' && !params.'BUILD_DEFAULT'){ + target = "${ARTIFACTORY_REPO}/zlux-core/" + + "${zoweVersion}-${zluxbuildpr}/" + + "zlux-core-${zoweVersion}-${timestamp}" + ["tar", "pax"].each { + def uploadSpec = """{"files": [{"pattern": "zlux.${it}", "target": "${target}.${it}"}]}""" + def buildInfo = Artifactory.newBuildInfo() + artifactoryServer.upload spec: uploadSpec, buildInfo: buildInfo + artifactoryServer.publishBuildInfo buildInfo } - + } else if(params.'STARTED_JOB'){ + target = "${ARTIFACTORY_REPO}/zlux-core/" + + "${zoweVersion}-${params.'PR_NUMBER'}-${params.'REPO_NAME'}/" + + "zlux-core-${zoweVersion}-${timestamp}" + ["tar", "pax"].each { + def uploadSpec = """{"files": [{"pattern": "zlux.${it}", "target": "${target}.${it}"}]}""" + def buildInfo = Artifactory.newBuildInfo() + artifactoryServer.upload spec: uploadSpec, buildInfo: buildInfo + artifactoryServer.publishBuildInfo buildInfo + } + } else { target = "${ARTIFACTORY_REPO}/zlux-core/" + "${zoweVersion}${branchName.toUpperCase()}/" + "zlux-core-${zoweVersion}-${timestamp}" @@ -308,6 +326,7 @@ node(JENKINS_NODE) { artifactoryServer.upload spec: uploadSpec, buildInfo: buildInfo artifactoryServer.publishBuildInfo buildInfo } + } } } } catch (FlowInterruptedException e) { @@ -345,17 +364,17 @@ node(JENKINS_NODE) { [$class: "UpstreamComitterRecipientProvider"] ], body: \ - """ -

${currentBuild.result}

-
- -
- """ + """ +

${currentBuild.result}

+
+ +
+ """ } } } diff --git a/Jenkinsfile.release b/Jenkinsfile.release deleted file mode 100644 index 14a1ec1..0000000 --- a/Jenkinsfile.release +++ /dev/null @@ -1,227 +0,0 @@ -#!groovy - -/** - * This program and the accompanying materials are - * made available under the terms of the Eclipse Public License v2.0 which accompanies - * this distribution, and is available at https://www.eclipse.org/legal/epl-v20.html - * - * SPDX-License-Identifier: EPL-2.0 - * - * Copyright Contributors to the Zowe Project. - */ - - -/* - * A monstrous pipeline to build, run unit tests, package and deploy zLUX artifacts. - * It should be split / simplified at some point. - */ - -import org.jenkinsci.plugins.workflow.steps.FlowInterruptedException - - -JENKINS_NODE = "zlux-agent" -GITHUB_PROJECT = "zowe" -GITHUB_TOKEN = "zowe-robot-github" -GITHUB_SSH_KEY = "zlux-jenkins" - -ZLUX_CORE_PLUGINS = [ - "zlux-app-manager", - "zlux-app-server", - "zlux-build", - "zlux-platform", - "zlux-server-framework", - "zlux-shared" -] -DEFAULT_BRANCH = "rc" -ZOWE_MANIFEST_URL = \ - "https://raw.githubusercontent.com/zowe/zowe-install-packaging/rc/manifest.json.template" -ARTIFACTORY_SERVER = "zoweArtifactory" -ARTIFACTORY_REPO = "libs-snapshot-local/org/zowe/zlux" -// PAX_HOSTNAME = "172.30.0.1" -// PAX_HOSTNAME = "river.zowe.org" -PAX_HOSTNAME = "zzow01.zowe.marist.cloud" -// PAX_SSH_PORT = 2022 -PAX_SSH_PORT = 22 -// PAX_CREDENTIALS = "TestAdminzOSaaS2" -// PAX_CREDENTIALS = "ssh-zdt-test-image-guest" -PAX_CREDENTIALS = "ssh-marist-server-zzow01" -NODE_VERSION = "v12.16.1" -NODE_HOME = "/ZOWE/node/node-${NODE_VERSION}-os390-s390x" -NODE_ENV_VARS = "_TAG_REDIR_ERR=txt _TAG_REDIR_IN=txt _TAG_REDIR_OUT=txt __UNTAGGED_READ_MODE=V6" - -properties([ - parameters([ - string( - name: "RELEASE_VERSION", - defaultValue: "", - description: "Version of release (X.X.X)", - trim: true - ) - ]) -]) - - -def getZoweVersion() { - return params.RELEASE_VERSION - // def response = httpRequest url: ZOWE_MANIFEST_URL - // echo "Zowe manifest template:\n${response.content}" - // return (response.content =~ /"version"\s*:\s*"(.*)"/)[0][1] -} - -def zoweVersion = null -def paxPackageDir = "/ZOWE/tmp/~${env.BUILD_TAG}" - - -node(JENKINS_NODE) { - currentBuild.result = "SUCCESS" - try { - - stage("Prepare") { - zoweVersion = getZoweVersion() - env.BRANCH_NAME = DEFAULT_BRANCH - } - sshagent(credentials: [GITHUB_SSH_KEY]) { - stage("Checkout") { - sh \ - """ - mkdir zlux - git config --global user.email "zowe-robot@zowe.org" - git config --global user.name "Zowe Robot" - """ - ZLUX_CORE_PLUGINS.each { - sh \ - """ - cd zlux - git clone https://github.com/zowe/${it}.git - cd ${it} - git checkout ${DEFAULT_BRANCH} - """ - } - } - stage("Set version") { - def (majorVersion, minorVersion, microVersion) = zoweVersion.tokenize(".") - sh \ - """ - cd zlux/zlux-build - sed -i -e "s/MAJOR_VERSION=0/MAJOR_VERSION=${majorVersion}/" \\ - -e "s/MINOR_VERSION=8/MINOR_VERSION=${minorVersion}/" \\ - -e "s/REVISION=4/REVISION=${microVersion}/" \\ - version.properties - echo "Set version to:" - cat version.properties - """ - } - stage("Build") { - sh "bash -c 'cd zlux/zlux-build && set -o pipefail && ant production 2>&1 | grep -vE \"^\\s+\\[exec\\]\\s+0\\% compiling\"'" - } - - stage("Package") { - sh \ - """ - chmod +x dist/zlux-build/*.sh - cd dist - tar cf ../zlux.tar -H ustar * - cd .. - git clone -b feature/tag-script https://github.com/1000TurquoisePogs/zowe-install-packaging.git - """ - - withCredentials([usernamePassword( - credentialsId: PAX_CREDENTIALS, - usernameVariable: "PAX_USERNAME", - passwordVariable: "PAX_PASSWORD" - )]) { - def PAX_SERVER = [ - name : PAX_HOSTNAME, - host : PAX_HOSTNAME, - port : PAX_SSH_PORT, - user : PAX_USERNAME, - password : PAX_PASSWORD, - allowAnyHosts: true - ] - sshCommand remote: PAX_SERVER, command: \ - "rm -rf ${paxPackageDir} && mkdir -p ${paxPackageDir}" - sshPut remote: PAX_SERVER, from: "zlux.tar", into: "${paxPackageDir}/" - sshPut remote: PAX_SERVER, from: "zowe-install-packaging/scripts/tag-files.sh", into: "${paxPackageDir}/" - sshCommand remote: PAX_SERVER, command: \ - """ - export _BPXK_AUTOCVT=ON && - cd ${paxPackageDir} && - chtag -tc iso8859-1 tag-files.sh && - chmod +x tag-files.sh && - mkdir -p zlux/share && cd zlux && - mkdir bin && cd share && - tar xpoUf ../../zlux.tar && - ../../tag-files.sh . && - cd zlux-server-framework && - rm -rf node_modules && - ${NODE_ENV_VARS} PATH=${NODE_HOME}/bin:$PATH npm install && - cd .. && - iconv -f iso8859-1 -t 1047 zlux-app-server/defaults/serverConfig/server.json > zlux-app-server/defaults/serverConfig/server.json.1047 && - mv zlux-app-server/defaults/serverConfig/server.json.1047 zlux-app-server/defaults/serverConfig/server.json && - chtag -tc 1047 zlux-app-server/defaults/serverConfig/server.json && - cd zlux-app-server/bin && - cp start.sh configure.sh ../../../bin && - if [ -e "validate.sh" ]; then - cp validate.sh ../../../bin - fi - cd .. - if [ -e "manifest.yaml" ]; then - cp manifest.yaml ../../ - fi - cd ../../ - pax -x os390 -pp -wf ../zlux.pax * - """ - sshGet remote: PAX_SERVER, from: "${paxPackageDir}/zlux.pax", into: "zlux.pax" - } - } - stage("Deploy") { - def artifactoryServer = Artifactory.server ARTIFACTORY_SERVER - def timestamp = (new Date()).format("yyyyMMdd.HHmmss") - def target = "${ARTIFACTORY_REPO}/zlux-core/" + - "${zoweVersion}-${env.BRANCH_NAME.toUpperCase()}/" + - "zlux-core-${zoweVersion}-${timestamp}" - - ["tar", "pax"].each { - def uploadSpec = """{"files": [{"pattern": "zlux.${it}", "target": "${target}.${it}"}]}""" - def buildInfo = Artifactory.newBuildInfo() - artifactoryServer.upload spec: uploadSpec, buildInfo: buildInfo - artifactoryServer.publishBuildInfo buildInfo - } - } - } - } catch (FlowInterruptedException e) { - currentBuild.result = "ABORTED" - throw e - } catch (e) { - if (e.getMessage() != 'nothing to build') { - currentBuild.result = "FAILURE" - throw e - } - } finally { - stage("Report") { - def prettyParams = "n/a" - emailext \ - subject: """${env.JOB_NAME} [${env.BUILD_NUMBER}]: ${currentBuild.result}""", - attachLog: true, - mimeType: "text/html", - recipientProviders: [ - [$class: "RequesterRecipientProvider"], - [$class: "CulpritsRecipientProvider"], - [$class: "DevelopersRecipientProvider"], - [$class: "UpstreamComitterRecipientProvider"] - ], - body: \ - """ -

${currentBuild.result}

-
- -
- """ - } - } -} diff --git a/production.xml b/production.xml index fedc518..eb340ab 100644 --- a/production.xml +++ b/production.xml @@ -40,7 +40,6 @@ -