From 0d2de5dc1e24449ae489b24864b12b83e8075849 Mon Sep 17 00:00:00 2001 From: Omar Siam Date: Mon, 2 Jul 2018 17:28:40 +0200 Subject: [PATCH 1/7] Tutorial settings. --- Jenkinsfile | 15 +++++++++++++++ 1 file changed, 15 insertions(+) create mode 100644 Jenkinsfile diff --git a/Jenkinsfile b/Jenkinsfile new file mode 100644 index 0000000000..2b6476817e --- /dev/null +++ b/Jenkinsfile @@ -0,0 +1,15 @@ +pipeline { + agent { + docker { + image 'node:6-alpine' + args '-p 3000:3000' + } + } + stages { + stage('Build') { + steps { + sh 'npm install' + } + } + } +} \ No newline at end of file From 9be2ca53ce501a7fac2bd7f62f6ad4bc316d7f70 Mon Sep 17 00:00:00 2001 From: Omar Siam Date: Mon, 2 Jul 2018 18:15:41 +0200 Subject: [PATCH 2/7] Try set cache path, will try to create /.npm which is forbidden. --- Jenkinsfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Jenkinsfile b/Jenkinsfile index 2b6476817e..6b53bee91b 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -8,7 +8,7 @@ pipeline { stages { stage('Build') { steps { - sh 'npm install' + sh 'npm config set cache $(pwd)/.npm --global && npm install' } } } From dd146e201a453c5ba61aa709bfa4a90777e626a7 Mon Sep 17 00:00:00 2001 From: Omar Siam Date: Mon, 2 Jul 2018 18:17:43 +0200 Subject: [PATCH 3/7] Same problem, setting global needs write permission like root. --- Jenkinsfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Jenkinsfile b/Jenkinsfile index 6b53bee91b..19ce71278d 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -8,7 +8,7 @@ pipeline { stages { stage('Build') { steps { - sh 'npm config set cache $(pwd)/.npm --global && npm install' + sh 'npm config set cache $(pwd)/.npm-cache && npm install' } } } From 2f42e4cea45cce15dc5b05c63a7be6e88afe3b43 Mon Sep 17 00:00:00 2001 From: Omar Siam Date: Mon, 2 Jul 2018 18:24:06 +0200 Subject: [PATCH 4/7] try with globalconfig environment. --- Jenkinsfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Jenkinsfile b/Jenkinsfile index 19ce71278d..b63e9d7507 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -8,7 +8,7 @@ pipeline { stages { stage('Build') { steps { - sh 'npm config set cache $(pwd)/.npm-cache && npm install' + sh 'export NPM_CONFIG_GLOBALCONFIG="$(pwd)/npmrc" && npm config set cache $(pwd)/.npm-cache && npm install' } } } From 2b87a08db539ba8caaca78d92060615398457ca2 Mon Sep 17 00:00:00 2001 From: Omar Siam Date: Mon, 2 Jul 2018 18:27:54 +0200 Subject: [PATCH 5/7] globalconfig as parameter ... --- Jenkinsfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Jenkinsfile b/Jenkinsfile index b63e9d7507..daf80cf36d 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -8,7 +8,7 @@ pipeline { stages { stage('Build') { steps { - sh 'export NPM_CONFIG_GLOBALCONFIG="$(pwd)/npmrc" && npm config set cache $(pwd)/.npm-cache && npm install' + sh 'npm --globalconfig $(pwd)/npmrc config set cache $(pwd)/.npm-cache && npm --globalconfig $(pwd)/npmrc install' } } } From 646ed97e3e773071f9d3cfde26395d58fe549853 Mon Sep 17 00:00:00 2001 From: Omar Siam Date: Mon, 2 Jul 2018 18:32:02 +0200 Subject: [PATCH 6/7] Creating a local .npmrc. --- Jenkinsfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Jenkinsfile b/Jenkinsfile index daf80cf36d..6209277a3f 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -8,7 +8,7 @@ pipeline { stages { stage('Build') { steps { - sh 'npm --globalconfig $(pwd)/npmrc config set cache $(pwd)/.npm-cache && npm --globalconfig $(pwd)/npmrc install' + sh 'echo "cache = $(pwd)/.npm-cache" > .npmrc && npm install' } } } From 312ef104f6910479abe664f54db5a35e0072852f Mon Sep 17 00:00:00 2001 From: Omar Siam Date: Mon, 2 Jul 2018 18:36:50 +0200 Subject: [PATCH 7/7] Tutorial add test. --- Jenkinsfile | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/Jenkinsfile b/Jenkinsfile index 6209277a3f..abfd022f19 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -5,11 +5,19 @@ pipeline { args '-p 3000:3000' } } + environment { + CI = 'true' + } stages { stage('Build') { steps { sh 'echo "cache = $(pwd)/.npm-cache" > .npmrc && npm install' } } + stage('Test') { + steps { + sh './jenkins/scripts/test.sh' + } + } } } \ No newline at end of file