Skip to content

Commit

Permalink
Improve jenkins-pipeline-examples
Browse files Browse the repository at this point in the history
  • Loading branch information
eyalbe4 committed May 28, 2016
1 parent a676c56 commit c737056
Show file tree
Hide file tree
Showing 2 changed files with 56 additions and 1 deletion.
12 changes: 11 additions & 1 deletion jenkins-pipeline-examples/README.md
Expand Up @@ -156,6 +156,16 @@ You can also use [AQL](https://www.jfrog.com/confluence/display/RTF/Artifactory+
```
## Examples
The examples below are meant to help you get started using the Artifactory DSL in your Pipeline scripts.
You can run the examples by following one of the two methods described below.
In your Jenkins job configuration, set *Definition* to "Pipeline script",
and then copy the content of the example's Jenkinsfile into the *Script* text-area.
Alternatively, you can do the following:
* Set *Definition* to "Pipeline script from SCM".
* Set *SCM* to *Git*.
* Set *Repository URL* to *https://github.com/JFrogDev/project-examples.git*
* Set *Script Path* to the relative path to the example's Jenkinsfile. For example, for the below *props-example*, set *Script Path* to *jenkins-pipeline-examples/props-example/Jenkinsfile*

* The [props-example](https://github.com/jfrogdev/project-examples/tree/master/jenkins-pipeline-examples/props-example) download and upload files to Artifactory with properties. The props-example also uses a placeholder when uploading.
Here are the available examples.
* The [props-example](https://github.com/jfrogdev/project-examples/tree/master/jenkins-pipeline-examples/props-example) downloads and uploads files to Artifactory with properties. The props-example also uses a placeholder when uploading.
* The [props-single-file-example](https://github.com/jfrogdev/project-examples/tree/master/jenkins-pipeline-examples/props-single-file-example) is the same as the [props-example](https://github.com/jfrogdev/project-examples/tree/master/jenkins-pipeline-examples/props-example), but has the specs embedded inside the Groovy script.
* The [aql-example](https://github.com/jfrogdev/project-examples/tree/master/jenkins-pipeline-examples/aql-example) uses [AQL](https://www.jfrog.com/confluence/display/RTF/Artifactory+Query+Language) in its download spec.
45 changes: 45 additions & 0 deletions jenkins-pipeline-examples/props-single-file-example/Jenkinsfile
@@ -0,0 +1,45 @@
node {
git url: 'https://github.com/jfrogdev/project-examples.git'
def filePathPrefix = 'jenkins-pipeline-examples/props-example/'

// Get Artifactory server instance, defined in the Artifactory Plugin administration page.
def server = Artifactory.server SERVER_ID

// Create the upload spec.
def uploadSpec = """{
"files": [
{
"pattern": "jenkins-pipeline-examples/files/ArtifactoryPipeline.zip",
"target": "libs-snapshot-local",
"props": "p1=v1;p2=v2"
},
{
"pattern": "jenkins-pipeline-examples/files/ArtifactoryPipelineNoProps.zip",
"target": "libs-snapshot-local"
}
]
}"""

// Upload to Artifactory.
def buildInfo1 = server.upload uploadSpec

// Create the download spec.
def downloadSpec = """{
"files": [
{
"pattern": "libs-snapshot-local/*(Pipeline).zip",
"target": "Bazinga/{1}/",
"props": "p1=v1;p2=v2"
}
]
}"""

// Download from Artifactory.
def buildInfo2 = server.download downloadSpec

// Merge the upload and download build-info objects.
buildInfo1.append buildInfo2

// Publish the build to Artifactory
server.publishBuildInfo buildInfo1
}

0 comments on commit c737056

Please sign in to comment.