Kinook Software Forum

Go Back   Kinook Software Forum > Visual Build Professional > [VBP] General Discussion
FAQ Community Calendar Today's Posts Search

Reply
 
Thread Tools Rate Thread Display Modes
  #1  
Old 11-13-2014, 06:04 AM
raistlin raistlin is online now
Registered User
 
Join Date: 11-14-2008
Posts: 23
Unexpanded macro value

I am trying to unexpand the macro value. A macro with this value is parsed and i want to retain its value.

Code:
"BUILD_URL=http://jenkins/job/Test%20New%20NUnit%20Test%20Script/lastBuild"
To use the value above, i need to convert % to %% so VBP will not treat %20New% as an expandable macro, i think.

I tried to do it this way without avail.
Code:
Option Explicit

Dim build_url

build_url = "%BUILD_URL%"

If Len(build_url) > 0 Then

build_url = Replace( build_url, "%%", "%%%%" )
SetTemporaryMacroValue "BUILD_URL", build_url      <--- this is a subfunction i use in the script

End If
What can i do to use a macro with %20xxx%20 in it without expansion? Thanks.

What i need is the opposite of http://www.kinook.com/Forum/showthread.php?t=1233
Reply With Quote
  #2  
Old 11-13-2014, 07:23 AM
kinook kinook is online now
Administrator
 
Join Date: 03-06-2001
Location: Colorado
Posts: 6,034
What do you mean by 'a macro with this value is parsed'? How was the BUILD_URL macro initialized? Literal % characters in the macro value should be escaped when creating the macro. The vbld_EscapeString system script function can be used for this.
http://www.kinook.com/VisBuildPro/Ma...scriptmisc.htm

To assign a macro value to another macro value, just copy the raw value without expanding. See the attached sample.
Attached Files
File Type: bld spec_chars.bld (2.0 KB, 5051 views)
Reply With Quote
  #3  
Old 11-13-2014, 08:02 AM
raistlin raistlin is online now
Registered User
 
Join Date: 11-14-2008
Posts: 23
The value is parsed as an environment variable when initiated by a jenkins job.

See https://wiki.jenkins-ci.org/display/...nmentVariables

The job build command:
Code:
VisBuildcmd.exe "BUILD_URL=%BUILD_URL%" /mta /b NUnitTest.bld
When expanded to on the test machine, it becomes:
Code:
VisBuildcmd.exe "BUILD_URL=http://jenkins/job/Test%20New%20NUnit%20Test%20Script/lastBuild" /mta /b NUnitTest.bld
Some of the jobs name have spaces, so these spaces are escaped to become %20 in the BUILD_URL env var.
Code:
Eg: http://jenkins/job/TestNewNUnitTestScript/ - OK
Eg: http://jenkins/job/Test New NUnit Test Script/ - Still OK, but will be escaped to:
    http://jenkins/job/Test%20New%20NUnit%20Test%20Script/ - Not OK
I do not want to replace spaces with underscores in the job name. Hence the problem.
Reply With Quote
  #4  
Old 11-13-2014, 08:11 AM
raistlin raistlin is online now
Registered User
 
Join Date: 11-14-2008
Posts: 23
Thanks for the codes, however it still fails with these error:

Code:
Error in Run Script (VBScript) script code at Line 11, Column 1  (http://jenkins/job/Test<Undefined macro 20New>20NUnit<Undefined macro 20Test>20Script/lastBuild)
13-11-2014 14:07:27: Step '4 - use' failed
13-11-2014 14:07:27: Build ended (elapsed = 00:00:00).
You can create a macro with this value to reproduce this problem:
Code:
http://jenkins/job/Test%20New%20NUnit%20Test%20Script/lastBuild
My real challenge is trying to use the macro out of the script, here:
Name:  MacroApplication.png
Views: 8288
Size:  22.9 KB
Reply With Quote
  #5  
Old 11-13-2014, 08:16 AM
kinook kinook is online now
Administrator
 
Join Date: 03-06-2001
Location: Colorado
Posts: 6,034
Add a step at the beginning of the project to escape the BUILD_URL macro value that was passed in (see attached).
http://www.kinook.com/VisBuildPro/Ma...ecialchars.htm
Attached Files
File Type: bld spec_chars2.bld (1.9 KB, 5049 views)
Reply With Quote
  #6  
Old 11-13-2014, 08:27 AM
raistlin raistlin is online now
Registered User
 
Join Date: 11-14-2008
Posts: 23
Epic. Thanks alot for this!
Reply With Quote
  #7  
Old 02-07-2022, 07:24 PM
teognost teognost is online now
Registered User
 
Join Date: 05-25-2004
Location: Prague,Czech Republic
Posts: 200
Copy the escaped macro value to another project macro

Is there any way to copy the escaped macro value BUILD_URL to another project macro BUILD_URL3(not a temp macro)?
In the sample attached I tried to do it with a Set macro step but it did not work -the macro BUILD_URL3 has the unescaped value(The next step log macro fails)
Attached Files
File Type: bld spec_chars3.bld (2.9 KB, 4077 views)
Reply With Quote
  #8  
Old 02-07-2022, 11:53 PM
kinook kinook is online now
Administrator
 
Join Date: 03-06-2001
Location: Colorado
Posts: 6,034
In a Set Macro action, check the 'Don't expand macros and script' option.

https://kinook.com/VisBuildPro/Manua...acroaction.htm
Reply With Quote
  #9  
Old 02-08-2022, 04:41 AM
teognost teognost is online now
Registered User
 
Join Date: 05-25-2004
Location: Prague,Czech Republic
Posts: 200
Thanks!And if in the Value field there is the macro I do not want expanded and another macro which I want to have it expanded?
Reply With Quote
  #10  
Old 02-08-2022, 11:21 AM
kinook kinook is online now
Administrator
 
Join Date: 03-06-2001
Location: Colorado
Posts: 6,034
You can't expand partially. It's all or nothing. Escape (double) something that should not be evaluated as a macro.
Reply With Quote
  #11  
Old 02-08-2022, 03:17 PM
teognost teognost is online now
Registered User
 
Join Date: 05-25-2004
Location: Prague,Czech Republic
Posts: 200
Thanks.I found another way-I set in the Value field of Set Macro:
[vbld_EscapeString("%BUILD_URL%")]
Reply With Quote
Reply


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



All times are GMT -5. The time now is 07:08 PM.


Copyright © 1999-2023 Kinook Software, Inc.