Picking up the CI buildnumber during build

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
6 messages Options
Reply | Threaded
Open this post in threaded view
|

Picking up the CI buildnumber during build

Magnus Therning
I'm looking for a way to pick up the CI buildnumber from the
environment
(e.g. $TRAVIS_BUILD_NUMBER) and use it as part of of the output of
`my-tool --version`. I don't really know where to start looking,
so I'm
hoping someone on the list has already done something similar and
can
point me to a working example :)

/M

--
Magnus Therning              OpenPGP: 0x927912051716CE39
email: [hidden email]   jabber: [hidden email]
twitter: magthe               http://therning.org/magnus

I am always doing that which I cannot do, in order that I may
learn
how to do it.
     — Pablo Picasso

_______________________________________________
Haskell-Cafe mailing list
To (un)subscribe, modify options or view archives go to:
http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-cafe
Only members subscribed via the mailman list are allowed to post.

signature.asc (847 bytes) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: Picking up the CI buildnumber during build

Vanessa McHale

Hi Magnus,

I would use getEnv or lookupEnv, along with Template Haskell and the runIO function. This would allow you to embed environment variables at compile time.


On 05/04/2018 07:47 AM, Magnus Therning wrote:
I'm looking for a way to pick up the CI buildnumber from the environment
(e.g. $TRAVIS_BUILD_NUMBER) and use it as part of of the output of
`my-tool --version`. I don't really know where to start looking, so I'm
hoping someone on the list has already done something similar and can
point me to a working example :)

/M

--
Magnus Therning              OpenPGP: 0x927912051716CE39
email: [hidden email]   jabber: [hidden email]
twitter: magthe               http://therning.org/magnus

I am always doing that which I cannot do, in order that I may learn
how to do it.
    — Pablo Picasso


_______________________________________________
Haskell-Cafe mailing list
To (un)subscribe, modify options or view archives go to:
http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-cafe
Only members subscribed via the mailman list are allowed to post.

--

Vanessa McHale
Functional Compiler Engineer | Chicago, IL

_______________________________________________
Haskell-Cafe mailing list
To (un)subscribe, modify options or view archives go to:
http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-cafe
Only members subscribed via the mailman list are allowed to post.

signature.asc (465 bytes) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: Picking up the CI buildnumber during build

Vo Minh Thu
In reply to this post by Magnus Therning
Hi,

I would search for some custom setup.hs with git describe on Google.

I know I did something along those lines in the past. I'll try to find it again.

Cheers,
Thu

Le ven. 4 mai 2018 à 14:47, Magnus Therning <[hidden email]> a écrit :
I'm looking for a way to pick up the CI buildnumber from the
environment
(e.g. $TRAVIS_BUILD_NUMBER) and use it as part of of the output of
`my-tool --version`. I don't really know where to start looking,
so I'm
hoping someone on the list has already done something similar and
can
point me to a working example :)

/M

--
Magnus Therning              OpenPGP: 0x927912051716CE39
email: [hidden email]   jabber: [hidden email]
twitter: magthe               http://therning.org/magnus

I am always doing that which I cannot do, in order that I may
learn
how to do it.
     — Pablo Picasso
_______________________________________________
Haskell-Cafe mailing list
To (un)subscribe, modify options or view archives go to:
http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-cafe
Only members subscribed via the mailman list are allowed to post.

_______________________________________________
Haskell-Cafe mailing list
To (un)subscribe, modify options or view archives go to:
http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-cafe
Only members subscribed via the mailman list are allowed to post.
Reply | Threaded
Open this post in threaded view
|

Re: Picking up the CI buildnumber during build

Adam Bergmark-2
Here is a package for embedding git info https://hackage.haskell.org/package/gitrev

Cheers,
Adam


On Fri, 4 May 2018 at 15:00, Vo Minh Thu <[hidden email]> wrote:
Hi,

I would search for some custom setup.hs with git describe on Google.

I know I did something along those lines in the past. I'll try to find it again.

Cheers,
Thu

Le ven. 4 mai 2018 à 14:47, Magnus Therning <[hidden email]> a écrit :
I'm looking for a way to pick up the CI buildnumber from the
environment
(e.g. $TRAVIS_BUILD_NUMBER) and use it as part of of the output of
`my-tool --version`. I don't really know where to start looking,
so I'm
hoping someone on the list has already done something similar and
can
point me to a working example :)

/M

--
Magnus Therning              OpenPGP: 0x927912051716CE39
email: [hidden email]   jabber: [hidden email]
twitter: magthe               http://therning.org/magnus

I am always doing that which I cannot do, in order that I may
learn
how to do it.
     — Pablo Picasso
_______________________________________________
Haskell-Cafe mailing list
To (un)subscribe, modify options or view archives go to:
http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-cafe
Only members subscribed via the mailman list are allowed to post.
_______________________________________________
Haskell-Cafe mailing list
To (un)subscribe, modify options or view archives go to:
http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-cafe
Only members subscribed via the mailman list are allowed to post.

_______________________________________________
Haskell-Cafe mailing list
To (un)subscribe, modify options or view archives go to:
http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-cafe
Only members subscribed via the mailman list are allowed to post.
Reply | Threaded
Open this post in threaded view
|

Re: Picking up the CI buildnumber during build

Magnus Therning
In reply to this post by Vanessa McHale

Vanessa McHale <[hidden email]> writes:

> Hi Magnus,
>
> I would use getEnv
> <http://hackage.haskell.org/package/base-4.11.1.0/docs/System-Environment.html#v:getEnv>
> or lookupEnv, along with Template Haskell and the runIO
> <http://hackage.haskell.org/package/template-haskell-2.13.0.0/docs/Language-Haskell-TH-Syntax.html#v:runIO>
> function. This would allow you to embed environment variables at
> compile
> time.

Thanks! That were indeed the functions I was looking for. I ended
up with
the following:

```haskell
import Data.Maybe (fromMaybe)
import Language.Haskell.TH (ExpQ, runIO, stringE)
import System.Environment (lookupEnv)

getBuildEnv :: String -> String -> ExpQ
getBuildEnv def varname = (runIO $ fromMaybe def <$> lookupEnv
varname) >>= stringE
```

/M

--
Magnus Therning              OpenPGP: 0x927912051716CE39
email: [hidden email]   jabber: [hidden email]
twitter: magthe               http://therning.org/magnus

Ah, good taste! What a dreadful thing! Taste is the enemy of
creativeness.
     — Pablo Picasso

_______________________________________________
Haskell-Cafe mailing list
To (un)subscribe, modify options or view archives go to:
http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-cafe
Only members subscribed via the mailman list are allowed to post.

signature.asc (847 bytes) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: Picking up the CI buildnumber during build

Magnus Therning
In reply to this post by Adam Bergmark-2

Adam Bergmark <[hidden email]> writes:

> Here is a package for embedding git info
> https://hackage.haskell.org/package/gitrev

Thanks! That was a good example of something similar to what I
wanted,
albeit a bit more complex :)

/M

--
Magnus Therning              OpenPGP: 0x927912051716CE39
email: [hidden email]   jabber: [hidden email]
twitter: magthe               http://therning.org/magnus

If you can tell the truth, you don't have to remember anything.
     — Mark Twain

_______________________________________________
Haskell-Cafe mailing list
To (un)subscribe, modify options or view archives go to:
http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-cafe
Only members subscribed via the mailman list are allowed to post.

signature.asc (847 bytes) Download Attachment