How to write message to Mattermost using Fastlane? - fastlane

How do I write a message to Mattermost using Fastlane ?
Below is my trial. I got most from this link.
What is still wrong ?
(of course, I replaced the MATTERMOST_WEBHOOK_URL by the actual value that I established in Mattermost).
In the link above, I saw an actions folder with a mattermost.rb file
How do I get this action to work ? What do I need to do inside my Fastfile or anywhere in order to get this to work ?
In fact, running the fastlane send_message lane, I get a success. But unfortunately, nothing is visible in my Mattermost channel.
Inside my Fastfile, I do:
def send_message_to_mattermost(options)
unless ENV['MATTERMOST_WEBHOOK_URL'].nil? || ENV['MATTERMOST_WEBHOOK_URL'].empty?
mattermost(
pretext: options[:pretext],
message: options[:msg],
default_payloads: options[:default_payloads],
username: 'Fastlane',
icon_url: 'https://s3-eu-west-1.amazonaws.com/fastlane.tools/fastlane.png',
payload: {},
attachment_properties: {
title: options[:title],
thumb_url: options[:thumb_url],
fields: [{
title: 'Version',
value: options[:version_number],
short: true
},
{
title: 'Build Number',
value: options[:build_number],
short: true
},
{
title: 'Built by',
value: 'Jenkins',
short: true
}]
},
success: options[:success]
)
end
end
And my Fastlane lane looks like this:
lane :send_message do
send_message_to_mattermost({
:version_number => ENV['VERSION_NUMBER'],
:build_number => ENV["BUILD_NUMBER"],
:pretext => ENV['MAIN_APP_IDENTIFIER'],
:title => 'Unsuccessful Build',
:thumb_url => 'https://support.apple.com/library/content/dam/edam/applecare/images/en_US/iOS/move-to-ios-icon.png',
:msg => "My message...",
:default_payloads => [:lane],
:success => true
})
end
Is mattermost(...) a standard command in Fastlane ? If not what do I need to do in order to send information to a Mattermost channel from Fastlane ?

I finally found a solution.
What was missing is to set the ENV["MATTERMOST_WEBHOOK_URL"] upfront
before_all do
ENV["MATTERMOST_WEBHOOK_URL"] = 'https://my_new_webooh_from_mattermost'
end
...and leave the following code intact (i.e. do not replace 'MATTERMOST_WEBHOOK_URL' by anything else - the before_all does the trick...)
def send_message_to_mattermost(options)
unless ENV['MATTERMOST_WEBHOOK_URL'].nil? || ENV['MATTERMOST_WEBHOOK_URL'].empty?
mattermost(
pretext: options[:pretext],
message: options[:msg],
default_payloads: options[:default_payloads],
username: 'Fastlane',
icon_url: 'https://s3-eu-west-1.amazonaws.com/fastlane.tools/fastlane.png',
payload: {},
attachment_properties: {
title: options[:title],
thumb_url: options[:thumb_url],
fields: [{
title: 'Version',
value: options[:version_number],
short: true
},
{
title: 'Build Number',
value: options[:build_number],
short: true
},
{
title: 'Built by',
value: 'Jenkins',
short: true
}]
},
success: options[:success]
)
end
end

Related

Custom buttons in tinyMCE 6.x to insert custom html

