Skip to content

Commit 5feb3cf

Browse files
committed
Deploying to gh-pages from @ baf195e 🚀
1 parent 225428e commit 5feb3cf

7 files changed

Lines changed: 28 additions & 28 deletions

File tree

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
}

examples/jenkins/ansible-kubernetes/index.html

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -679,7 +679,7 @@ <h2 id="preparing-the-jenkins-instance">Preparing the Jenkins instance</h2>
679679
</ol>
680680
<h2 id="configure-the-pipeline">Configure the pipeline</h2>
681681
<p>First, create a new pipeline via <a href="http://localhost:8080/view/all/newJob">New Item</a> button in the rigth side menu of the Jenkins dashboard. The name of the pipeline could be for example <code>Animals</code> and it should be an pipeline.</p>
682-
<p>In the configure pipeline view, scroll to the bottom and under Pipeline sub-header select <code>Pipeline script from SCM</code>. SCM type should be <code>Git</code> and Repository URL the url of this repository: <code>https://github.com/kangasta/jenkins-examples.git</code>. Ensure that branch specifier includes <code>main</code> branch of the repository and modify the Script Path to be <code>ansible-kubernetes\Jenkinsfile</code>.</p>
682+
<p>In the configure pipeline view, scroll to the bottom and under Pipeline sub-header select <code>Pipeline script from SCM</code>. SCM type should be <code>Git</code> and Repository URL the url of this repository: <code>https://github.com/kangasta/cicd-examples.git</code>. Ensure that branch specifier includes <code>main</code> branch of the repository and modify the Script Path to be <code>docs/examples/jenkins/ansible-kubernetes/Jenkinsfile</code>.</p>
683683
<p>After you have created the pipeline, try to execute it by clicking <em>Build Now</em>. The pipeline should have deployed the example application into the Kubernetes cluster with the default image tag (<code>cow</code>) defined in the <a href="deploy-to-kubernetes.yml">deploy-to-kubernetes.yml</a> Ansible playbook.</p>
684684
<p>You can find the URL of the created load-balancer from the console output of the build. Open the application with your browser or user curl to see the application response.</p>
685685
<p>In addition, after the first execution Jenkins should have updated the project configuration to contain parameters defined in the pipeline and we can configure the image tag in <em>Build with Parameters</em> menu.</p>
@@ -705,7 +705,7 @@ <h2 id="configure-the-pipeline">Configure the pipeline</h2>
705705
<span class="md-icon" title="Last update">
706706
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"><path d="M21 13.1c-.1 0-.3.1-.4.2l-1 1 2.1 2.1 1-1c.2-.2.2-.6 0-.8l-1.3-1.3c-.1-.1-.2-.2-.4-.2m-1.9 1.8-6.1 6V23h2.1l6.1-6.1zM12.5 7v5.2l4 2.4-1 1L11 13V7zM11 21.9c-5.1-.5-9-4.8-9-9.9C2 6.5 6.5 2 12 2c5.3 0 9.6 4.1 10 9.3-.3-.1-.6-.2-1-.2s-.7.1-1 .2C19.6 7.2 16.2 4 12 4c-4.4 0-8 3.6-8 8 0 4.1 3.1 7.5 7.1 7.9l-.1.2z"/></svg>
707707
</span>
708-
<span class="git-revision-date-localized-plugin git-revision-date-localized-plugin-date">October 11, 2024</span>
708+
<span class="git-revision-date-localized-plugin git-revision-date-localized-plugin-date">October 12, 2024</span>
709709
</span>
710710

711711

