Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Initial pipeline based on jenkins-shared-library #20

Draft
wants to merge 3 commits into
base: v1.x/staging
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions .tarignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
.*
*.js.map
dco-signoffs
Jenkinsfile
sonar-project.properties
webClient/node_modules
nodeServer/node_modules
126 changes: 126 additions & 0 deletions Jenkinsfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,126 @@
#!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.
*/


PLUGIN_NAME = "sample-angular-app"
PLUGIN_ID = 'org.zowe.zlux.sample-angular-app'

GITHUB_SSH_KEY = "zlux-jenkins" // This is required for git+ssh npm dependencies


node("zlux-agent") {

def lib = library("jenkins-library").org.zowe.jenkins_shared_library
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We can use library("jenkins-library@staging") to temporarily import the latest updates on library. The staging branch has the changes of zowe/jenkins-library#14, zowe/jenkins-library#16, zowe/jenkins-library#17.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Library changes on staging have been merged into master. @staging can be removed now. Thanks for testing.

def pipeline = lib.pipelines.generic.GenericPipeline.new(this)
pipeline.admins.add("dnikolaev", "sgrady")

def baseBranch = env.CHANGE_TARGET? env.CHANGE_TARGET: env.BRANCH_NAME
def zoweManifestURL = \
"https://raw.githubusercontent.com/zowe/zowe-install-packaging" +
"/${baseBranch}/manifest.json.template"
def zoweManifestText = httpRequest(url: zoweManifestURL).content.replace("{BUILD_NUMBER}", "-")

pipeline.setup(
packageName: PLUGIN_ID,
version: readJSON(text: zoweManifestText)["version"],
github: [
email : lib.Constants.DEFAULT_GITHUB_ROBOT_EMAIL,
usernamePasswordCredential: lib.Constants.DEFAULT_GITHUB_ROBOT_CREDENTIAL
],
artifactory: [
url: lib.Constants.DEFAULT_ARTIFACTORY_URL,
usernamePasswordCredential : lib.Constants.DEFAULT_ARTIFACTORY_ROBOT_CREDENTIAL
],
pax: [
sshHost: lib.Constants.DEFAULT_PAX_PACKAGING_SSH_HOST,
sshPort: lib.Constants.DEFAULT_PAX_PACKAGING_SSH_PORT,
sshCredential: lib.Constants.DEFAULT_PAX_PACKAGING_SSH_CREDENTIAL,
remoteWorkspace: lib.Constants.DEFAULT_PAX_PACKAGING_REMOTE_WORKSPACE,
],
skipCheckout: true
)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

With zowe/jenkins-library#17, a new option skipCheckout: true is available for setup() method.


pipeline.createStage(
name: 'Checkout',
stage: {
dir(PLUGIN_NAME) {
checkout scm
}
pipeline.github.cloneRepository(
repository: "zowe/zlux-app-manager", branch: baseBranch, folder: "zlux-app-manager"
)
pipeline.github.cloneRepository(
repository: "zowe/zlux-platform", branch: baseBranch, folder: "zlux-platform"
)
}
)

pipeline.build(
operation: {
sshagent (credentials: [GITHUB_SSH_KEY]) {
sh "cd zlux-app-manager/virtual-desktop && npm ci"
sh \
"""
export MVD_DESKTOP_DIR=${env.WORKSPACE}/zlux-app-manager/virtual-desktop
packages=\$(find ${PLUGIN_NAME} -name package.json | { grep -v node_modules || true; })
for package in \$packages
do
sh -c "cd `dirname \$package` && npm ci && npm run build"
done
"""
}
}
)

pipeline.test(
name: "Unit tests",
junit : "unit-tests-report.xml",
allowMissingJunit: true,
operation: {
sh \
"""
packages=\$(find ${PLUGIN_NAME} -name package.json | { grep -v node_modules || true; })
for package in \$packages
do
sh -c "cd `dirname \$package` && npm run test"
done
"""
}
)

// pipeline.sonarScan(
// scannerTool: lib.Constants.DEFAULT_SONARQUBE_SCANNER_TOOL,
// scannerServer: lib.Constants.DEFAULT_SONARQUBE_SERVER
// )

// NB: jenkins-shared-library doesn't process `.ext.ext` properly
pipeline.packaging(
name: PLUGIN_NAME,
operation: {
sh "tar --exclude-from=${PLUGIN_NAME}/.tarignore -zcvf ${PLUGIN_NAME}.tar.gz ${PLUGIN_NAME}"
sh "mkdir -p .pax/ascii && tar -C .pax/ascii -xf ${PLUGIN_NAME}.tar.gz"
pipeline.pax.pack(
job : "pax-packaging-${PLUGIN_NAME}",
filename : "${PLUGIN_NAME}.pax.Z",
paxOptions : '',
keepTempFolder : false,
compress : true
)
}
)

pipeline.publish(
artifacts: ["${PLUGIN_NAME}.tar.gz", ".pax/${PLUGIN_NAME}.pax.Z"]
)

pipeline.end()
}