I have what I want working in tinyMCE v4.x, but am really styruggling to update the code to work with the latest version (6.x) of this editor.
Basically, my custom button opens a new (popup) window (passing various arguments) in which the user can do various things which produces some HTML, and this is then pasted back into the tinyMCE editor window (at the current insertion point) via editor.insertContent([whatever]);
Here's my v4 code to add the button to the editor toolbar:
editor.addButton('myButton', {
text: 'XYZ',
tooltip: 'Do something',
icon: false,
onclick: function () {
editor.windowManager.open({
title: 'XYZ',
url: 'mypopuppage.html',
width: 800,
height: 600
}, {
arg0: '0',
arg1: '1',
arg2: editor.selection.getContent({ format: 'html' }),
arg3: '',
arg4: ''
});
}
});
});
As I say, this is fine - it works. For v6 I've tried, but can't get it to work. I have not managed to find any code examples online that do anything similar for tinyMCE v6.x, though I'm sure there must be some... this is my effort, but clearly requires more, as it doesn;t work - the button shows, but nothing happens when I click it:
selector: "textarea#txtA",
menubar: false,
statusbar: false,
plugins: "myButton",
setup: (editor) => {
editor.ui.registry.addButton('myButton', {
text: 'XYZ',
onAction: (_) => {
editor.windowManager.open({
title: 'XYZ',
url: 'mypopuppage.html',
width: 800,
height: 600
}, {
arg0: '0',
arg1: '1',
arg2: editor.selection.getContent({ format: 'html' }),
arg3: '',
arg4: ''
});
}
});
},
toolbar1: "myButton"
});
Any help gratefully received...
[edit] OK - getting there; silly me: I should use
editor.windowManager.openUrl({
to open the dialog... now I just have to figure out how to send the HTML back to the editor...
..not sure I'm passing my arguments corectly for this version of tinyMCE... or not reading them correctly on the popup page. In v4x I could use
var args = top.tinymce.activeEditor.windowManager.getParams();
but this doesn't seem to work with v6x... I can use a workaorund of passing the arguments as parameters in the URL I call, but I suspect there is a more robust way of doing it as per v4x - damned if I can find it though... that asied, I'm just about there now :)

Fastlane: how to pass lane_context to another lane

I use Jenkins pipeline to build app. In pipeline I invoke fastlane lanes two times, between them I invoke integration tests.
This is the script for iOS
default_platform(:ios)
before_all do |lane, options|
IPA_NAME = options[:ipa_name];
ENV["SLACK_URL"] = "slack_url";
ENV["DELIVER_ITMSTRANSPORTER_ADDITIONAL_UPLOAD_PARAMETERS"] = "-t DAV"
end
platform :ios do
lane :build_to_browserstack do |lane, options|
begin
build_app()
push_to_browserstack()
rescue => exception
error_do_all_operations(exception)
end
end
end
platform :ios do
lane :push_to_testflight do |lane, options|
begin
push_to_testflight_and_s3()
passed_do_all_operations()
rescue => exception
error_do_all_operations(exception)
end
end
end
def build_app
clean_build_artifacts
cert
sigh(
skip_install: true,
provisioning_name: 'name'
)
increment_version_number(
version_number: "1.22.3"
)
increment_build_number({
build_number: latest_testflight_build_number + 1
})
get_version_number(
target: ENV["SCHEME"]
)
get_build_number
gym(
scheme: ENV["SCHEME"],
export_options: {
provisioningProfiles: {
"com.com.com" => "profile"
}
},
output_name: IPA_NAME
)
end
def push_to_browserstack
upload_to_browserstack_app_automate(
browserstack_username: "name",
browserstack_access_key: "key",
file_path: ENV["PATH_TO_IPA"] + IPA_NAME,
custom_id: IPA_NAME
)
end
def push_to_testflight_and_s3
upload_to_testflight(
ipa: ENV["PATH_TO_IPA"] + IPA_NAME,
skip_submission: true,
skip_waiting_for_build_processing: true,
team_name: 'team'
)
aws_s3(
access_key: 'key',
secret_access_key: 'key',
bucket: 'bucket',
region: 'us-east-2',
ipa: ENV["PATH_TO_IPA"] + IPA_NAME,
path: 'path'
)
end
def passed_do_all_operations
slack(
message: "New iOS build was uploaded to TestFlight",
success: true,
channel: "#engineering_general",
slack_url: ENV["SLACK_URL"],
default_payloads: [:git_branch],
payload: {"Build Date" => Time.new.to_s,},
attachment_properties: {
fields: [
{
title: "Version number",
value: lane_context[SharedValues::VERSION_NUMBER],
},
{
title: "Build number",
value: lane_context[SharedValues::BUILD_NUMBER],
}
]
}
)
end
def error_do_all_operations(exception)
slack(
message: "iOS build was not uploaded to TestFlight",
success: false,
channel: "#engineering_general",
slack_url: ENV["SLACK_URL"],
default_payloads: [:git_branch],
payload: {"Build Date" => Time.new.to_s,},
attachment_properties: {
fields: [
{
title: "Version number",
value: lane_context[SharedValues::VERSION_NUMBER],
},
{
title: "Build number",
value: lane_context[SharedValues::BUILD_NUMBER],
},
{
title: "Error message",
value: exception.to_s,
short: false
}
]
}
)
end
I use parameterized invocation of fastlane, peace of code:
before_all do |lane, options|
IPA_NAME = options[:ipa_name];
At first I invoke the lane build_to_browserstack. Now it has error due to my browserstack accout, and error_do_all_operations() function produces slack notification correctly, with values of lane_context[SharedValues::VERSION_NUMBER], and lane_context[SharedValues::BUILD_NUMBER],
At second I invoke the lane push_to_testflight and here is a problem. Function passed_do_all_operations() produces slack notifications without lane_context values.
So the question is how to pass lane_context from first invocation to second invocation ?

Building a List in actions-on-google Nodejs v2

I may be missing something really obvious, but I haven't figured out how I can build a List programatically in v2 of tne actions-on-google Nodejs client library.
In other words, I want to do something like the conv.ask code below, but don't know the items beforehand, so need to create a list, add the items to the list, and then ask the list in dynamic way. I could do this in v1 with:
var rList = app.buildList("Please select one option:");
for (var r =0; r < resp_text.length; r++) {
rList.addItems(app.buildOptionItem(resp_value[r], resp_matches[r]).setTitle(resp_text[r]));
}
app.askWithList(question_str, rList);
... so am basically looking for the v2 equivalent of the above.
Any help appreciated, thanks!
conv.ask(new List({
title: 'Things to learn about',
items: {
// Add the first item to the list
'MATH_AND_PRIME': {
synonyms: [
'math',
'math and prime',
'prime numbers',
'prime',
],
title: 'Title of the First List Item',
description: '42 is an abundant number',
image: new Image({
url: 'https://example.com/math_and_prime.jpg',
alt: 'Math & prime numbers',
}),
},
// Add the second item to the list
'EGYPT': {
synonyms: [
'religion',
'egypt',
'ancient egyptian',
],
title: 'Ancient Egyptian religion',
description: '42 gods ruled on the fate of the dead in the afterworld',
image: new Image({
url: 'http://example.com/egypt',
alt: 'Egypt',
}),
},
// Add the last item to the list
'RECIPES': {
synonyms: [
'recipes',
'recipe',
'42 recipes',
],
title: '42 recipes in 42 ingredients',
description: 'A beautifully simple recipe',
image: new Image({
url: 'http://example.com/recipe',
alt: 'Recipe',
}),
},
},
}));
Ok, answering my own question just in case it will help someone else...
The way (or at least one way) to do this is to dynamicaly create an item array and using that in the list constructor:
var ritems = {}
for (var r=0; r < resp_text.length; r++) {
ritems[resp_value[r]] = {
synonyms: [resp_matches[r]],
title: resp_text[r]
}
}
conv.ask(question_str);
conv.ask(new List({
title: "Please select one option:",
items: ritems
}))

Fill PDF form using perl or node

I need to fill PDF form, Which contains radio buttons too. I tried to fill it with perl, CAM::PDF module and with node, pdf-fill-form module.
In node, the radio's value is always undefined:
{
name: 'Op1',
page: 14,
value: undefined,
id: 983128,
type: 'radio'
}
In perl, the object's value looks like this (if the first option is checked is S, second: XL, third: 2XL etc):
'V'=> bless({
'gennum'=>0,
'value'=>'S',
'type'=>'label',
'objnum'=>988
},
'CAM: : PDF: : Node')
If I change the S to XL, nothing happens in the PDF.
Has somebody any idea, How to fill the radio box?
You can do with node js npm pdf-fill-form module.
let say you are trying to set gender:
your radio button must be formed this way.
{ name: 'gender',
page: 0,
value: false,
id: 65558,
caption: 'male',
type: 'radio' },
{ name: 'gender',
page: 0,
value: false,
id: 65559,
caption: 'female',
type: 'radio' }
Here caption is the important one.
if you trying to set gender is male means just do this
{ gender: 'male'}

Simple login form with SenchaTouch

Just diving into SenchaTouch which seems very promising.
I'm building my first application, a simple login form check source http://pastebin.com/8Zddr9cj
I'm looking for a way to do the following things :
Display 'nice' error message when the login/password is wrong. Can be in red to replace the 'Please enter your credentials); i don't know how to access this property.
If login success, close the form and load the application (probably another js file).
Quite simple, but i'm a newbie to this,
1) Fieldset has a method called setInstructions which you can call to update the instructions. So, you could specify an id configuration in your field set, then use that later on when you want to update the instructions.
...
items: [
{
xtype: 'fieldset',
id: 'fieldset',
title: 'Login',
instructions: 'Please enter your credentials',
defaults: {
required: true,
labelAlign: 'left',
labelWidth: '40%'
},
items: [
{
xtype: 'emailfield',
name : 'email',
label: 'Email',
placeHolder: 'your#email.com',
useClearIcon: true
}, {
xtype: 'passwordfield',
name : 'password',
label: 'Password',
useClearIcon: false
}]
}
],
...
//wherever you want to update the instructions
var fieldset = Ext.getCmp('fieldset');
fieldset.setInstructions('My new instructions!');
2) Here is a simple demo of this:
//create a panel, which is full screen, and will contain your form, and another item
//which you want to show at some point
var wrapper = new Ext.Panel({
fullscreen: true,
layout: 'card',
//my two items
items: [
form,
{
xtype: 'panel',
html: 'my second panel, which is not visible on render.'
}
]
});
//change the active card/item, when you need to
wrapper.setActiveItem(1); //starts at 0
Make sure you remove fullscreen from your form, as it is no longer fullscreen (this wrapper panel is).