examples/jenkins/build-status-pipelines/index.html

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -653,11 +653,11 @@ <h2 id="preparing-the-jenkins-instance">Preparing the Jenkins instance</h2>
653653
<h2 id="creating-and-running-the-seed-project">Creating and running the seed project</h2>
654654
<p>To run the job DSL script, create a new pipeline with following script as an inline pipeline script and run the created pipeline.</p>
655655
<div class="language-groovy highlight"><pre><span></span><code><span id="__span-0-1"><a id="__codelineno-0-1" name="__codelineno-0-1" href="#__codelineno-0-1"></a><span class="n">node</span><span class="w"> </span><span class="o">{</span>
656-
</span><span id="__span-0-2"><a id="__codelineno-0-2" name="__codelineno-0-2" href="#__codelineno-0-2"></a><span class="w"> </span><span class="n">git</span><span class="w"> </span><span class="nl">branch:</span><span class="w"> </span><span class="s1">&#39;main&#39;</span><span class="o">,</span><span class="w"> </span><span class="nl">url:</span><span class="w"> </span><span class="s1">&#39;https://github.com/kangasta/jenkins-examples.git&#39;</span>
657-
</span><span id="__span-0-3"><a id="__codelineno-0-3" name="__codelineno-0-3" href="#__codelineno-0-3"></a><span class="w"> </span><span class="n">jobDsl</span><span class="w"> </span><span class="nl">targets:</span><span class="w"> </span><span class="s1">&#39;build-status-pipelines/jobs.groovy&#39;</span>
656+
</span><span id="__span-0-2"><a id="__codelineno-0-2" name="__codelineno-0-2" href="#__codelineno-0-2"></a><span class="w"> </span><span class="n">git</span><span class="w"> </span><span class="nl">branch:</span><span class="w"> </span><span class="s1">&#39;main&#39;</span><span class="o">,</span><span class="w"> </span><span class="nl">url:</span><span class="w"> </span><span class="s1">&#39;https://github.com/kangasta/cicd-examples.git&#39;</span>
657+
</span><span id="__span-0-3"><a id="__codelineno-0-3" name="__codelineno-0-3" href="#__codelineno-0-3"></a><span class="w"> </span><span class="n">jobDsl</span><span class="w"> </span><span class="nl">targets:</span><span class="w"> </span><span class="s1">&#39;docs/examples/jenkins/build-status-pipelines/jobs.groovy&#39;</span>
658658
</span><span id="__span-0-4"><a id="__codelineno-0-4" name="__codelineno-0-4" href="#__codelineno-0-4"></a><span class="o">}</span>
659659
</span></code></pre></div>
660-
<p>The execution will likely fail with <code>ERROR: script not yet approved for use</code> message. To enable this script, navigate to <a href="http://localhost:8080/scriptApproval/">Manage Jenkins &gt; In-process Script Approval</a>, inspect the script, and click Approve. Then try to run the created seed project again. It should now succeed and list the created resources.</p>
660+
<p>The execution will likely fail with <code>ERROR: script not yet approved for use</code> message. To enable this script, navigate to <a href="http://localhost:8080/scriptApproval/">Manage Jenkins &gt; In-process Script Approval</a>, inspect the script, and click <em>Approve</em>. Then try to run the created seed project again. It should now succeed and list the created resources.</p>
661661

662662

663663

@@ -680,7 +680,7 @@ <h2 id="creating-and-running-the-seed-project">Creating and running the seed pro
680680
<span class="md-icon" title="Last update">
681681
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"><path d="M21 13.1c-.1 0-.3.1-.4.2l-1 1 2.1 2.1 1-1c.2-.2.2-.6 0-.8l-1.3-1.3c-.1-.1-.2-.2-.4-.2m-1.9 1.8-6.1 6V23h2.1l6.1-6.1zM12.5 7v5.2l4 2.4-1 1L11 13V7zM11 21.9c-5.1-.5-9-4.8-9-9.9C2 6.5 6.5 2 12 2c5.3 0 9.6 4.1 10 9.3-.3-.1-.6-.2-1-.2s-.7.1-1 .2C19.6 7.2 16.2 4 12 4c-4.4 0-8 3.6-8 8 0 4.1 3.1 7.5 7.1 7.9l-.1.2z"/></svg>
682682
</span>
683-
<span class="git-revision-date-localized-plugin git-revision-date-localized-plugin-date">October 11, 2024</span>
683+
<span class="git-revision-date-localized-plugin git-revision-date-localized-plugin-date">October 12, 2024</span>
684684
</span>
685685

