Skip to content

Commit d5eb67a

Browse files
authored
Add Jenkinsfile with parameters (#9)
* Add Jenkinsfile with parameters * Fix the pipeline syntax error * Fix the pipeline syntax error * Fix the pipeline syntax error * Fix the pipeline syntax error * Fix the pipeline syntax error * Fix the pipeline syntax error * Fix the pipeline syntax error * Fix the pipeline syntax error * Fix the pipeline syntax error
1 parent 29609bc commit d5eb67a

3 files changed

Lines changed: 34 additions & 0 deletions

File tree

Jenkinsfile-parameters.groovy

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
pipeline {
2+
agent any
3+
4+
parameters {
5+
string defaultValue: 'rick', description: 'just for testing', name: 'name', trim: true
6+
booleanParam defaultValue: false, description: 'You can use this flag to debug your Pipeline', name: 'debug'
7+
}
8+
9+
stages{
10+
stage('simple'){
11+
steps{
12+
echo "My name is ${params.name}."
13+
14+
script {
15+
if ("${params.debug}" == "true") {
16+
echo "You can put some debug info at here."
17+
echo "Another way to use param: " + params.name
18+
}
19+
}
20+
}
21+
}
22+
23+
stage('debug stage') {
24+
when {
25+
equals expected: true, actual: params.debug
26+
}
27+
steps {
28+
echo "It's joke, there're debug info here."
29+
}
30+
}
31+
}
32+
}

README-zh.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55
|文件|需求|描述|
66
|---|---|---|
7+
|[Jenkinsfile-parameters.groovy](Jenkinsfile-parameters.groovy)|没有特别需要依赖的。|在 Jenkinsfile 中使用参数化流水线的例子。|
78
|[Jenkinsfile-junit-k8s](Jenkinsfile-junit-k8s)|需要有一个带 `maven` 标签的代理节点。这个节点必须是在一个包含 `java` 容器的 pod 中。|生成 junit 报告。|
89
|[Jenkinsfile-input](Jenkinsfile-input)|任何类型的节点。|需要用户输入,然后流水线才可以继续。|
910
|[Jenkinsfile.jmeter.groovy](Jenkinsfile.jmeter.groovy)|一个 kubernetes 环境|在 Jenkins 中运行 JMeter 测试|

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ According to different use cases, we provide several Jenkinsfile for you:
44

55
|File|Requirement|Description|
66
|---|---|---|
7+
|[Jenkinsfile-parameters.groovy](Jenkinsfile-parameters.groovy)|No particular things are required.|A demo about how to use parameters in Jenkinsfile pipeline.|
78
|[Jenkinsfile-junit-k8s](Jenkinsfile-junit-k8s)|It requires an agent which has a label `maven`. The agent should be a pod which contains a container named `java`.|Generate junit report.|
89
|[Jenkinsfile-input](Jenkinsfile-input)|Any types of agent.|Require a user to input something, then the Pipeline will keep going.|
910
|[Jenkinsfile.jmeter.groovy](Jenkinsfile.jmeter.groovy)|A kubernetes environment|Running a JMeter test in Jenkins|

0 commit comments

Comments
 (0)