how to increase the size of jenkins pipeline input area? - jenkins-pipeline

In Jenkins pipe line script : input syntax is,
def newTag = input(
id: 'currentTag', message: 'Put the tag for vals here', ok: 'CREATE TAG',
parameters: [
string(
defaultValue: 'temp',
description: 'Enter carefully for new tag',
name: 'tagName'
),
]
)
While run this, it waits for input with applet.
In doc link there is no method to specify the size.
How to increase the size of that input bar ?

You can use text() instead of string(). The input window can be resized.

I don't think you can set the size of it, but if you load the 'input' form from the log output or from BlueOcean view, it will look much better for you

Related

Get all keys of Json as list directly from Git Repo

For my Jenkins pipeline I want to populate all the keys in Json which is in GitRepo as Extended Choice parameters.
[$class: 'ChoiceParameter', choiceType: 'PT_SINGLE_SELECT', description: 'Select an option', name: 'Option', randomName: 'choice-parameter-112', script: [$class: 'GroovyScript', fallbackScript: [classpath: [], sandbox: false, script: ''], script: [classpath: [], sandbox: false,
script: '''
//What should I write here in this block?
return keys
''']]]
Basically all I need is a curl call that I can make from the above block to get single file from Git using the Git Credential ID(I've stored my user name and password as credential id in Git)
This is a frequent case which boils down to this:
You can't issue a call to sh unless you have a node. To have a node, you need to run a pipeline. To run a pipeline, you need to figure out the parameters. To figure out this parameter, you need to issue a call to sh. See the problem?
To overcome the problem, you can cheat the system by running another (small) pipeline before the main one, e.g.
node('master') {
stage('read file') {
def file_contents = sh (returnStdout: true, script: "curl myrepo/myfile.json")
def parsed_data = readJSON text: file_contents
}
}
and then
properties([
parameters([
[$class: 'ChoiceParameter',
etc.

jekyll blog new line (minimal-mistake)

jekyll blog(minimal-mistakes thema) has a space to introduce myself.
I want to write on two lines in this space.
For example
hello
world
I know that to edit this page, i need to touch the _config.yml file.
# Site Author
author:
name : "Choi Young-jin"
avatar : "/assets/images/images/avatar.png"
bio : "**^^**" <-----------Parts to change
42 intra ID: yochoi
location : "Seoul"
email : "amateur.toss#gmail.com"
links:
- label: "Email"
icon: "fas fa-fw fa-envelope-square"
# url: "amateur.toss#gmail.com"
- label: "GitHub"
icon: "fab fa-fw fa-github"
url: "https://github.com/amateurtoss"
The escape character does not work.
bio: "hello\nworld"
What if I want to show the string in two lines?
Well it's markdown, so you should do
bio: |-
hello
world
(That's a YAML block scalar, which is interpreted literally and ends with the next item on the same or lesser indentation level as bio)
You can of course also do
bio: "hello\n\nworld"
But it's less obvious what happens here.
You can use HTML in the bio string, so you can simply use a HTML linebreak:
bio: "hello<br>world"
The above is the only way in which I managed to have a single line break. All other options lead to either no line break or an empty line between the two lines.

File.new command for Ruby to upload mp3 file to soundcloud

I'm now trying to upload a mp3 file to Soundcloud. Here I'm bogged down to the use of File.new command in Ruby.
I send a request and a passing parameter looks like the below.
Parameters: {..."mp3_1"=>#<ActionDispatch::Http::UploadedFile:0x007ff24d5e3ea8 #tempfile=#<Tempfile:/var/folders/kk/y_wprlln2qv6mzylj03g14x00000gn/T/RackMultipart20160316-21426-14vu8x1.mp3>, #original_filename="datasecurity.mp3", #content_type="audio/mp3", #headers="Content-Disposition: form-data; name=\"mp3_1\"; filename=\"datasecurity.mp3\"\r\nContent-Type: audio/mp3\r\n">}
Then, I write File.new command with the potentail file name and params[:mp3_1] like the below.
client = Soundcloud.new(:access_token => 'XXX')
track = client.post('/tracks', :track => {
:title => 'This is my sound',
:asset_data => File.new("file name",params[:mp3_1])
})
Now I get an error saying:
no implicit conversion of ActionDispatch::Http::UploadedFile into String
The paperclip function works ( storing file to the storage directly has been what I've done ) but this file.new doesn't allow me to move forward. If I can get any help, I really appreciate that (:
Best
you already have a file, no need to create a new one with File.new
have a closer look to your dump :
#tempfile=#<Tempfile:/var/folders/...../RackMultipart20160316-21426-14vu8x1.mp3
this is a file, you may use it directly in your call
client.post('/tracks', :track => {
:title => 'This is my sound',
:asset_data => params[:mp3_1].tempfile)
})

Create a file descriptor in ruby

I am writing a script will perform various tasks with DSV or positional files. These tasks varies and are like creating an DB table for the file, or creating a shell script for parsing it.
As I have idealized my script would receive a "descriptor" as input to perform its tasks. It then would parse this descriptor and perform its tasks accordingly.
I came up with some ideas on how to specify the descriptor file, but didn't really manage to get something robust - probably due my inexperience in ruby.
It seems though, the best way to parse the descriptor would be using ruby language itself and then somehow catch parsing exceptions to turn into something more relevant to the context.
Example:
The file I will be reading looks like (myfile.dsv):
jhon,12343535,27/04/1984
dave,53245265,30/03/1977
...
Descriptor file myfile.des contains:
FILE_TYPE = "DSV"
DSV_SEPARATOR = ","
FIELDS = [
name => [:pos => 0, :type => "string"],
phone => [:pos => 1, :type => "number"],
birthdate => [:pos => 2, :type => "date", :mask = "dd/mm/yyyy"]
]
And the usage should be:
ruby script.rb myfile.des --task GenerateTable
So the program script.rb should load and parse the descriptor myfile.des and perform whatever tasks accordingly.
Any ideas on how to perform this?
Use YAML
Instead of rolling your own, use YAML from the standard library.
Sample YAML File
Name your file something like descriptor.yml, and fill it with:
---
:file_type: DSV
:dsv_separator: ","
:fields:
:name:
:pos: 0
:type: string
:phone:
:pos: 1
:type: number
:birthdate:
:pos: 2
:type: date
:mask: dd/mm/yyyy
Loading YAML
You can read your configuration back in with:
require 'yaml'
settings = YAML.load_file 'descriptor.yml'
This will return a settings Hash like:
{:file_type=>"DSV",
:dsv_separator=>",",
:fields=>
{:name=>{:pos=>0, :type=>"string"},
:phone=>{:pos=>1, :type=>"number"},
:birthdate=>{:pos=>2, :type=>"date", :mask=>"dd/mm/yyyy"}}}
which you can then access as needed to configure your application.

Getting "No frame found" when using in_frame

For some reason when I use the code below, my script returns "No frame found", but when I use watir-webdriver's browser.frame(:xpath => '//[#id="Main"]').img(:xpath => '//[#id="STSearchImage2"]') it works just fine.
Snippet of in_frame code:
# Main frame
in_frame(:id => 'Main') do |main_frame|
...
# # Scheduled Tasks image
image(:searchandfilter_clients_image, :xpath => '//*[#id="STSearchImg2"]', :frame => main_frame)
...
end
Snippet of code used in step:
searchandfilter_clients_image_element.click
The line above returns the error.
The frame I'm trying to select is within a frameset near the root of the body of the page. I don't have any issues selecting the frame without page-object.
Let me know if more information is needed.
Thank you for your help.

Resources