Extract data-bits from your Jenkins jobs

Another quicky.

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

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:

$ 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/>