686686

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
}

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
}

examples/jenkins/parallel-robot-pipeline/index.html

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -669,9 +669,9 @@ <h2 id="preparing-the-jenkins-instance">Preparing the Jenkins instance</h2>
669669
<p>The pipeline provided by this example can be added to any Jenkins instance you have administrator access and can run pipeline stages with docker agent. For example, Jenkins configuration from <a href="../dind-jenkins/">Docker-in-Docker</a> example can be used.</p>
670670
<p>In order to be able to run the pipeline we will need <a href="https://plugins.jenkins.io/docker-workflow/">Docker Pipeline</a> and <a href="https://plugins.jenkins.io/robot/">Robot Framework</a> plugins. Install these plugins through <em>Available</em> tab in <a href="http://localhost:8080/pluginManager/available">Manage Jenkins &gt; Manage Plugins</a> and restart the Jenkins instance after these plugins have been installed. The restart can be done, for example, from the plugins page or by restarting the container with <code>docker compose down</code> and <code>docker compose up</code>.</p>
671671
<h2 id="configure-the-pipeline">Configure the pipeline</h2>
672-
<p>First, create a new pipeline via <a href="http://localhost:8080/view/all/newJob">New Item</a> button in the rigth side menu of the Jenkins dashboard. The name of the pipeline could be for example <code>Screenshots</code> and it should be an pipeline.</p>
673-
<p>In the configure pipeline view, scroll to the bottom and under Pipeline sub-header select <code>Pipeline script from SCM</code>. SCM type should be <code>Git</code> and Repository URL the url of this repository: <code>https://github.com/kangasta/jenkins-examples.git</code>. Ensure that branch specifier includes <code>main</code> branch of the repository and modify the Script Path to be <code>parallel-robot-pipeline/Jenkinsfile</code>.</p>
674-
<p>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 <code>.robot</code> 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.</p>
672+
<p>First, create a new pipeline via <em><a href="http://localhost:8080/view/all/newJob">New Item</a></em> button in the rigth side menu of the Jenkins dashboard. The name of the pipeline could be for example <code>Screenshots</code> and it should be an pipeline.</p>
673+
<p>In the configure pipeline view, scroll to the bottom and under Pipeline sub-header select <code>Pipeline script from SCM</code>. SCM type should be <code>Git</code> and Repository URL the url of this repository: <code>https://github.com/kangasta/cicd-examples.git</code>. Ensure that branch specifier includes <code>main</code> branch of the repository and modify the Script Path to be <code>docs/examples/jenkins/parallel-robot-pipeline/Jenkinsfile</code>.</p>
674+
<p>After you have created the pipeline, try to execute it by clicking <em>Build Now</em>. All Robot Framework tasks should be in Skipped state as we did not specify URL variable, see <code>.robot</code> 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.</p>
675675
<p>Finally, If the robot log cannot be loaded after task execution, see <a href="https://stackoverflow.com/questions/36607394/error-opening-robot-framework-log-failed">this stackoverflow post</a> for solution. To summarize, run following command in Jenkins Script Console to modify Jenkins servers Content Security Policy (CSP):</p>
676676
<div class="language-groovy highlight"><pre><span></span><code><span id="__span-0-1"><a id="__codelineno-0-1" name="__codelineno-0-1" href="#__codelineno-0-1"></a><span class="n">System</span><span class="o">.</span><span class="na">setProperty</span><span class="o">(</span><span class="s2">&quot;hudson.model.DirectoryBrowserSupport.CSP&quot;</span><span class="o">,</span><span class="s2">&quot;sandbox allow-scripts; default-src &#39;none&#39;; img-src &#39;self&#39; data: ; style-src &#39;self&#39; &#39;unsafe-inline&#39; data: ; script-src &#39;self&#39; &#39;unsafe-inline&#39; &#39;unsafe-eval&#39; ;&quot;</span><span class="o">)</span>
677677
</span></code></pre></div>

search/search_index.json

Lines changed: 1 addition & 1 deletion
Large diffs are not rendered by default.

0 commit comments

Comments
 (0)