Skip to content

Commit 0498c3d

Browse files
author
Patrick Wolf
committed
Merge remote-tracking branch 'upstream/master'
2 parents 85929f7 + b894be2 commit 0498c3d

File tree

19 files changed

+143
-90
lines changed

19 files changed

+143
-90
lines changed

jenkinsfile-examples/nodejs-build-test-deploy-docker-notify/Jenkinsfile

Lines changed: 32 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -31,48 +31,55 @@ node('node') {
3131

3232
try {
3333

34-
stage 'Checkout'
34+
stage('Checkout'){
3535

36-
checkout scm
36+
checkout scm
37+
}
3738

38-
stage 'Test'
39+
stage('Test'){
3940

40-
env.NODE_ENV = "test"
41+
env.NODE_ENV = "test"
4142

42-
print "Environment will be : ${env.NODE_ENV}"
43+
print "Environment will be : ${env.NODE_ENV}"
4344

44-
sh 'node -v'
45-
sh 'npm prune'
46-
sh 'npm install'
47-
sh 'npm test'
45+
sh 'node -v'
46+
sh 'npm prune'
47+
sh 'npm install'
48+
sh 'npm test'
4849

49-
stage 'Build Docker'
50+
}
51+
52+
stage('Build Docker'){
5053

5154
sh './dockerBuild.sh'
55+
}
56+
57+
stage('Deploy'){
5258

53-
stage 'Deploy'
59+
echo 'Push to Repo'
60+
sh './dockerPushToRepo.sh'
5461

55-
echo 'Push to Repo'
56-
sh './dockerPushToRepo.sh'
62+
echo 'ssh to web server and tell it to pull new image'
63+
sh 'ssh [email protected] running/xxxxxxx/dockerRun.sh'
5764

58-
echo 'ssh to web server and tell it to pull new image'
59-
sh 'ssh [email protected] running/xxxxxxx/dockerRun.sh'
65+
}
6066

61-
stage 'Cleanup'
67+
stage('Cleanup'){
6268

63-
echo 'prune and cleanup'
64-
sh 'npm prune'
65-
sh 'rm node_modules -rf'
69+
echo 'prune and cleanup'
70+
sh 'npm prune'
71+
sh 'rm node_modules -rf'
6672

67-
mail body: 'project build successful',
68-
69-
replyTo: '[email protected]',
70-
subject: 'project build successful',
71-
73+
mail body: 'project build successful',
74+
75+
replyTo: '[email protected]',
76+
subject: 'project build successful',
77+
78+
}
7279

73-
}
7480

7581

82+
}
7683
catch (err) {
7784

7885
currentBuild.result = "FAILURE"
Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1-
// This shows a simple build wrapper example, using the AnsiColorBuildWrapper plugin.
1+
// This shows a simple build wrapper example, using the AnsiColor plugin.
22
node {
3-
// This is the current syntax for invoking a build wrapper, naming the class.
4-
wrap([$class: 'AnsiColorBuildWrapper']) {
3+
// This displays colors using the 'xterm' ansi color map.
4+
ansiColor('xterm') {
55
// Just some echoes to show the ANSI color.
66
stage "\u001B[31mI'm Red\u001B[0m Now not"
77
}
8-
}
8+
}
Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
# Synopsis
22

33
This shows usage of a simple build wrapper, specifically the
4-
AnsiColorBuildWrapper plugin, which adds ANSI coloring to the console output.
5-
4+
AnsiColor plugin, which adds ANSI coloring to the console output.

pipeline-examples/artifactory-generic-upload-download/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,4 @@
22

33
This is a simple demonstration of how to download dependencies, upload artifacts and publish build info to Artifactory.
44
<br>
5-
Read the full documentation [here](https://wiki.jenkins-ci.org/display/JENKINS/Artifactory+-+Working+With+the+Pipeline+Jenkins+Plugin).
5+
Read the full documentation [here](https://www.jfrog.com/confluence/display/RTF/Working+With+Pipeline+Jobs+in+Jenkins).

pipeline-examples/artifactory-gradle-build/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,4 @@
22

33
This is a simple demonstration of how to run a Gradle build, that resolves dependencies, upload artifacts and publish build info to Artifactory.
44
<br>
5-
Read the full documentation [here](https://wiki.jenkins-ci.org/display/JENKINS/Artifactory+-+Working+With+the+Pipeline+Jenkins+Plugin).
5+
Read the full documentation [here](https://www.jfrog.com/confluence/display/RTF/Working+With+Pipeline+Jobs+in+Jenkins).

pipeline-examples/artifactory-gradle-build/artifactoryGradleBuild.groovy

Lines changed: 17 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -3,20 +3,25 @@ node {
33
def server = Artifactory.server "SERVER_ID"
44
// Create an Artifactory Gradle instance.
55
def rtGradle = Artifactory.newGradleBuild()
6+
def buildInfo
67

7-
stage 'Clone sources'
8-
git url: 'https://github.com/jfrogdev/project-examples.git'
8+
stage('Clone sources') {
9+
git url: 'https://github.com/jfrogdev/project-examples.git'
10+
}
911

10-
stage 'Artifactory configuration'
11-
// Tool name from Jenkins configuration
12-
rtGradle.tool = "Gradle-2.4"
13-
// Set Artifactory repositories for dependencies resolution and artifacts deployment.
14-
rtGradle.deployer repo:'ext-release-local', server: server
15-
rtGradle.resolver repo:'remote-repos', server: server
12+
stage('Artifactory configuration') {
13+
// Tool name from Jenkins configuration
14+
rtGradle.tool = "Gradle-2.4"
15+
// Set Artifactory repositories for dependencies resolution and artifacts deployment.
16+
rtGradle.deployer repo:'ext-release-local', server: server
17+
rtGradle.resolver repo:'remote-repos', server: server
18+
}
1619

17-
stage 'Gradle build'
18-
def buildInfo = rtGradle.run rootDir: "gradle-examples/4/gradle-example-ci-server/", buildFile: 'build.gradle', tasks: 'clean artifactoryPublish'
20+
stage('Gradle build') {
21+
buildInfo = rtGradle.run rootDir: "gradle-examples/4/gradle-example-ci-server/", buildFile: 'build.gradle', tasks: 'clean artifactoryPublish'
22+
}
1923

20-
stage 'Publish build info'
21-
server.publishBuildInfo buildInfo
24+
stage('Publish build info') {
25+
server.publishBuildInfo buildInfo
26+
}
2227
}

pipeline-examples/artifactory-maven-build/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,4 @@
22

33
This is a simple demonstration of how to run a Maven build, that resolves dependencies, upload artifacts and publish build info to Artifactory.
44
<br>
5-
Read the full documentation [here](https://wiki.jenkins-ci.org/display/JENKINS/Artifactory+-+Working+With+the+Pipeline+Jenkins+Plugin).
5+
Read the full documentation [here](https://www.jfrog.com/confluence/display/RTF/Working+With+Pipeline+Jobs+in+Jenkins).

pipeline-examples/artifactory-maven-build/artifactoryMavenBuild.groovy

Lines changed: 17 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -3,20 +3,25 @@ node {
33
def server = Artifactory.server "SERVER_ID"
44
// Create an Artifactory Maven instance.
55
def rtMaven = Artifactory.newMavenBuild()
6+
def buildInfo
67

7-
stage 'Clone sources'
8-
git url: 'https://github.com/jfrogdev/project-examples.git'
8+
stage('Clone sources') {
9+
git url: 'https://github.com/jfrogdev/project-examples.git'
10+
}
911

10-
stage 'Artifactory configuration'
11-
// Tool name from Jenkins configuration
12-
rtMaven.tool = "Maven-3.3.9"
13-
// Set Artifactory repositories for dependencies resolution and artifacts deployment.
14-
rtMaven.deployer releaseRepo:'libs-release-local', snapshotRepo:'libs-snapshot-local', server: server
15-
rtMaven.resolver releaseRepo:'libs-release', snapshotRepo:'libs-snapshot', server: server
12+
stage('Artifactory configuration') {
13+
// Tool name from Jenkins configuration
14+
rtMaven.tool = "Maven-3.3.9"
15+
// Set Artifactory repositories for dependencies resolution and artifacts deployment.
16+
rtMaven.deployer releaseRepo:'libs-release-local', snapshotRepo:'libs-snapshot-local', server: server
17+
rtMaven.resolver releaseRepo:'libs-release', snapshotRepo:'libs-snapshot', server: server
18+
}
1619

17-
stage 'Maven build'
18-
def buildInfo = rtMaven.run pom: 'maven-example/pom.xml', goals: 'clean install'
20+
stage('Maven build') {
21+
buildInfo = rtMaven.run pom: 'maven-example/pom.xml', goals: 'clean install'
22+
}
1923

20-
stage 'Publish build info'
21-
server.publishBuildInfo buildInfo
24+
stage('Publish build info') {
25+
server.publishBuildInfo buildInfo
26+
}
2227
}
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
[configFile Provider plugin](https://plugins.jenkins.io/config-file-provider) enables provisioning of various types of configuration files. Plugin works in such a way as to make the configuration available for the entire duration of the build across all the build agents that are used to execute the build.
2+
3+
Common scenarios that demand the usage of configuration files:
4+
5+
- Provide properties that can be consumed by the build tool
6+
- Global settings that override local settings
7+
- Details of credentials needed to access repos
8+
- Inputs to generate binary images that need to be tailored to specific architectures
9+
10+
The example shows simple usage of configFile Provider plugin and howto access it's contents.
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
#!groovy
2+
3+
node {
4+
stage('configFile Plugin') {
5+
6+
// 'ID' refers to alpha-numeric value generated automatically by Jenkins.
7+
// This code snippet assumes that the config file is stored in Jenkins.
8+
9+
// help to assign the ID of config file to a variable, this is optional
10+
// as ID can be used directly within 'configFileProvider' step too.
11+
def mycfg_file = '<substitute-alpha-numeric-value-cfgfille-here-within-quotes>'
12+
13+
// whether referencing the config file as ID (directly) or via user-defined
14+
// variable, 'configFileProvider' step enables access to the config file
15+
// via 'name' given for the field, 'variable:'
16+
configFileProvider([configFile(fileId: mycfg_file, variable: 'PACKER_OPTIONS')]) {
17+
echo " =========== ^^^^^^^^^^^^ Reading config from pipeline script "
18+
sh "cat ${env.PACKER_OPTIONS}"
19+
echo " =========== ~~~~~~~~~~~~ ============ "
20+
21+
// Access to config file opens up other possibilities like
22+
// passing on the configuration to an external script for other tasks, like,
23+
// for example, to set generic options that can be used for generating
24+
// binary images using packer.
25+
echo " =========== ^^^^^^^^^^^^ Reading config via Python... "
26+
sh "python build_image.py ${env.PACKER_OPTIONS}"
27+
echo " =========== ~~~~~~~~~~~~ ============ "
28+
}
29+
}
30+
}

0 commit comments

Comments
 (0)