Extract data-bits from your Jenkins jobs

Another quicky.

I read here that cool trick to convert HTML entities to plain text:

1
alias htmldecode="perl -MHTML::Entities -pe 'decode_entities(\$_)'"

In a Debian based system, this suppose to apt-get install libhtml-parser-perl.
Why bother you may ask? Well because the (awful) Jenkins-cli outputs text areas content in encoded HTML entities, and for example I like the idea of being able to test a standalone packer template that’s failing.

Finally, here’s the full usecase:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
$ java -jar jenkins-cli.jar -s http://127.0.0.1:8080/ get-job "packertest" --username foo --password bar | htmldecode

<?xml version='1.0' encoding='UTF-8'?>
<project>
<actions/>
<description></description>
<keepDependencies>false</keepDependencies>
<properties/>
<scm class="hudson.scm.NullSCM"/>
<canRoam>true</canRoam>
<disabled>false</disabled>
<blockBuildWhenDownstreamBuilding>false</blockBuildWhenDownstreamBuilding>
<blockBuildWhenUpstreamBuilding>false</blockBuildWhenUpstreamBuilding>
<triggers/>
<concurrentBuild>false</concurrentBuild>
<builders/>
<publishers>
<biz.neustar.jenkins.plugins.packer.PackerPublisher plugin="packer@1.4">
<name>Default</name>
<jsonTemplate></jsonTemplate>
<jsonTemplateText>{
"variables": {
"aws_access_key": "",
"aws_secret_key": ""
},
"builders": [{
"type": "amazon-ebs",
"access_key": "{{user `aws_access_key`}}",
"secret_key": "{{user `aws_secret_key`}}",
"region": "eu-central-1",
"source_ami": "ami-02724d1f",
"instance_type": "t2.micro",
"ssh_username": "admin",
"ami_name": "jenkins-packer (RED) {{timestamp}}",
"vpc_id": "vpc-00000000",
"subnet_id": "subnet-00000000",
"security_group_id": "sg-00000000",
"associate_public_ip_address": true
}],
"provisioners": [{
"type": "shell",
"inline": [
"echo 'Acquire::ForceIPv4 \"true\";' | sudo tee /etc/apt/apt.conf.d/99force-ipv4",
"echo 'deb http://cloudfront.debian.net/debian jessie-backports main' |sudo tee /etc/apt/sources.list.d/backports.list",
"sudo apt-get update",
"sudo apt-get -t jessie-backports install -y ansible"
]
}, {
"type": "ansible-local",
"playbook_file": "{{ user `test_yml` }}",
"command": "PYTHONUNBUFFERED=1 ansible-playbook"
}]
}</jsonTemplateText>
<params>-color=false</params>
<useDebug>false</useDebug>
<changeDir></changeDir>
<templateMode>text</templateMode>
<fileEntries>
<biz.neustar.jenkins.plugins.packer.PackerFileEntry>
<varFileName>test_yml</varFileName>
<contents>---

- hosts: all

tasks:
- name: install stuff
apt: name=vim state=installed
become: true</contents>
</biz.neustar.jenkins.plugins.packer.PackerFileEntry>
</fileEntries>
</biz.neustar.jenkins.plugins.packer.PackerPublisher>
</publishers>
<buildWrappers/>