Skip to content

Commit baf195e

Browse files
authored
Update URLs and paths to refer this repository (#16)
1 parent b79cfff commit baf195e

7 files changed

Lines changed: 25 additions & 25 deletions

File tree

docs/examples/jenkins/ansible-kubernetes/Jenkinsfile

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
String d = "docs/examples/jenkins/ansible-kubernetes"
2+
13
pipeline {
24
agent any
35
parameters {
@@ -7,22 +9,19 @@ pipeline {
79
stage("deploy") {
810
agent {
911
dockerfile {
10-
dir "ansible-kubernetes"
12+
dir "$d"
1113
reuseNode true
1214
}
1315
}
1416
environment {
1517
K8S_AUTH_KUBECONFIG = credentials('kubeconfig')
18+
KUBECONFIG = credentials('kubeconfig')
1619
}
1720
steps {
1821
sh """
19-
ansible-playbook ansible-kubernetes/deploy-to-kubernetes.yml --extra-vars "animal=${params.ANIMAL}"
22+
ansible-playbook $d/deploy-to-kubernetes.yml --extra-vars "animal=${params.ANIMAL}"
23+
./$d/wait-until-service-up.sh
2024
"""
21-
// Do not use Groovy string interpolation for credential
22-
sh '''
23-
export KUBECONFIG=$K8S_AUTH_KUBECONFIG
24-
./ansible-kubernetes/wait-until-service-up.sh
25-
'''
2625
}
2726
}
2827
}

docs/examples/jenkins/ansible-kubernetes/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ In the _New credentials_ form:
2323

2424
First, create a new pipeline via [New Item](http://localhost:8080/view/all/newJob) button in the rigth side menu of the Jenkins dashboard. The name of the pipeline could be for example `Animals` and it should be an pipeline.
2525

26-
In the configure pipeline view, scroll to the bottom and under Pipeline sub-header select `Pipeline script from SCM`. SCM type should be `Git` and Repository URL the url of this repository: `https://github.com/kangasta/jenkins-examples.git`. Ensure that branch specifier includes `main` branch of the repository and modify the Script Path to be `ansible-kubernetes\Jenkinsfile`.
26+
In the configure pipeline view, scroll to the bottom and under Pipeline sub-header select `Pipeline script from SCM`. SCM type should be `Git` and Repository URL the url of this repository: `https://github.com/kangasta/cicd-examples.git`. Ensure that branch specifier includes `main` branch of the repository and modify the Script Path to be `docs/examples/jenkins/ansible-kubernetes/Jenkinsfile`.
2727

2828
After you have created the pipeline, try to execute it by clicking _Build Now_. The pipeline should have deployed the example application into the Kubernetes cluster with the default image tag (`cow`) defined in the [deploy-to-kubernetes.yml](./deploy-to-kubernetes.yml) Ansible playbook.
2929

docs/examples/jenkins/ansible-kubernetes/wait-until-service-up.sh

100644100755
File mode changed.

docs/examples/jenkins/build-status-pipelines/README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,9 @@ To run the job DSL script, create a new pipeline with following script as an inl
1414

1515
```groovy
1616
node {
17-
git branch: 'main', url: 'https://github.com/kangasta/jenkins-examples.git'
18-
jobDsl targets: 'build-status-pipelines/jobs.groovy'
17+
git branch: 'main', url: 'https://github.com/kangasta/cicd-examples.git'
18+
jobDsl targets: 'docs/examples/jenkins/build-status-pipelines/jobs.groovy'
1919
}
2020
```
2121

22-
The execution will likely fail with `ERROR: script not yet approved for use` message. To enable this script, navigate to [Manage Jenkins > In-process Script Approval](http://localhost:8080/scriptApproval/), inspect the script, and click Approve. Then try to run the created seed project again. It should now succeed and list the created resources.
22+
The execution will likely fail with `ERROR: script not yet approved for use` message. To enable this script, navigate to [Manage Jenkins > In-process Script Approval](http://localhost:8080/scriptApproval/), inspect the script, and click _Approve_. Then try to run the created seed project again. It should now succeed and list the created resources.

docs/examples/jenkins/build-status-pipelines/jobs.groovy

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
String d = "docs/examples/jenkins/build-status-pipelines"
2+
13
folder('Status') {
24
description('Example pipelines to produce success, unstable, failed, aborted, and not-built statuses.')
35
}
@@ -9,7 +11,7 @@ for (status in statuses) {
911
pipelineJob(name) {
1012
definition {
1113
cps {
12-
script(readFileFromWorkspace("build-status-pipelines/${status.toLowerCase()}.Jenkinsfile"))
14+
script(readFileFromWorkspace("$d/${status.toLowerCase()}.Jenkinsfile"))
1315
sandbox()
1416
}
1517
}
@@ -20,7 +22,7 @@ for (status in statuses) {
2022
pipelineJob('Status/Not built') {
2123
definition {
2224
cps {
23-
script(readFileFromWorkspace("build-status-pipelines/success.Jenkinsfile"))
25+
script(readFileFromWorkspace("$d/success.Jenkinsfile"))
2426
sandbox()
2527
}
2628
}

docs/examples/jenkins/parallel-robot-pipeline/Jenkinsfile

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
String d = "docs/examples/jenkins/parallel-robot-pipeline"
2+
13
pipeline {
24
agent any
35
parameters {
@@ -11,24 +13,24 @@ pipeline {
1113
parallel {
1214
stage('Chromium') {
1315
agent { docker {
14-
image 'ghcr.io/kangasta/robot-selenium-chromium:latest'
16+
image 'ghcr.io/kangasta/robot-browser:latest'
1517
args '--entrypoint=""'
1618
reuseNode true
1719
} }
1820
steps {
19-
sh "robot -d robot_output -l none -r none -o chromium.xml -N Chromium -v URL:${params.URL} --nostatusrc parallel-robot-pipeline/suites/"
21+
sh "robot -d robot_output -l none -r none -o chromium.xml -N Chromium -v URL:${params.URL} --nostatusrc $d/suites/"
2022
// If reuseNode true was not used, we would have to stash the output XML.
2123
// stash includes: 'robot_output/**', name: 'Chromium'
2224
}
2325
}
2426
stage('Firefox') {
2527
agent { docker {
26-
image 'ghcr.io/kangasta/robot-selenium-firefox:latest'
28+
image 'ghcr.io/kangasta/robot-browser:latest'
2729
args '--entrypoint=""'
2830
reuseNode true
2931
} }
3032
steps {
31-
sh "robot -d robot_output -l none -r none -o b.xml -N Firefox -v URL:${params.URL} --nostatusrc parallel-robot-pipeline/suites/"
33+
sh "robot -d robot_output -l none -r none -o b.xml -N Firefox -v URL:${params.URL} --nostatusrc $d/suites/"
3234
// If reuseNode true was not used, we would have to stash the output XML.
3335
// stash includes: 'robot_output/**', name: 'Firefox'
3436
}
@@ -37,18 +39,15 @@ pipeline {
3739
}
3840
stage('Process logs') {
3941
agent { docker {
40-
image 'ghcr.io/kangasta/robot-selenium-firefox:latest'
42+
image 'ghcr.io/kangasta/robot-browser:latest'
4143
args '--entrypoint=""'
4244
reuseNode true
4345
} }
4446
steps {
4547
// If reuseNode true was not used, we would have to unstash the output XMLs.
4648
// unstash 'Chromium'
4749
// unstash 'Firefox'
48-
sh """
49-
rebot -d rebot_output -o output.xml -N '${env.JOB_BASE_NAME} ${BUILD_DISPLAY_NAME}' --nostatusrc robot_output/*.xml
50-
cp -r robot_output/*_screenshots rebot_output/ || true # Do not fail the pipeline if no screenshot are available
51-
"""
50+
sh "rebot -d rebot_output -o output.xml -N '${env.JOB_BASE_NAME} ${BUILD_DISPLAY_NAME}' --nostatusrc robot_output/*.xml"
5251
}
5352
}
5453
}

docs/examples/jenkins/parallel-robot-pipeline/README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,11 @@ In order to be able to run the pipeline we will need [Docker Pipeline](https://p
1010

1111
## Configure the pipeline
1212

13-
First, create a new pipeline via [New Item](http://localhost:8080/view/all/newJob) button in the rigth side menu of the Jenkins dashboard. The name of the pipeline could be for example `Screenshots` and it should be an pipeline.
13+
First, create a new pipeline via _[New Item](http://localhost:8080/view/all/newJob)_ button in the rigth side menu of the Jenkins dashboard. The name of the pipeline could be for example `Screenshots` and it should be an pipeline.
1414

15-
In the configure pipeline view, scroll to the bottom and under Pipeline sub-header select `Pipeline script from SCM`. SCM type should be `Git` and Repository URL the url of this repository: `https://github.com/kangasta/jenkins-examples.git`. Ensure that branch specifier includes `main` branch of the repository and modify the Script Path to be `parallel-robot-pipeline/Jenkinsfile`.
15+
In the configure pipeline view, scroll to the bottom and under Pipeline sub-header select `Pipeline script from SCM`. SCM type should be `Git` and Repository URL the url of this repository: `https://github.com/kangasta/cicd-examples.git`. Ensure that branch specifier includes `main` branch of the repository and modify the Script Path to be `docs/examples/jenkins/parallel-robot-pipeline/Jenkinsfile`.
1616

17-
After you have created the pipeline, try to execute it by clicking Build Now. All Robot Framework tasks should be in Skipped state as we did not specify URL variable, see `.robot` file for details. In addition, after the first execution Jenkins should have updated the project configuration to contain parameters defined in the pipeline and we can now pass target URL to our automation tasks in Build with Parameters menu.
17+
After you have created the pipeline, try to execute it by clicking _Build Now_. All Robot Framework tasks should be in Skipped state as we did not specify URL variable, see `.robot` file for details. In addition, after the first execution Jenkins should have updated the project configuration to contain parameters defined in the pipeline and we can now pass target URL to our automation tasks in Build with Parameters menu.
1818

1919
Finally, If the robot log cannot be loaded after task execution, see [this stackoverflow post](https://stackoverflow.com/questions/36607394/error-opening-robot-framework-log-failed) for solution. To summarize, run following command in Jenkins Script Console to modify Jenkins servers Content Security Policy (CSP):
2020

0 commit comments

Comments
 (0)