6
6
* SPDX-License-Identifier: EPL-2.0 *
7
7
* *
8
8
* Copyright Contributors to the Zowe Project. *
9
+ * Copyright IBM Corp, 2019.
9
10
* *
10
11
*/
11
12
@@ -23,11 +24,9 @@ def RELEASE_BRANCHES = ["master"]
23
24
*/
24
25
def PIPELINE_CONTROL = [
25
26
build : true ,
26
- unit_test : true ,
27
+ unit_test : true ,
27
28
system_test : true ,
28
- deploy : false ,
29
- smoke_test : false ,
30
- create_bundle : false ,
29
+ deploy : true ,
31
30
ci_skip : false ]
32
31
33
32
/**
@@ -42,7 +41,7 @@ def BUILD_RESULT = [
42
41
/**
43
42
* Test npm registry using for smoke test
44
43
*/
45
- def TEST_NPM_REGISTRY = " .... "
44
+ def TEST_NPM_REGISTRY = " https://eu.artifactory.swg-devops.com/artifactory/api/npm/cicsts-npm-virtual "
46
45
47
46
/**
48
47
* The root results folder for items configurable by environmental variables
@@ -81,6 +80,8 @@ def PRODUCT_NAME = "zowe-cli-cics-deploy-plugin"
81
80
*/
82
81
def ZOWE_CLI_INSTALL_DIR = " /.npm-global/lib/node_modules/@brightside/core"
83
82
83
+ def ARTIFACTORY_CREDENTIALS_ID = " c8e3aa62-5eef-4e6b-8a3f-aa1006a7ef01"
84
+
84
85
// Setup conditional build options. Would have done this in the options of the declarative pipeline, but it is pretty
85
86
// much impossible to have conditional options based on the branch :/
86
87
def opts = []
@@ -198,6 +199,7 @@ pipeline {
198
199
steps(' Install Zowe CLI' ) {
199
200
timeout(time : 10 , unit : ' MINUTES' ) {
200
201
echo " Install Zowe CLI globaly"
202
+ sh(" npm set registry https://registry.npmjs.org" )
201
203
sh(" npm set @brightside:registry https://api.bintray.com/npm/ca/brightside/" )
202
204
sh(" npm install -g @brightside/core@next" )
203
205
sh(" zowe --version" )
@@ -503,49 +505,35 @@ pipeline {
503
505
* DESCRIPTION
504
506
* -----------
505
507
* Bumps the pre-release version in preparation for publishing to an npm
506
- * registry. It will clean out any pending changes and switch to the real
507
- * branch that was published (currently the pipeline would be in a
508
- * detached HEAD at the commit) before executing the npm command to bump
509
- * the version.
510
- *
511
- * The step does checking against the commit that was checked out and
512
- * the BUILD_REVISION that was retrieved earlier. If they do not match,
513
- * the commit will not be pushed and the build will fail. This handles
514
- * the condition where the current build made it to this step but another
515
- * change had been pushed to the master branch. This means that we would
516
- * have to bump the version of a future commit to the one we just built
517
- * and tested, which is a big no no. A corresponding email will be sent
518
- * out in this situation to explain how this condition could have occurred.
519
- *
520
- * OUTPUTS
521
- * -------
522
- * GitHub: A commit containing the bumped version in the package.json.
523
- *
524
- * Commit Message:
525
- * Bumped pre-release version <VERSION_HERE> [ci skip]
508
+ * registry.
526
509
************************************************************************/
527
- // stage('Bump Version') {
528
- // when {
529
- // allOf {
530
- // expression {
531
- // return PIPELINE_CONTROL.ci_skip == false
532
- // }
533
- // expression {
534
- // return PIPELINE_CONTROL.deploy
535
- // }
536
- // expression {
537
- // return currentBuild.resultIsBetterOrEqualTo(BUILD_RESULT.success)
538
- // }
539
- // }
540
- // }
541
- // steps {
542
- // timeout(time: 5, unit: 'MINUTES') {
543
- // echo "Bumping Version"
544
-
545
- // echo 'Perform version bump for the branch'
546
- // }
547
- // }
548
- // }
510
+ stage(' Bump Version' ) {
511
+ when {
512
+ allOf {
513
+ expression {
514
+ return PIPELINE_CONTROL . ci_skip == false
515
+ }
516
+ expression {
517
+ return PIPELINE_CONTROL . deploy
518
+ }
519
+ expression {
520
+ return BRANCH_NAME == MASTER_BRANCH
521
+ }
522
+ }
523
+ }
524
+ steps {
525
+ timeout(time : 5 , unit : ' MINUTES' ) {
526
+ echo " Bumping Version"
527
+
528
+ // This npm command does the version bump
529
+ script {
530
+ def baseVersion = sh returnStdout : true , script : ' node -e "console.log(require(\' ./package.json\' ).version.split(\' -\' )[0])"'
531
+ def preReleaseVersion = baseVersion. trim() + " -next." + new Date (). format(" yyyyMMddHHmm" , TimeZone . getTimeZone(" UTC" ))
532
+ sh " npm version ${ preReleaseVersion} --no-git-tag-version"
533
+ }
534
+ }
535
+ }
536
+ }
549
537
/* ***********************************************************************
550
538
* STAGE
551
539
* -----
@@ -570,70 +558,45 @@ pipeline {
570
558
* -------
571
559
* npm: A package to an npm registry
572
560
************************************************************************/
573
- // stage('Deploy') {
574
- // when {
575
- // allOf {
576
- // expression {
577
- // return PIPELINE_CONTROL.ci_skip == false
578
- // }
579
- // expression {
580
- // return PIPELINE_CONTROL.deploy
581
- // }
582
- // expression {
583
- // return currentBuild.resultIsBetterOrEqualTo(BUILD_RESULT.success)
584
- // }
585
- // }
586
- // }
587
- // steps {
588
- // timeout(time: 5, unit: 'MINUTES') {
589
- // echo 'Deploy Binary'
590
-
591
- // echo 'Perform binary deployment'
592
- // }
593
- // }
594
- // }
595
- /* ***********************************************************************
596
- * STAGE
597
- * -----
598
- * Smoke Test
599
- *
600
- * TIMEOUT
601
- * -------
602
- * 5 Minutes
603
- *
604
- * EXECUTION CONDITIONS
605
- * --------------------
606
- * - PIPELINE_CONTROL.ci_skip is false
607
- * - PIPELINE_CONTROL.smoke_test is true
608
- * - The build is still successful and not unstable
609
- *
610
- * DESCRIPTION
611
- * -----------
612
- * Install the new pulished plugin and run some simple command to validate
613
- *
614
- ************************************************************************/
615
- // stage('Smoke Test') {
616
- // when {
617
- // allOf {
618
- // expression {
619
- // return PIPELINE_CONTROL.ci_skip == false
620
- // }
621
- // expression {
622
- // return PIPELINE_CONTROL.smoke_test
623
- // }
624
- // expression {
625
- // return currentBuild.resultIsBetterOrEqualTo(BUILD_RESULT.success)
626
- // }
627
- // }
628
- // }
629
- // steps {
630
- // timeout(time: 5, unit: 'MINUTES') {
631
- // echo "Smoke Test"
632
-
633
- // echo 'Perform smoke test here'
634
- // echo 'Record test reports artifacts'
635
- // }
636
- // }
637
- // }
561
+ stage(' Deploy' ) {
562
+ when {
563
+ allOf {
564
+ expression {
565
+ return PIPELINE_CONTROL . ci_skip == false
566
+ }
567
+ expression {
568
+ return PIPELINE_CONTROL . deploy
569
+ }
570
+ expression {
571
+ return BRANCH_NAME == MASTER_BRANCH
572
+ }
573
+ }
574
+ }
575
+ steps {
576
+ timeout(time : 5 , unit : ' MINUTES' ) {
577
+ echo ' Deploy Binary'
578
+ withCredentials([usernamePassword(credentialsId : ARTIFACTORY_CREDENTIALS_ID , usernameVariable : ' USERNAME' , passwordVariable : ' API_KEY' )]) {
579
+
580
+ // Set up authentication to Artifactory
581
+ sh " rm -f .npmrc"
582
+ sh ' curl -u $USERNAME:$API_KEY https://eu.artifactory.swg-devops.com/artifactory/api/npm/auth/ >> .npmrc'
583
+ sh " echo registry=$TEST_NPM_REGISTRY >> .npmrc"
584
+ sh " echo @brightside:registry=https://api.bintray.com/npm/ca/brightside/ >> .npmrc"
585
+ sh " echo @brightside:always-auth=false >> .npmrc"
586
+
587
+ script {
588
+ if (BRANCH_NAME == MASTER_BRANCH ) {
589
+ echo " publishing next to $TEST_NPM_REGISTRY "
590
+ sh " npm publish --tag next"
591
+ }
592
+ else {
593
+ echo " publishing latest to $TEST_NPM_REGISTRY "
594
+ sh " npm publish --tag latest"
595
+ }
596
+ }
597
+ }
598
+ }
599
+ }
600
+ }
638
601
}
639
602
}
0 commit comments