This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
pipeline { | |
agent any | |
stages { | |
stage('Build') { | |
steps { | |
echo 'Building...' | |
} | |
} | |
stage('Test') { | |
steps { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def execute(step, services) { | |
stage(step.name) { | |
if (step.shared) { | |
runSharedStep(step.command) | |
} else { | |
parallel services.collectEntries {service -> [service, {runServiceStep(service, step.command)}]} | |
} | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[ | |
[ | |
name : 'Build', | |
command : 'make build', | |
shared : false, | |
], | |
[ | |
name : 'Service Test', | |
command : 'make service-test', | |
shared : false, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def runAllLocations = ['common/', 'Jenkinsfile'] | |
def shouldRunAll(changedFiles) { | |
def hasChangesInCommon = changedFiles.any { file -> runAllLocations.any { file.matches("$it.*") } } | |
def hasChangesInRoot = changedFiles.any { !it.contains('/') } | |
hasChangesInCommon || hasChangesInRoot || changedFiles.isEmpty() | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def changedServices(changedFiles) { | |
listServices().findAll { service -> changedFiles.any { it.contains("services/$service") } } | |
} | |
def listServices() { | |
sh(script: "ls -1 $WORKSPACE/services/", returnStdout: true) | |
.split() | |
.findAll {!it.endsWith('@tmp')} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def changedFilesSinceLastPass() { | |
def files = [] | |
def lastSuccessfulBuildNumber = currentBuild.previousSuccessfulBuild?.number | |
if (lastSuccessfulBuildNumber == null) { | |
return [] | |
} | |
def build = currentBuild | |
while (build.number > lastSuccessfulBuildNumber) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
props = load_props() | |
connect_to_wifi(props['wifi_sid'], props['wifi_pass']) | |
mqtt = MQTT(props['client_id'], props['iot_endpoint'], props['iot_topic']) | |
thermistor = Thermistor() | |
while True: | |
temp = thermistor.get_temp() | |
mqtt.send({'temp': temp}) | |
deep_sleep_seconds(props['sleep_seconds']) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import math | |
import machine | |
def _steinhart_temperature_C(Rt, Ro=10000.0, To=25.0, beta=3950.0): | |
steinhart = math.log(Rt / Ro) / beta | |
steinhart += 1.0 / (To + 273.15) | |
steinhart = (1.0 / steinhart) - 273.15 | |
return steinhart | |
def _get_thermistor_resistance(self, Rnom = 10000, adc_resolution=1023): |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from umqtt.simple import MQTTClient | |
import json | |
client_id = 'esp8266' | |
mqtt_topic = 'tempReading/bedroom' | |
mqtt_port = 8883 | |
mqtt_host = 'a2XXXXXXXX.iot.us-west-2.amazonaws.com' | |
private_key = open("/private_key.der").read() | |
certificate = open("/cert.der").read() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
rtc = machine.RTC() | |
rtc.irq(trigger=rtc.ALARM0, wake=machine.DEEPSLEEP) | |
rtc.alarm(rtc.ALARM0, seconds * 1000) | |
print('Entering deep sleep for %s seconds' % seconds) | |
machine.deepsleep() |