meta data for this page
Differences
This shows you the differences between two versions of the page.
Both sides previous revision Previous revision Next revision | Previous revision | ||
sw:jenkins [2018/11/07 15:13] niziak |
sw:jenkins [2021/03/31 20:38] (current) niziak |
||
---|---|---|---|
Line 1: | Line 1: | ||
- | + | ====== Jenkins ====== | |
====== Pipeline ====== | ====== Pipeline ====== | ||
+ | * is main Jenkins plugin which act as main build engine (from Jenkins 2.0) | ||
* **replay** feature let to run job with modified by hand ''Jenkinsfile'' | * **replay** feature let to run job with modified by hand ''Jenkinsfile'' | ||
+ | | ||
- | ====== Jenkinsfile ===== | + | ===== Scripted pipeline ==== |
It is possible to write Jenkinsfile's as Groovy scripts (advanced) or using Declarative Pipeline Syntax. | It is possible to write Jenkinsfile's as Groovy scripts (advanced) or using Declarative Pipeline Syntax. | ||
- | **Scripted pipeline** https://jenkins.io/doc/book/pipeline/syntax/#scripted-pipeline | + | [[https://dzone.com/articles/top-10-best-practices-for-jenkins-pipeline|Top 10 Best Practices for Jenkins Pipeline ]] |
+ | [[https://www.blazemeter.com/blog/how-to-use-the-jenkins-scripted-pipeline]] | ||
+ | [[https://jenkins.io/doc/book/pipeline/syntax/#scripted-pipeline]] | ||
<file | jenkinsfile> | <file | jenkinsfile> | ||
node { | node { | ||
+ | stage("a") { | ||
+ | } | ||
+ | stage("b") { | ||
+ | } | ||
+ | stage("c") { | ||
+ | parallel ( | ||
+ | 'taskA': { stage("1") { }}, | ||
+ | 'taskB': { stage("2") { }}, | ||
+ | ) | ||
+ | } | ||
+ | stage("archive") { | ||
+ | archiveArtifacts artifacts: 'out_*/*.*' | ||
+ | archiveArtifacts artifacts: 'contiki/tools/cc2538-bsl/cc2538-bsl.py' | ||
+ | } | ||
+ | } | ||
</file> | </file> | ||
- | https://jenkins.io/doc/pipeline/examples/ | + | NOTE: |
+ | * **parallel** expect map as argument. [[https://www.cloudbees.com/blog/parallelism-and-distributed-builds-jenkins]] | ||
+ | * | ||
- | **Declarative Pipeline** | + | |
+ | |||
+ | [[https://jenkins.io/doc/pipeline/tour/hello-world/|Creating your first Pipeline]] | ||
+ | [[https://jenkins.io/doc/pipeline/examples/]] | ||
+ | [[https://www.blazemeter.com/blog/how-to-use-the-jenkins-scripted-pipeline]] | ||
+ | [[https://wiki.jenkins.io/display/JENKINS/Distributed+builds|Distributed builds]] | ||
+ | |||
+ | ==== archiveArtifacts ==== | ||
+ | |||
+ | **archiveArtifacts:** | ||
+ | * ''Directory/**/*.*'' -> All the files recursively under Directory | ||
+ | * ''**/*.*'' -> all the files in the workspace | ||
+ | * ''**/*.xml'' -> all xml files in your workspace. | ||
+ | * ''Directory/**/*.xml'' -> All the xml files recursively under Directory | ||
+ | |||
+ | <file groovy> | ||
+ | archiveArtifacts artifacts: 'file.extension''' | ||
+ | archiveArtifacts artifacts: 'teste.js' | ||
+ | archiveArtifacts artifacts: '*.js' | ||
+ | archiveArtifacts artifacts: 'teste.js', onlyIfSuccessful: true | ||
+ | </file> | ||
+ | |||
+ | ===== Declarative Pipeline==== | ||
<file | Jenkinsfile> | <file | Jenkinsfile> | ||
pipeline { | pipeline { | ||
agent any | agent any | ||
+ | stages { | ||
+ | stage('Download') { | ||
+ | steps { | ||
+ | sh 'make config' | ||
+ | sh 'echo "artifact file" > generatedFile.txt' | ||
+ | } | ||
+ | } | ||
+ | } | ||
+ | post { | ||
+ | always { | ||
+ | archiveArtifacts artifacts: 'generatedFile.txt', onlyIfSuccessful: true | ||
+ | } | ||
+ | } | ||
} | } | ||
</file> | </file> | ||
+ | |||
+ | |||
+ | ===== Global Pipeline Libraries ===== | ||
+ | |||
+ | //You may also declare whether scripts need to explicitly request that library (detailed below), or if it is present by default. Furthermore, if you specify a version in Jenkins configuration, you can block scripts from selecting a different version.// | ||
+ | |||
+ | [[https://jenkins.io/doc/book/pipeline/shared-libraries/]] | ||
+ | |||
+ | [[https://stackoverflow.com/questions/38695237/create-resusable-jenkins-pipeline-script]] | ||
+ | [[https://jenkins.io/blog/2017/10/02/pipeline-templates-with-shared-libraries/|Share a standard Pipeline across multiple projects with Shared Libraries]] | ||
+ | [[https://automatingguy.com/2017/12/29/jenkins-pipelines-shared-libraries/|Exploring Jenkins Pipelines: Shared Libraries]] | ||
+ | [[https://jenkins.io/doc/book/pipeline/shared-libraries/|Extending with Shared Libraries]] | ||
+ | [[https://cleverbuilder.com/articles/jenkins-shared-library/]] | ||
+ | |||
+ | |||
+ | |||
====== Workspace ====== | ====== Workspace ====== |